[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] scripts/git: Cleanup and fix minor git scripts issues



commit c98724b0228b892b738f503434bdc28463ba488c
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Fri Aug 9 00:14:11 2019 +1000

    scripts/git: Cleanup and fix minor git scripts issues
    
    Fix typos, clean up formatting, rewrite some comments, add headings.
    
    Preparation for 31314.
---
 scripts/git/git-merge-forward.sh | 75 ++++++++++++++++++++++++----------------
 scripts/git/git-push-all.sh      | 18 ++++++++--
 2 files changed, 61 insertions(+), 32 deletions(-)

diff --git a/scripts/git/git-merge-forward.sh b/scripts/git/git-merge-forward.sh
index ba2998328..e2b5bde49 100755
--- a/scripts/git/git-merge-forward.sh
+++ b/scripts/git/git-merge-forward.sh
@@ -1,9 +1,11 @@
 #!/usr/bin/env bash
 
-##############################
-# Configuration (change me!) #
-##############################
+#################
+# Configuration #
+#################
 
+# Don't change this configuration - set the env vars in your .profile
+#
 # The general setup that is suggested here is:
 #
 #   GIT_PATH = /home/<user>/git/
@@ -21,20 +23,23 @@ TOR_MASTER_NAME=${TOR_MASTER_NAME:-"tor"}
 # The worktrees location (directory).
 TOR_WKT_NAME=${TOR_WKT_NAME:-"tor-wkt"}
 
-#########################
-# End of configuration. #
-#########################
+##########################
+# Git branches to manage #
+##########################
+
+# The branches and worktrees need to be modified when there is a new branch,
+# and when an old branch is no longer supported.
 
 # Configuration of the branches that needs merging. The values are in order:
-#   (1) Branch name that we merge onto.
-#   (2) Branch name to merge from. In other words, this is merge into (1)
-#   (3) Full path of the git worktree.
+#   (0) current maint/release branch name
+#   (1) previous maint/release name to merge into (0)
+#   (2) Full path of the git worktree
 #
 # As an example:
-#   $ cd <PATH/TO/WORKTREE> (3)
-#   $ git checkout maint-0.3.5 (1)
+#   $ cd <PATH/TO/WORKTREE> (2)
+#   $ git checkout maint-0.3.5 (0)
 #   $ git pull
-#   $ git merge maint-0.3.4 (2)
+#   $ git merge maint-0.3.4 (1)
 #
 # First set of arrays are the maint-* branch and then the release-* branch.
 # New arrays need to be in the WORKTREE= array else they aren't considered.
@@ -65,9 +70,28 @@ ${RELEASE_040[0]}
 ${RELEASE_041[0]}
 EOF
 
-##########################
-# Git Worktree to manage #
-##########################
+#######################
+# Argument processing #
+#######################
+
+# Controlled by the -n option. The dry run option will just output the command
+# that would have been executed for each worktree.
+DRY_RUN=0
+
+while getopts "n" opt; do
+  case "$opt" in
+    n) DRY_RUN=1
+       echo "    *** DRY RUN MODE ***"
+       ;;
+    *)
+       exit 1
+       ;;
+  esac
+done
+
+###########################
+# Git worktrees to manage #
+###########################
 
 # List of all worktrees to work on. All defined above. Ordering is important.
 # Always the maint-* branch BEFORE then the release-*.
@@ -87,9 +111,9 @@ WORKTREE=(
 )
 COUNT=${#WORKTREE[@]}
 
-# Controlled by the -n option. The dry run option will just output the command
-# that would have been executed for each worktree.
-DRY_RUN=0
+#############
+# Constants #
+#############
 
 # Control characters
 CNRM=$'\x1b[0;0m'   # Clear color
@@ -150,7 +174,7 @@ function pull_branch
   fi
 }
 
-# Merge the given branch name ($2) into the current branch ($1).
+# Merge the given branch name ($1) into the current branch ($2).
 function merge_branch
 {
   local cmd="git merge --no-edit $1"
@@ -203,16 +227,6 @@ function fetch_origin
 # Entry point #
 ###############
 
-while getopts "n" opt; do
-  case "$opt" in
-    n) DRY_RUN=1
-       echo "    *** DRY DRUN MODE ***"
-       ;;
-    *)
-       ;;
-  esac
-done
-
 # First, fetch the origin.
 goto_repo "$ORIGIN_PATH"
 fetch_origin
@@ -231,6 +245,7 @@ for ((i=0; i<COUNT; i++)); do
   switch_branch "$current"
   # Update the current branch with an origin merge to get the latest.
   merge_branch_origin "$current"
-  # Merge the previous branch. Ex: merge maint-0.2.5 into maint-0.2.9.
+  # Example:
+  #   merge maint-0.2.9 into maint-0.3.5.
   merge_branch "$previous" "$current"
 done
diff --git a/scripts/git/git-push-all.sh b/scripts/git/git-push-all.sh
index 469d6fe57..617f24cdc 100755
--- a/scripts/git/git-push-all.sh
+++ b/scripts/git/git-push-all.sh
@@ -1,8 +1,8 @@
 #!/usr/bin/env bash
 
-# Usage: git-push-all.sh
+# Usage: git-push-all.sh <git-opts>
 #        env vars: TOR_UPSTREAM_REMOTE_NAME=upstream TOR_PUSH_DELAY=0
-#        options: --no-atomic --dry-run (any other git push option)
+#        git-opts: --no-atomic --dry-run (any other git push option)
 #
 # TOR_PUSH_DELAY pushes the master and maint branches separately, so that CI
 # runs in a sensible order.
@@ -10,11 +10,21 @@
 
 set -e
 
+#################
+# Configuration #
+#################
+
+# Don't change this configuration - set the env vars in your .profile
+#
 # 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}
 
+########################
+# Git branches to push #
+########################
+
 PUSH_BRANCHES=$(echo \
   master \
   {release,maint}-0.4.1 \
@@ -23,6 +33,10 @@ PUSH_BRANCHES=$(echo \
   {release,maint}-0.2.9 \
   )
 
+###############
+# Entry point #
+###############
+
 if [ "$PUSH_DELAY" -le 0 ]; then
   echo "Pushing $PUSH_BRANCHES"
   # We know that there are no spaces in any branch within $PUSH_BRANCHES, so



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits