summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-10-23 09:11:43 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-10-23 09:11:43 -0400
commit9586ae178a38436e07278f141801208c04b37191 (patch)
treef5b8820b69bf2fea95b878d8a4e2347660f023d4
parent34509e78c6280a103eb243865ce52a70f4a665d0 (diff)
parent226f11002dd743bfb9c1c8cddd5c78a28c9b859f (diff)
downloadtor-9586ae178a38436e07278f141801208c04b37191.tar.gz
tor-9586ae178a38436e07278f141801208c04b37191.zip
Merge branch 'tor-github/pr/1451'
-rw-r--r--changes/ticket322169
-rwxr-xr-xscripts/git/git-push-all.sh74
2 files changed, 64 insertions, 19 deletions
diff --git a/changes/ticket32216 b/changes/ticket32216
new file mode 100644
index 0000000000..86712d700d
--- /dev/null
+++ b/changes/ticket32216
@@ -0,0 +1,9 @@
+ o Minor features (git scripts):
+ - Make git-push-all.sh skip unchanged branches when pushing to upstream.
+ The script already skipped unchanged test branches.
+ Closes ticket 32216.
+ o Minor bugfixes (git scripts):
+ - Avoid sleeping before the last push in git-push-all.sh.
+ Closes ticket 32216.
+ - Forward all unrecognised arguments in git-push-all.sh to git push.
+ Closes ticket 32216.
diff --git a/scripts/git/git-push-all.sh b/scripts/git/git-push-all.sh
index 7e67f4c96d..ebfa576196 100755
--- a/scripts/git/git-push-all.sh
+++ b/scripts/git/git-push-all.sh
@@ -29,6 +29,8 @@ function usage()
echo " CI environment failures, using code that previously passed CI."
echo " (default: skip; current: $CURRENT_PUSH_SAME matching branches)"
echo " --: pass further arguments to git push."
+ echo " All unrecognised arguments are passed to git push, but complex"
+ echo " arguments before -- may be mangled by getopt."
echo " (default: git push --atomic, current: $GIT_PUSH)"
echo
echo " env vars:"
@@ -127,9 +129,11 @@ while getopts ":hr:st:" opt; do
OPTIND=$((OPTIND - 2))
;;
*)
- # Assume we're done with script arguments,
- # and git push will handle the option
- break
+ # Make git push handle the option
+ # This might mangle options with spaces, use -- for complex options
+ GIT_PUSH="$GIT_PUSH $1"
+ shift
+ OPTIND=$((OPTIND - 1))
;;
esac
done
@@ -229,20 +233,31 @@ fi
# Entry point #
###############
-# Skip the test branches that are the same as the upstream branches
-if [ "$PUSH_SAME" -eq 0 ] && [ "$TEST_BRANCH_PREFIX" ]; then
+if [ "$TEST_BRANCH_PREFIX" ]; then
+ # Skip the test branches that are the same as the default or current
+ # upstream branches (they have already been tested)
+ UPSTREAM_SKIP_SAME_AS="$UPSTREAM_BRANCHES $DEFAULT_UPSTREAM_BRANCHES"
+else
+ # Skip the local maint-*, release-*, master branches that are the same as the
+ # current upstream branches, but ignore the default upstream
+ # (we want to update a non-default remote, even if it matches the default)
+ UPSTREAM_SKIP_SAME_AS="$UPSTREAM_BRANCHES"
+fi
+
+# Skip branches that match the relevant upstream(s)
+if [ "$PUSH_SAME" -eq 0 ]; then
NEW_PUSH_BRANCHES=
for b in $PUSH_BRANCHES; do
PUSH_COMMIT=$(git rev-parse "$b")
SKIP_UPSTREAM=
- for u in $DEFAULT_UPSTREAM_BRANCHES $UPSTREAM_BRANCHES; do
+ for u in $UPSTREAM_SKIP_SAME_AS; do
UPSTREAM_COMMIT=$(git rev-parse "$u")
if [ "$PUSH_COMMIT" = "$UPSTREAM_COMMIT" ]; then
SKIP_UPSTREAM="$u"
fi
done
if [ "$SKIP_UPSTREAM" ]; then
- printf "Skipping unchanged: %s remote: %s\n" \
+ printf "Skipping unchanged: %s matching remote: %s\n" \
"$b" "$SKIP_UPSTREAM"
else
if [ "$NEW_PUSH_BRANCHES" ]; then
@@ -255,6 +270,12 @@ if [ "$PUSH_SAME" -eq 0 ] && [ "$TEST_BRANCH_PREFIX" ]; then
PUSH_BRANCHES=${NEW_PUSH_BRANCHES}
fi
+if [ ! "$PUSH_BRANCHES" ]; then
+ echo "No branches to push!"
+ # We expect the rest of the script to run without errors, even if there
+ # are no branches
+fi
+
if [ "$PUSH_DELAY" -le 0 ]; then
echo "Pushing $PUSH_BRANCHES"
# We know that there are no spaces in any branch within $PUSH_BRANCHES, so
@@ -267,27 +288,42 @@ if [ "$PUSH_DELAY" -le 0 ]; then
else
# Push the branches in optimal CI order, with a delay between each push
PUSH_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | sort -V)
- MASTER_BRANCH=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep master)
+ MASTER_BRANCH=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep master) \
+ || true # Skipped master branch
if [ -z "$TEST_BRANCH_PREFIX" ]; then
- MAINT_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep maint)
+ MAINT_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep maint) \
+ || true # Skipped all maint branches
RELEASE_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep release | \
- tr "\n" " ")
- printf "Pushing with %ss delays, so CI runs in this order:\n%s\n%s\n%s\n" \
- "$PUSH_DELAY" "$MASTER_BRANCH" "$MAINT_BRANCHES" "$RELEASE_BRANCHES"
+ tr "\n" " ") || true # Skipped all release branches
else
# Actually test branches based on maint branches
- MAINT_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep -v master)
- printf "Pushing with %ss delays, so CI runs in this order:\n%s\n%s\n" \
- "$PUSH_DELAY" "$MASTER_BRANCH" "$MAINT_BRANCHES"
+ MAINT_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep -v master) \
+ || true # Skipped all maint test branches
# No release branches
RELEASE_BRANCHES=
fi
- $GIT_PUSH "$@" "$UPSTREAM_REMOTE" "$MASTER_BRANCH"
- sleep "$PUSH_DELAY"
+ if [ "$MASTER_BRANCH" ] || [ "$MAINT_BRANCHES" ] \
+ || [ "$RELEASE_BRANCHES" ]; then
+ printf "Pushing with %ss delays, so CI runs in this order:\n" "$PUSH_DELAY"
+ if [ "$MASTER_BRANCH" ]; then
+ printf "%s\n" "$MASTER_BRANCH"
+ fi
+ if [ "$MAINT_BRANCHES" ]; then
+ printf "%s\n" "$MAINT_BRANCHES"
+ fi
+ if [ "$RELEASE_BRANCHES" ]; then
+ printf "%s\n" "$RELEASE_BRANCHES"
+ fi
+ fi
# shellcheck disable=SC2086
- for b in $MAINT_BRANCHES; do
+ for b in $MASTER_BRANCH $MAINT_BRANCHES; do
$GIT_PUSH "$@" "$UPSTREAM_REMOTE" "$b"
- sleep "$PUSH_DELAY"
+ # If we are pushing more than one branch, delay.
+ # In the unlikely scenario where we are pushing maint without master,
+ # or maint without release, there may be an extra delay
+ if [ "$MAINT_BRANCHES" ] || [ "$RELEASE_BRANCHES" ]; then
+ sleep "$PUSH_DELAY"
+ fi
done
if [ "$RELEASE_BRANCHES" ]; then
# shellcheck disable=SC2086