2019-06-11 14:29:10 +10:00
|
|
|
#!/usr/bin/env bash
|
2019-02-14 14:27:40 -05:00
|
|
|
|
2019-08-09 00:14:11 +10:00
|
|
|
# Usage: git-push-all.sh <git-opts>
|
2019-08-08 12:33:42 +10:00
|
|
|
# env vars: TOR_UPSTREAM_REMOTE_NAME=upstream TOR_PUSH_DELAY=0
|
2019-08-09 00:14:11 +10:00
|
|
|
# git-opts: --no-atomic --dry-run (any other git push option)
|
2019-08-08 12:33:42 +10:00
|
|
|
#
|
|
|
|
# TOR_PUSH_DELAY pushes the master and maint branches separately, so that CI
|
|
|
|
# runs in a sensible order.
|
|
|
|
# push --atomic is the default when TOR_PUSH_DELAY=0, and for release branches.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2019-08-09 00:14:11 +10:00
|
|
|
#################
|
|
|
|
# Configuration #
|
|
|
|
#################
|
|
|
|
|
|
|
|
# Don't change this configuration - set the env vars in your .profile
|
|
|
|
#
|
2019-08-08 12:33:42 +10:00
|
|
|
# The upstream remote which git.torproject.org/tor.git points to.
|
|
|
|
UPSTREAM_REMOTE=${TOR_UPSTREAM_REMOTE_NAME:-"upstream"}
|
|
|
|
# Add a delay between pushes, so CI runs on the most important branches first
|
|
|
|
PUSH_DELAY=${TOR_PUSH_DELAY:-0}
|
|
|
|
|
2019-08-09 00:14:11 +10:00
|
|
|
########################
|
|
|
|
# Git branches to push #
|
|
|
|
########################
|
|
|
|
|
2019-08-26 09:58:38 -04:00
|
|
|
PUSH_BRANCHES=$(echo \
|
2019-08-08 12:33:42 +10:00
|
|
|
master \
|
|
|
|
{release,maint}-0.4.1 \
|
|
|
|
{release,maint}-0.4.0 \
|
|
|
|
{release,maint}-0.3.5 \
|
|
|
|
{release,maint}-0.2.9 \
|
2019-08-26 09:58:38 -04:00
|
|
|
)
|
2019-08-08 12:33:42 +10:00
|
|
|
|
2019-08-09 00:14:11 +10:00
|
|
|
###############
|
|
|
|
# Entry point #
|
|
|
|
###############
|
|
|
|
|
2019-08-08 12:33:42 +10:00
|
|
|
if [ "$PUSH_DELAY" -le 0 ]; then
|
|
|
|
echo "Pushing $PUSH_BRANCHES"
|
2019-08-26 09:58:38 -04:00
|
|
|
# We know that there are no spaces in any branch within $PUSH_BRANCHES, so
|
|
|
|
# it is safe to use it unquoted. (This also applies to the other shellcheck
|
|
|
|
# exceptions below.)
|
|
|
|
#
|
|
|
|
# shellcheck disable=SC2086
|
2019-08-08 12:33:42 +10:00
|
|
|
git push --atomic "$@" "$UPSTREAM_REMOTE" $PUSH_BRANCHES
|
|
|
|
else
|
2019-08-26 09:58:38 -04:00
|
|
|
PUSH_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | sort -V)
|
|
|
|
MASTER_BRANCH=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep master)
|
|
|
|
MAINT_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep maint)
|
|
|
|
RELEASE_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep release | \
|
|
|
|
tr "\n" " ")
|
2019-08-08 12:33:42 +10:00
|
|
|
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"
|
2019-08-26 09:58:38 -04:00
|
|
|
git push "$@" "$UPSTREAM_REMOTE" "$MASTER_BRANCH"
|
2019-08-08 12:33:42 +10:00
|
|
|
sleep "$PUSH_DELAY"
|
2019-08-26 09:58:38 -04:00
|
|
|
# shellcheck disable=SC2086
|
2019-08-08 12:33:42 +10:00
|
|
|
for b in $MAINT_BRANCHES; do
|
|
|
|
git push "$@" "$UPSTREAM_REMOTE" $b
|
|
|
|
sleep "$PUSH_DELAY"
|
|
|
|
done
|
2019-08-26 09:58:38 -04:00
|
|
|
# shellcheck disable=SC2086
|
2019-08-08 12:33:42 +10:00
|
|
|
git push --atomic "$@" "$UPSTREAM_REMOTE" $RELEASE_BRANCHES
|
|
|
|
fi
|