From 436e0c8ca4a0cfb5206b404835c86aae45d98c86 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 28 Feb 2019 13:23:23 -0500 Subject: [PATCH] maint: Make git scripts fetch origin once Replace the "git pull" by one single "git fetch origin" and then "git merge" into each defined branches. This speeds up the process considerably. Closes #29616 Signed-off-by: David Goulet --- scripts/maint/git-merge-forward.sh | 39 ++++++++++++++++++++++++++++-- scripts/maint/git-pull-all.sh | 32 ++++++++++++++++++++---- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/scripts/maint/git-merge-forward.sh b/scripts/maint/git-merge-forward.sh index e22e7befad..4b294f4945 100755 --- a/scripts/maint/git-merge-forward.sh +++ b/scripts/maint/git-merge-forward.sh @@ -48,6 +48,11 @@ RELEASE_034=( "release-0.3.4" "maint-0.3.4" "$GIT_PATH/$TOR_WKT_NAME/release-0.3 RELEASE_035=( "release-0.3.5" "maint-0.3.5" "$GIT_PATH/$TOR_WKT_NAME/release-0.3.5" ) RELEASE_040=( "release-0.4.0" "maint-0.4.0" "$GIT_PATH/$TOR_WKT_NAME/release-0.4.0" ) +# The master branch path has to be the main repository thus contains the +# origin that will be used to fetch the updates. All the worktrees are created +# from that repository. +ORIGIN_PATH="$GIT_PATH/$TOR_MASTER_NAME" + ########################## # Git Worktree to manage # ########################## @@ -146,6 +151,19 @@ function merge_branch fi } +# Pull the given branch name. +function merge_branch_origin +{ + local cmd="git merge --ff-only origin/$1" + printf " %s Merging branch origin/%s..." "$MARKER" "$1" + if [ $DRY_RUN -eq 0 ]; then + msg=$( eval "$cmd" 2>&1 ) + validate_ret $? "$msg" + else + printf "\\n %s\\n" "${IWTH}$cmd${CNRM}" + fi +} + # Go into the worktree repository. function goto_repo { @@ -156,6 +174,19 @@ function goto_repo cd "$1" || exit } +# Fetch the origin. No arguments. +function fetch_origin +{ + local cmd="git fetch origin" + printf " %s Fetching origin..." "$MARKER" + if [ $DRY_RUN -eq 0 ]; then + msg=$( eval "$cmd" 2>&1 ) + validate_ret $? "$msg" + else + printf "\\n %s\\n" "${IWTH}$cmd${CNRM}" + fi +} + ############### # Entry point # ############### @@ -170,6 +201,10 @@ while getopts "n" opt; do esac done +# First, fetch the origin. +goto_repo "$ORIGIN_PATH" +fetch_origin + # Go over all configured worktree. for ((i=0; i&1 ) validate_ret $? "$msg" @@ -143,6 +148,19 @@ function goto_repo cd "$1" || exit } +# Fetch the origin. No arguments. +function fetch_origin +{ + local cmd="git fetch origin" + printf " %s Fetching origin..." "$MARKER" + if [ $DRY_RUN -eq 0 ]; then + msg=$( eval "$cmd" 2>&1 ) + validate_ret $? "$msg" + else + printf "\\n %s\\n" "${IWTH}$cmd${CNRM}" + fi +} + ############### # Entry point # ############### @@ -157,6 +175,10 @@ while getopts "n" opt; do esac done +# First, fetch the origin. +goto_repo "$ORIGIN_PATH" +fetch_origin + # Go over all configured worktree. for ((i=0; i