mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
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 <dgoulet@torproject.org>
This commit is contained in:
parent
cb0d403049
commit
436e0c8ca4
@ -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_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" )
|
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 #
|
# Git Worktree to manage #
|
||||||
##########################
|
##########################
|
||||||
@ -146,6 +151,19 @@ function merge_branch
|
|||||||
fi
|
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.
|
# Go into the worktree repository.
|
||||||
function goto_repo
|
function goto_repo
|
||||||
{
|
{
|
||||||
@ -156,6 +174,19 @@ function goto_repo
|
|||||||
cd "$1" || exit
|
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 #
|
# Entry point #
|
||||||
###############
|
###############
|
||||||
@ -170,6 +201,10 @@ while getopts "n" opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# First, fetch the origin.
|
||||||
|
goto_repo "$ORIGIN_PATH"
|
||||||
|
fetch_origin
|
||||||
|
|
||||||
# Go over all configured worktree.
|
# Go over all configured worktree.
|
||||||
for ((i=0; i<COUNT; i++)); do
|
for ((i=0; i<COUNT; i++)); do
|
||||||
current=${!WORKTREE[$i]:0:1}
|
current=${!WORKTREE[$i]:0:1}
|
||||||
@ -182,8 +217,8 @@ for ((i=0; i<COUNT; i++)); do
|
|||||||
goto_repo "$repo_path"
|
goto_repo "$repo_path"
|
||||||
# Checkout the current branch
|
# Checkout the current branch
|
||||||
switch_branch "$current"
|
switch_branch "$current"
|
||||||
# Update the current branch with a pull to get the latest.
|
# Update the current branch with an origin merge to get the latest.
|
||||||
pull_branch "$current"
|
merge_branch_origin "$current"
|
||||||
# Merge the previous branch. Ex: merge maint-0.2.5 into maint-0.2.9.
|
# Merge the previous branch. Ex: merge maint-0.2.5 into maint-0.2.9.
|
||||||
merge_branch "$previous" "$current"
|
merge_branch "$previous" "$current"
|
||||||
done
|
done
|
||||||
|
@ -47,6 +47,11 @@ RELEASE_034=( "release-0.3.4" "$GIT_PATH/$TOR_WKT_NAME/release-0.3.4" )
|
|||||||
RELEASE_035=( "release-0.3.5" "$GIT_PATH/$TOR_WKT_NAME/release-0.3.5" )
|
RELEASE_035=( "release-0.3.5" "$GIT_PATH/$TOR_WKT_NAME/release-0.3.5" )
|
||||||
RELEASE_040=( "release-0.4.0" "$GIT_PATH/$TOR_WKT_NAME/release-0.4.0" )
|
RELEASE_040=( "release-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 #
|
# Git Worktree to manage #
|
||||||
##########################
|
##########################
|
||||||
@ -121,10 +126,10 @@ function switch_branch
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Pull the given branch name.
|
# Pull the given branch name.
|
||||||
function pull_branch
|
function merge_branch
|
||||||
{
|
{
|
||||||
local cmd="git pull"
|
local cmd="git merge --ff-only origin/$1"
|
||||||
printf " %s Pulling branch %s..." "$MARKER" "$1"
|
printf " %s Merging branch origin/%s..." "$MARKER" "$1"
|
||||||
if [ $DRY_RUN -eq 0 ]; then
|
if [ $DRY_RUN -eq 0 ]; then
|
||||||
msg=$( eval "$cmd" 2>&1 )
|
msg=$( eval "$cmd" 2>&1 )
|
||||||
validate_ret $? "$msg"
|
validate_ret $? "$msg"
|
||||||
@ -143,6 +148,19 @@ function goto_repo
|
|||||||
cd "$1" || exit
|
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 #
|
# Entry point #
|
||||||
###############
|
###############
|
||||||
@ -157,6 +175,10 @@ while getopts "n" opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# First, fetch the origin.
|
||||||
|
goto_repo "$ORIGIN_PATH"
|
||||||
|
fetch_origin
|
||||||
|
|
||||||
# Go over all configured worktree.
|
# Go over all configured worktree.
|
||||||
for ((i=0; i<COUNT; i++)); do
|
for ((i=0; i<COUNT; i++)); do
|
||||||
current=${!WORKTREE[$i]:0:1}
|
current=${!WORKTREE[$i]:0:1}
|
||||||
@ -168,6 +190,6 @@ for ((i=0; i<COUNT; i++)); do
|
|||||||
goto_repo "$repo_path"
|
goto_repo "$repo_path"
|
||||||
# Checkout the current branch
|
# Checkout the current branch
|
||||||
switch_branch "$current"
|
switch_branch "$current"
|
||||||
# Update the current branch with a pull to get the latest.
|
# Update the current branch by merging the origin to get the latest.
|
||||||
pull_branch "$current"
|
merge_branch "$current"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user