]> git.ozlabs.org Git - next-scripts/commitdiff
check_commits: check for unexpected files in commits
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 22 Apr 2019 05:29:49 +0000 (15:29 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 22 Apr 2019 05:31:10 +0000 (15:31 +1000)
so far juts for addition of .rej and .orig file

Suggested-by: Paul Gortmaker <paul.gortmaker@windriver.com>
check_commits

index d383d7759e2c632f485f3a351f2efd837d3a852f..3569e987f135dce6c8bc0885f7b720439b50f9c0 100755 (executable)
@@ -37,6 +37,28 @@ print_commits()
                "$is" "$its" "$t" "$s"
 }
 
+check_unexpected_files()
+{
+       local files
+
+       readarray files < <(git diff-tree -r --diff-filter=A --name-only --no-commit-id "$1" '*.rej' '*.orig')
+       if [ "${#files[@]}" -eq 0 ]; then
+               return
+       fi
+
+       s=
+       this='this'
+       if [ "${#files[@]}" -gt 1 ]; then
+               s='s'
+               this='these'
+       fi
+
+       printf 'Commit\n\n'
+       git log --no-walk --pretty='format:  %h ("%s")' "$1"
+       printf '\nadded %s unexpected file%s:\n\n' "$this" "$s"
+       printf '  %s\n' "${files[@]}"
+}
+
 for c in $commits; do
        ae=$(git log -1 --format='<%ae>%n<%aE>%n %an %n %aN ' "$c" | sort -u)
        ce=$(git log -1 --format='<%ce>%n<%cE>%n %cn %n %cN ' "$c" | sort -u)
@@ -49,6 +71,8 @@ for c in $commits; do
        if ! grep -i -F -q "$ce" <<<"$sob"; then
                committer_missing+=("$c")
        fi
+
+       check_unexpected_files "$c"
 done
 
 print_commits 'author' "${author_missing[@]}"