-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goodnight.sh
executable file
·30 lines (25 loc) · 1.03 KB
/
goodnight.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
#!/bin/sh
set -e
# sync 'nightly' with the current branch in remote (that has been pushed)
#
# we don't want the local version of the current branch,
# because if we haven't pushed new commits into remote yet
# (thru current branch), we don't want to push thru nightly either.
#
CURR_BRANCH_PUSHED="origin/$(git branch --show)"
CURR_BRANCH_PUSHED_COMMIT=$(git rev-parse "$CURR_BRANCH_PUSHED")
git branch -f nightly "$CURR_BRANCH_PUSHED_COMMIT"
LOCAL_NIGHTLY="$(git rev-parse nightly)"
REMOTE_NIGHTLY="$(git rev-parse origin/nightly)"
if [ "$LOCAL_NIGHTLY" = "$REMOTE_NIGHTLY" ]; then
printf "Already up-to-date, skipping push.\n"
else
git push -f origin nightly
fi
POST_STACKED_REBASE_HOOK_PATH=".git/hooks/post-stacked-rebase"
# BACKWARDS FIX FOR PREVIOUS VERSIONS:
# remove the bad script:
if grep "AUTO-GENERATED BY GIT-STACKED-REBASE's goodnight.sh script." "$POST_STACKED_REBASE_HOOK_PATH" >/dev/null 2>&1; then
echo "bad post-rebase script found (previously generated by goodnight.sh), removing."
rm "$POST_STACKED_REBASE_HOOK_PATH";
fi