summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-11-10 17:07:33 +0100
committerThomas Haller <thaller@redhat.com>2020-11-10 17:14:07 +0100
commit45cb0ef403b08561cce9502e0203ce6c859bfdff (patch)
treeb8cfde604b850d623bddda027be8919063a43a5a
parent9ebf5f938caef806c7051b4a65b6135bba0e593e (diff)
downloadNetworkManager-45cb0ef403b08561cce9502e0203ce6c859bfdff.tar.gz
contrib/checkpatch: use random name for git remote and clean up afterwards
-rwxr-xr-xcontrib/scripts/checkpatch-feature-branch.sh19
1 files changed, 14 insertions, 5 deletions
diff --git a/contrib/scripts/checkpatch-feature-branch.sh b/contrib/scripts/checkpatch-feature-branch.sh
index 72e5903dae..292a429109 100755
--- a/contrib/scripts/checkpatch-feature-branch.sh
+++ b/contrib/scripts/checkpatch-feature-branch.sh
@@ -13,19 +13,24 @@ if printf '%s' "$HEAD" | grep -q '\.\.'; then
# Check the explicitly specified range from the argument.
REFS=( $(git log --reverse --format='%H' "$HEAD") ) || die "not a valid range (HEAD is $HEAD)"
else
- BASE_REF="refs/remotes/origin/"
+ BASE_REF="refs/remotes/origin"
+ NM_UPSTREAM_REMOTE=
if [ "$NM_CHECKPATCH_FETCH_UPSTREAM" == 1 ]; then
- git remote add nm-upstream https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
- git fetch nm-upstream || die "failure to fetch from https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git"
- BASE_REF="refs/remotes/nm-upstream/"
+ NM_UPSTREAM_REMOTE="nm-upstream-$(date '+%Y%m%d-%H%M%S')-$RANDOM"
+ git remote add "$NM_UPSTREAM_REMOTE" https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
+ BASE_REF="refs/remotes/$NM_UPSTREAM_REMOTE"
+ git fetch "$NM_UPSTREAM_REMOTE" \
+ "refs/heads/master:$BASE_REF/master" \
+ "refs/heads/nm-*:$BASE_REF/nm-*" \
+ || die "failure to fetch from https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git"
fi
# the argument is only a single ref (or the default "HEAD").
# Find all commits that branch off one of the stable branches or master
# and lead to $HEAD. These are the commits of the feature branch.
- RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF"'\(master\|nm-1-[0-9]\+\)$#\1..'"$HEAD"'#p' -n) )
+ RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF/"'\(master\|nm-1-[0-9]\+\)$#\1..'"$HEAD"'#p' -n) )
[ "${#RANGES[@]}" != 0 ] || die "cannot detect git-ranges (HEAD is $(git rev-parse "$HEAD"))"
@@ -36,6 +41,10 @@ else
# stable nm-1-* branches. Just check the patch itself.
REFS=( "$HEAD" )
fi
+
+ if [ -n "$NM_UPSTREAM_REMOTE" ]; then
+ git remote remove "$NM_UPSTREAM_REMOTE"
+ fi
fi
SUCCESS=0