-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitvb-publish-all
executable file
·59 lines (48 loc) · 1.32 KB
/
gitvb-publish-all
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
#!/usr/bin/env bash
set -e
GITVB_HOME="./.git/.gitvb-v0"
MAIN_BRANCH="${MAIN_BRANCH:-main}"
STAGE_STASH_MSG="STAGED CHANGES FROM GITVB-PUBLISH-ALL"
stashedStage="0"
if [ ! -z "$(git diff --staged)" ]; then
echo "WARNING: stashing the stage!"
git stash --staged -m "$STAGE_STASH_MSG"
stashedStage="1"
fi
gitvb-wip publish-all
if [ "$(git branch --show-current)" != "$MAIN_BRANCH" ]; then
echo "you are not on the main branch: $MAIN_BRANCH"
exit 1
fi
pickedBranches="$(gitvb-ls)"
git fetch --progress
nMainBehind=$(git rev-list --count $MAIN_BRANCH..origin/$MAIN_BRANCH)
if [ "$nMainBehind" != "0" ]; then
echo
echo "** you need to resync before publishing!"
echo
# gitvb-resync
exit 1
fi
if [ ! -z "$pickedBranches" ]; then
while IFS= read -r line; do
if [ -z "$line" ]; then
continue
fi
gitvb-publish "$line" --no-resync
done <<< "$pickedBranches"
fi
gitvb-wip-undo publish-all
# undo the stage stash
if [ "$stashedStage" == "1" ]; then
if [[ "$(git stash list)" == *$STAGE_STASH_MSG* ]]; then
echo "Reapplying stash onto stage!"
git stash pop --index # index pops onto the stage
else
echo "oops, don't have expected stash for the stage!"
exit 8
fi
else
echo "no stash to reapply back to stage"
fi
gitvb-status