mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Merge branch 'tor-github/pr/1451'
This commit is contained in:
commit
9586ae178a
9
changes/ticket32216
Normal file
9
changes/ticket32216
Normal file
@ -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.
|
@ -29,6 +29,8 @@ function usage()
|
|||||||
echo " CI environment failures, using code that previously passed CI."
|
echo " CI environment failures, using code that previously passed CI."
|
||||||
echo " (default: skip; current: $CURRENT_PUSH_SAME matching branches)"
|
echo " (default: skip; current: $CURRENT_PUSH_SAME matching branches)"
|
||||||
echo " --: pass further arguments to git push."
|
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 " (default: git push --atomic, current: $GIT_PUSH)"
|
||||||
echo
|
echo
|
||||||
echo " env vars:"
|
echo " env vars:"
|
||||||
@ -127,9 +129,11 @@ while getopts ":hr:st:" opt; do
|
|||||||
OPTIND=$((OPTIND - 2))
|
OPTIND=$((OPTIND - 2))
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Assume we're done with script arguments,
|
# Make git push handle the option
|
||||||
# and git push will handle the option
|
# This might mangle options with spaces, use -- for complex options
|
||||||
break
|
GIT_PUSH="$GIT_PUSH $1"
|
||||||
|
shift
|
||||||
|
OPTIND=$((OPTIND - 1))
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -229,20 +233,31 @@ fi
|
|||||||
# Entry point #
|
# Entry point #
|
||||||
###############
|
###############
|
||||||
|
|
||||||
# Skip the test branches that are the same as the upstream branches
|
if [ "$TEST_BRANCH_PREFIX" ]; then
|
||||||
if [ "$PUSH_SAME" -eq 0 ] && [ "$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=
|
NEW_PUSH_BRANCHES=
|
||||||
for b in $PUSH_BRANCHES; do
|
for b in $PUSH_BRANCHES; do
|
||||||
PUSH_COMMIT=$(git rev-parse "$b")
|
PUSH_COMMIT=$(git rev-parse "$b")
|
||||||
SKIP_UPSTREAM=
|
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")
|
UPSTREAM_COMMIT=$(git rev-parse "$u")
|
||||||
if [ "$PUSH_COMMIT" = "$UPSTREAM_COMMIT" ]; then
|
if [ "$PUSH_COMMIT" = "$UPSTREAM_COMMIT" ]; then
|
||||||
SKIP_UPSTREAM="$u"
|
SKIP_UPSTREAM="$u"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$SKIP_UPSTREAM" ]; then
|
if [ "$SKIP_UPSTREAM" ]; then
|
||||||
printf "Skipping unchanged: %s remote: %s\n" \
|
printf "Skipping unchanged: %s matching remote: %s\n" \
|
||||||
"$b" "$SKIP_UPSTREAM"
|
"$b" "$SKIP_UPSTREAM"
|
||||||
else
|
else
|
||||||
if [ "$NEW_PUSH_BRANCHES" ]; then
|
if [ "$NEW_PUSH_BRANCHES" ]; then
|
||||||
@ -255,6 +270,12 @@ if [ "$PUSH_SAME" -eq 0 ] && [ "$TEST_BRANCH_PREFIX" ]; then
|
|||||||
PUSH_BRANCHES=${NEW_PUSH_BRANCHES}
|
PUSH_BRANCHES=${NEW_PUSH_BRANCHES}
|
||||||
fi
|
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
|
if [ "$PUSH_DELAY" -le 0 ]; then
|
||||||
echo "Pushing $PUSH_BRANCHES"
|
echo "Pushing $PUSH_BRANCHES"
|
||||||
# We know that there are no spaces in any branch within $PUSH_BRANCHES, so
|
# 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
|
else
|
||||||
# Push the branches in optimal CI order, with a delay between each push
|
# Push the branches in optimal CI order, with a delay between each push
|
||||||
PUSH_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | sort -V)
|
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
|
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 | \
|
RELEASE_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep release | \
|
||||||
tr "\n" " ")
|
tr "\n" " ") || true # Skipped all release branches
|
||||||
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"
|
|
||||||
else
|
else
|
||||||
# Actually test branches based on maint branches
|
# Actually test branches based on maint branches
|
||||||
MAINT_BRANCHES=$(echo "$PUSH_BRANCHES" | tr " " "\n" | grep -v master)
|
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" \
|
|| true # Skipped all maint test branches
|
||||||
"$PUSH_DELAY" "$MASTER_BRANCH" "$MAINT_BRANCHES"
|
|
||||||
# No release branches
|
# No release branches
|
||||||
RELEASE_BRANCHES=
|
RELEASE_BRANCHES=
|
||||||
fi
|
fi
|
||||||
$GIT_PUSH "$@" "$UPSTREAM_REMOTE" "$MASTER_BRANCH"
|
if [ "$MASTER_BRANCH" ] || [ "$MAINT_BRANCHES" ] \
|
||||||
sleep "$PUSH_DELAY"
|
|| [ "$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
|
# shellcheck disable=SC2086
|
||||||
for b in $MAINT_BRANCHES; do
|
for b in $MASTER_BRANCH $MAINT_BRANCHES; do
|
||||||
$GIT_PUSH "$@" "$UPSTREAM_REMOTE" "$b"
|
$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
|
done
|
||||||
if [ "$RELEASE_BRANCHES" ]; then
|
if [ "$RELEASE_BRANCHES" ]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
|
Loading…
Reference in New Issue
Block a user