-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitvb-sync-unpicked
executable file
·55 lines (46 loc) · 1.37 KB
/
gitvb-sync-unpicked
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
#!/usr/bin/env bash
set -e
GITVB_HOME="./.git/.gitvb-v0"
MAIN_BRANCH="${MAIN_BRANCH:-main}"
if [ ! -z "$(git diff --staged)" ]; then
echo "there are staged changes. exiting."
exit 1
fi
if [ "$(git branch --show-current)" != "$MAIN_BRANCH" ]; then
echo "you are not on the main branch: $MAIN_BRANCH"
exit 1
fi
if [ "$1" == "" ]; then
echo "usage: gitvb-sync-unpicked <branch>"
exit 1
fi
pickBranch="$1"
vbFilePath="$GITVB_HOME/$pickBranch.gitvb"
if [ -f "$vbFilePath" ]; then
echo "cannot rebase picked branch $pickBranch"
exit 2
fi
if [ -z "$(git ls-remote --heads origin $pickBranch)" ]; then
echo
echo "*** The branch '$pickBranch' does not exist on the remote."
echo " Cannot safely pick this branch. It was probably merged then deleted."
echo " Cleanup by running $ gitvb-rm-unpicked $pickBranch"
echo
exit 4
fi
git fetch --progress
gitvb-wip unpick-sync
git checkout "$pickBranch"
git pull --rebase
git rebase origin/$MAIN_BRANCH
if [ "$(git branch --show-current)" != "$pickBranch" ]; then
echo "somehow not on '$pickBranch' - bailing before force pushing and causing damage!"
exit 17
fi
# git push --force-with-lease
git checkout $MAIN_BRANCH
gitvb-wip-undo unpick-sync
echo
echo "$pickBranch has been resynced with origin/$MAIN_BRANCH succesfully"
echo "it can now be picked with $ gitvb-pick $pickBranch"
echo