-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.sh
executable file
·58 lines (49 loc) · 1.13 KB
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash -e
# @installable
MYSELF="$(readlink -f "$0")"
MYDIR="${MYSELF%/*}"
ME=$(basename $MYSELF)
source $MYDIR/env
[[ -f $LOCAL_ENV ]] && source $LOCAL_ENV
source $MYDIR/log.sh
source $MYDIR/db.sh
source $(real require.sh)
while test $# -gt 0
do
case "$1" in
--target)
shift
target="$1"
;;
-*)
echo "bad option '$1'"
exit 1
;;
esac
shift
done
# TODO fix: get from task?
[[ -z "$target" ]] && target=$(db CURR_FEATURE_TARGET_BRANCH)
require target
info "sync with '$target'?"
read confirm
if [[ ! -n "$(curr_branch)" ]]; then
err "you have to be inside the repository directory"
branchd="$(db CURR_FEATURE_DIR)"
if [[ -d "$branchd" ]]; then
info "maybe you want to go to $branchd ?"
fi
exit 1
fi
current=$(db CURR_FEATURE)
info "... from $current"
git checkout $target
git pull
git checkout $current
git merge $target
if [[ $(git status | grep -ci 'Your branch is ahead' || true) -gt 0 ]]; then
info "detected $current ahead of $target, pushing changes"
git push
fi
info "$current is synced with $target"
$MYDIR/rr-comment.sh "synced to $target"