Update switch_all_submodules_to_head_and_clean

+ Ensure checkout for new upstream branch in worktree mode of tree.
+ To test the availability of repository use curl if it is present.
+ Sign commits using GPG during rebase if the signing key is set.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 9545e31f18)
r14.0.x r14.0.10
Slávek Banko 3 years ago
parent 23145430b1
commit 26adf9d607
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -33,7 +33,7 @@ if [[ -z "$remote" ]]; then
fi
# get git user
echobd "Preparing $(git rev-parse --show-toplevel | xargs -r basename) $branch branch for development use"
echobd "Preparing $(git rev-parse --show-toplevel | xargs -r basename) on $branch branch for development use"
if [[ $1 == "" ]]; then
gituser=`git config --local remote.$remote.url | sed -n "s|\(https\?://\)\?\([^@]*\)@.*|\2|p" | grep -v "\(anonymous\|system\)"`
else
@ -48,6 +48,10 @@ if [[ $gituser == "" ]]; then
gituser="anonymous"
fi
if [[ -n "$(git config --get user.signingkey)" ]]; then
GIT_SIGN="-S"
fi
# check git abilities
if [[ -n "`git status --help 2>/dev/null|grep -- '--ignore-submodules'`" ]]; then
GIT_IGNORE_SUBMODULES="--ignore-submodules"
@ -76,9 +80,13 @@ updateModule() {
fi
git remote |
while read REMOTE; do
REPO_SERVER=$(git config remote."$REMOTE".url |
REPO_URL=$(git config remote."$REMOTE".url)
REPO_SERVER=$(echo "$REPO_URL" |
sed -n "s|^http[^/]*/*\([^@]*@\)\?\([^/]*\)/.*|\2|p")
if [ -x /usr/bin/fping ] && [ -n "$REPO_SERVER" ]; then
if [ -x /usr/bin/curl ] && [ "${REPO_URL}" != "${REPO_URL#http}" ]; then
curl --silent --connect-timeout 10 --max-time 15 --location --netrc \
$REPO_URL/info/refs?service=git-upload-pack >/dev/null || continue
elif [ -x /usr/bin/fping ] && [ -n "$REPO_SERVER" ]; then
fping -q -r1 "$REPO_SERVER" || continue
fi
echo Fetching $REMOTE
@ -88,7 +96,7 @@ updateModule() {
git checkout $branch
remote=`git config branch."$branch".remote`
[[ -n "$remote" ]] || return
git rebase $remote/$branch $branch
git rebase $GIT_SIGN $remote/$branch $branch
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD
git clean -dxff
@ -135,8 +143,9 @@ updateModule() {
cd $REPO_LOCALTREE &&
git fetch &&
git worktree prune &&
git worktree add $PARENTDIR/$MODULE$submodule $branch &&
git worktree add $PARENTDIR/$MODULE$submodule origin/$branch &&
cd $PARENTDIR/$MODULE$submodule &&
git checkout $branch &&
git branch --set-upstream-to=origin/$branch
) || continue
fi

Loading…
Cancel
Save