summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-04-30 01:50:48 +0200
committerSlávek Banko <slavek.banko@axis.cz>2021-04-30 01:50:48 +0200
commit9545e31f1887508c47299477d95f08993026c02d (patch)
treeb125661d5ddce09c646ec989e3a07a61e10a60b6
parent807378eeb2a1363a10e4c9715758004df5c51500 (diff)
downloadscripts-9545e31f1887508c47299477d95f08993026c02d.tar.gz
scripts-9545e31f1887508c47299477d95f08993026c02d.zip
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>
-rwxr-xr-xswitch_all_submodules_to_head_and_clean19
1 files changed, 14 insertions, 5 deletions
diff --git a/switch_all_submodules_to_head_and_clean b/switch_all_submodules_to_head_and_clean
index 2c136fd..661ff8d 100755
--- a/switch_all_submodules_to_head_and_clean
+++ b/switch_all_submodules_to_head_and_clean
@@ -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