-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitvb-publish
executable file
·61 lines (49 loc) · 1.25 KB
/
gitvb-publish
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
#!/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-publish <branch>"
exit 1
fi
publishBranch="$1"
vbFilePath="$GITVB_HOME/$publishBranch.gitvb"
if [ ! -f "$vbFilePath" ]; then
echo "not picked $publishBranch"
exit 2
fi
# if [ "$2" != "--no-resync" ]; then
# echo
# echo "** need to resync before publishing!"
# echo
# gitvb-resync
# fi
echo
echo "** publishing your changes to $publishBranch"
echo
gitvb-wip publish
git checkout "$publishBranch"
nRemote=$(git rev-list --count "origin/$publishBranch" ^"$publishBranch")
echo "nRemote=$nRemote"
if [ "$nRemote" != "0" ]; then
echo " (force required, remote not on $MAIN_BRANCH)"
echo "force pushing..."
git push --force-with-lease || git push --force-with-lease
else
echo "pushing..."
echo " (not using force)"
git push || git push
fi
git checkout "$MAIN_BRANCH"
gitvb-wip-undo publish
echo
echo "** succesfully published to $publishBranch"
echo