-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgit-up
executable file
·64 lines (56 loc) · 1.52 KB
/
git-up
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
59
60
61
62
63
64
#!/bin/sh
BRANCH=`git branch-name`
[ -z "$BRANCH" ] && exit 1
UPSTREAM=upstream
git remote -v | cut -f1 | grep -q \^"$UPSTREAM"\$ || UPSTREAM=origin
remote_branch=master
git branch -r | awk '{ print $1 }' | grep -q '^'"$UPSTREAM"'/master$' || remote_branch=main
git branch -r | awk '{ print $1 }' | grep -q '^'"$UPSTREAM"'/devel$' && remote_branch=devel
master=false
case $BRANCH in
master)
remote_branch=master
master=true
;;
main)
remote_branch=main
master=true
;;
devel)
remote_branch=devel
master=true
;;
feature/*)
remote_branch=$BRANCH
master=true
;;
stable-*)
remote_branch=$BRANCH
master=true
;;
esac
ZSTREAMS="4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10"
for release in $ZSTREAMS; do
if pwd | grep -q ansible-hub-ui-$release; then
remote_branch=stable-$release
fi
if pwd | grep -q galaxy_ng-$release; then
remote_branch=stable-$release
fi
done
echo "git-up: Fetching from $UPSTREAM/$remote_branch" 1>&2
if $master; then
git fetch "$UPSTREAM"
git merge --ff-only "$UPSTREAM"/"$remote_branch"
else
git fetch "$UPSTREAM" "$remote_branch"
branch="master"
git branch | awk '{ print $1 }' | grep -q '^master$' || branch=main
git branch | awk '{ print $1 }' | grep -q '^devel$' && branch=devel
echo "git-up: Updating $branch, not $BRANCH" 1>&2
while ! [ -d .git ]; do
cd ..
done
diff -Naur .git/refs/heads/"$branch" .git/refs/remotes/"$UPSTREAM"/"$remote_branch"
cp .git/refs/remotes/"$UPSTREAM"/"$remote_branch" .git/refs/heads/"$branch"
fi