summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-22 14:01:41 +0200
committerThomas Haller <thaller@redhat.com>2018-10-22 14:09:47 +0200
commit924a895a1af15166bfb24af55a90f13db42b1801 (patch)
tree1523344ac6e3b0216644f85ffedeed008cd26c1f
parent8d6d7c48f99afaae9713f2a397a84c97d09cc623 (diff)
downloadNetworkManager-924a895a1af15166bfb24af55a90f13db42b1801.tar.gz
checkpatch: support ranges for "checkpatch-feature-branch.sh"
Improve "checkpatch-feature-branch.sh" to support accepting range as argument.
-rwxr-xr-xcontrib/scripts/checkpatch-feature-branch.sh29
1 files changed, 19 insertions, 10 deletions
diff --git a/contrib/scripts/checkpatch-feature-branch.sh b/contrib/scripts/checkpatch-feature-branch.sh
index 2e0b589194..e2fe5b422f 100755
--- a/contrib/scripts/checkpatch-feature-branch.sh
+++ b/contrib/scripts/checkpatch-feature-branch.sh
@@ -1,26 +1,35 @@
#!/bin/bash
die() {
- printf "%s\n" "$@"
- exit 1
+ printf "%s\n" "$@"
+ exit 1
}
HEAD="${1:-HEAD}"
BASE_DIR="$(dirname "$0")"
-BASE_REF="refs/remotes/origin/"
+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/"
-RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF"'\(master\|nm-1-[0-9]\+\)$#\1..'"$HEAD"'#p' -n) )
+ # 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[@]}" != 0 ] || die "cannot detect git-ranges (HEAD is $(git rev-parse HEAD))"
+ RANGES=( $(git show-ref | sed 's#^\(.*\) '"$BASE_REF"'\(master\|nm-1-[0-9]\+\)$#\1..'"$HEAD"'#p' -n) )
-REFS=( $(git log --reverse --format='%H' "${RANGES[@]}") )
+ [ "${#RANGES[@]}" != 0 ] || die "cannot detect git-ranges (HEAD is $(git rev-parse HEAD))"
-if [ "${#REFS[@]}" == 0 ] ; then
- # no refs detected. This means, $HEAD is already on master (or one of the
- # stable nm-1-* branches. Just check the patch itself.
- REFS=( $HEAD )
+ REFS=( $(git log --reverse --format='%H' "${RANGES[@]}") )
+
+ if [ "${#REFS[@]}" == 0 ] ; then
+ # no refs detected. This means, $HEAD is already on master (or one of the
+ # stable nm-1-* branches. Just check the patch itself.
+ REFS=( $HEAD )
+ fi
fi
SUCCESS=0