aboutsummaryrefslogtreecommitdiff
path: root/scripts/git/git-push-all.sh
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-08-12 11:12:41 +1000
committerteor <teor@torproject.org>2019-08-29 22:50:47 +1000
commitb47b71ad2fc095b43437317011d127424188eb4f (patch)
treedba55e91950a5dcfaf4b2cc0929382d350a15584 /scripts/git/git-push-all.sh
parent70387054b9011b8d430a53db5406954f157afa06 (diff)
downloadtor-b47b71ad2fc095b43437317011d127424188eb4f.tar.gz
tor-b47b71ad2fc095b43437317011d127424188eb4f.zip
scripts/git: Let git-push-all.sh skip unchanged test branches
Skip test branches that are the same as remote maint/release/master branches. Add a TOR_PUSH_SAME and -s argument to git-push-all.sh to change this default. Part of 31314.
Diffstat (limited to 'scripts/git/git-push-all.sh')
-rwxr-xr-xscripts/git/git-push-all.sh73
1 files changed, 69 insertions, 4 deletions
diff --git a/scripts/git/git-push-all.sh b/scripts/git/git-push-all.sh
index 2d6e77a8c1..8a8ef1f2db 100755
--- a/scripts/git/git-push-all.sh
+++ b/scripts/git/git-push-all.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Usage: git-push-all.sh -t <test-branch-prefix> -r <remote-name>
+# Usage: git-push-all.sh -t <test-branch-prefix> -r <remote-name> -s
# -- <git-opts>
# env vars: TOR_UPSTREAM_REMOTE_NAME=upstream TOR_PUSH_DELAY=0
# git-opts: --no-atomic --dry-run (any other git push option)
@@ -20,10 +20,17 @@ set -e
# git push command and default arguments
GIT_PUSH=${TOR_GIT_PUSH:-"git push --atomic"}
# The upstream remote which git.torproject.org/tor.git points to.
-# In test branch mode, override this setting with -r <remote-name>
-UPSTREAM_REMOTE=${TOR_UPSTREAM_REMOTE_NAME:-"upstream"}
+DEFAULT_UPSTREAM_REMOTE=${TOR_UPSTREAM_REMOTE_NAME:-"upstream"}
+# Push to a different upstream remote using -r <remote-name>
+UPSTREAM_REMOTE=${DEFAULT_UPSTREAM_REMOTE}
# Add a delay between pushes, so CI runs on the most important branches first
PUSH_DELAY=${TOR_PUSH_DELAY:-0}
+# Push (1) or skip (0) test branches that are the same as an upstream
+# maint/master branch. Push if you are testing that the CI environment still
+# works on old code, skip if you are testing new code in the branch.
+# Default: skip unchanged branches.
+# Inverted by the -s option.
+PUSH_SAME=${TOR_PUSH_SAME:-0}
#######################
# Argument processing #
@@ -34,7 +41,7 @@ PUSH_DELAY=${TOR_PUSH_DELAY:-0}
# <tbbn>_029, <tbbn>_035, ... , <tbbn>_master, and merge forward.
TEST_BRANCH_PREFIX=
-while getopts ":r:t:" opt; do
+while getopts ":r:st:" opt; do
case "$opt" in
r) UPSTREAM_REMOTE="$OPTARG"
echo " *** PUSHING TO REMOTE: ${UPSTREAM_REMOTE} ***"
@@ -42,6 +49,15 @@ while getopts ":r:t:" opt; do
shift
OPTIND=$[$OPTIND - 2]
;;
+ s) PUSH_SAME=$[! "$PUSH_SAME" ]
+ if [ "$PUSH_SAME" -eq 0 ]; then
+ echo " *** SKIPPING UNCHANGED TEST BRANCHES ***"
+ else
+ echo " *** PUSHING UNCHANGED TEST BRANCHES ***"
+ fi
+ shift
+ OPTIND=$[$OPTIND - 1]
+ ;;
t) TEST_BRANCH_PREFIX="$OPTARG"
echo " *** PUSHING TEST BRANCHES: ${TEST_BRANCH_PREFIX}_nnn ***"
shift
@@ -73,6 +89,29 @@ if [ "$TEST_BRANCH_PREFIX" ]; then
fi
fi
+################################
+# Git upstream remote branches #
+################################
+
+DEFAULT_UPSTREAM_BRANCHES=
+if [ "$DEFAULT_UPSTREAM_REMOTE" != "$UPSTREAM_REMOTE" ]; then
+ DEFAULT_UPSTREAM_BRANCHES=`echo \
+ ${DEFAULT_UPSTREAM_REMOTE}/master \
+ ${DEFAULT_UPSTREAM_REMOTE}/{release,maint}-0.4.1 \
+ ${DEFAULT_UPSTREAM_REMOTE}/{release,maint}-0.4.0 \
+ ${DEFAULT_UPSTREAM_REMOTE}/{release,maint}-0.3.5 \
+ ${DEFAULT_UPSTREAM_REMOTE}/{release,maint}-0.2.9 \
+ `
+fi
+
+UPSTREAM_BRANCHES=`echo \
+ ${UPSTREAM_REMOTE}/master \
+ ${UPSTREAM_REMOTE}/{release,maint}-0.4.1 \
+ ${UPSTREAM_REMOTE}/{release,maint}-0.4.0 \
+ ${UPSTREAM_REMOTE}/{release,maint}-0.3.5 \
+ ${UPSTREAM_REMOTE}/{release,maint}-0.2.9 \
+ `
+
########################
# Git branches to push #
########################
@@ -115,6 +154,32 @@ fi
# Entry point #
###############
+# Skip the test branches that are the same as the upstream branches
+if [ "$PUSH_SAME" -eq 0 -a "$TEST_BRANCH_PREFIX" ]; 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
+ 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" \
+ "$b" "$SKIP_UPSTREAM"
+ else
+ if [ "$NEW_PUSH_BRANCHES" ]; then
+ NEW_PUSH_BRANCHES="${NEW_PUSH_BRANCHES} ${b}"
+ else
+ NEW_PUSH_BRANCHES="${b}"
+ fi
+ fi
+ done
+ PUSH_BRANCHES=${NEW_PUSH_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