[PATCH 1/2] dim: basic Fixes: check
Daniel Vetter
daniel.vetter at ffwll.ch
Tue Feb 12 09:46:34 UTC 2019
Somewhat inspired by Stephen Rotwell's code, but because random
unfriendly encounters with bash it ended up looking quite a bit
different. Also only really checks sha1 for now, but that should be
good enough.
v2: Actually forward the error code from the subshell (which was
automatically created because of the pipeline, now I made it
explicit). Spotted by shellcheck, somehow I didn't notice that my
checks didn't actually abort the pull in my testing.
Cc: Dave Airlie <airlied at linux.ie>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
dim | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/dim b/dim
index 8e1bfa968e4a..9592851cdca8 100755
--- a/dim
+++ b/dim
@@ -795,6 +795,52 @@ function dim_rebuild_tip
commit_rerere_cache
}
+function checkpatch_fixes_tag
+{
+ local sha1 fixes_lines cite rv fline
+
+ sha1=$1
+ rv=0
+ fixes_lines=$(git log -1 --format='%B' "$sha1" | grep -i '^[[:space:]]*Fixes:')
+ cite=$(dim_cite $sha1)
+
+ echo "$fixes_lines" | ( local rv; rv=0 ; while read -r fline; do
+ local fixes_sha1 fixes_subject
+ if [[ -z "$fline" ]] ; then
+ continue
+ fi
+
+ [[ "$fline" =~ ^[[:space:]]*[Ff][Ii][Xx][Ee][Ss]:[[:space:]]*(.*)$ ]]
+ fline="${BASH_REMATCH[1]}"
+
+ if [[ ! "$fline" =~ ^[[:space:]]*([[:xdigit:]]{5,})[[:space:]]*(.*)$ ]]; then
+ echoerr "$cite: Malformed fixes line:"
+ echoerr " $fline"
+ rv=1
+ continue
+ fi
+ fixes_sha1="${BASH_REMATCH[1]}"
+ fixes_subject="${BASH_REMATCH[2]}"
+
+ if ! git rev-parse --verify -q $fixes_sha1 ; then
+ echoerr "$cite: SHA1 in fixes line not found:"
+ echoerr " $fline"
+ rv=1
+ continue
+ fi
+ if ! git merge-base --is-ancestor $fixes_sha1 $sha1 ; then
+ echoerr "$cite: Fixes: SHA1 in not pointing at an ancestor:"
+ echoerr " $fline"
+ rv=1
+ continue
+ fi
+ done ; exit $rv )
+
+ rv=$?
+
+ return $rv
+}
+
# additional patch checks before pushing, e.g. for r-b tags
function checkpatch_commit_push
{
@@ -837,6 +883,10 @@ function checkpatch_commit_push
rv=1
fi
+ if ! checkpatch_fixes_tag $sha1 ; then
+ rv=1
+ fi
+
return $rv
}
--
2.20.1
More information about the dim-tools
mailing list