From: Stephen Rothwell Date: Mon, 22 Apr 2019 05:29:49 +0000 (+1000) Subject: check_commits: check for unexpected files in commits X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=bda84fe3da678b465a2f0c17dcce1579f981b6c2;p=next-scripts check_commits: check for unexpected files in commits so far juts for addition of .rej and .orig file Suggested-by: Paul Gortmaker --- diff --git a/check_commits b/check_commits index d383d77..3569e98 100755 --- a/check_commits +++ b/check_commits @@ -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[@]}"