Skip to content

Instantly share code, notes, and snippets.

@zevweiss
Created November 3, 2023 19:48
Show Gist options
  • Save zevweiss/63482cda0e7003a58530e4e2eabb2fb0 to your computer and use it in GitHub Desktop.
Save zevweiss/63482cda0e7003a58530e4e2eabb2fb0 to your computer and use it in GitHub Desktop.
kernel pre-submission scripts/checklist stuff
Before posting patches:
- preflight script:
- checkpatch --strict?
- dt_binding_check?
- dtbs_check?
- signed-off-by?
- get_maintainer.pl?
- subject line capitalization? (tag: subtag: Description)
- sparse? (make C=1)
- sysfs ABI documentation?
- MAINTAINERS?
- ispell?
- 'Fixes:' & 'Reported-by' tags?
- 'Reviewed-by:' tags up to date? (added, invalidated/removed)
- stable CC with version annotation? (@vger.kernel.org, not kernel.org)
- appropriate -vN flag on git format-patch for subject prefix tag?
- cover letter to all, patches CCed to specific maintainers?
- Cc:/To: lists formatted properly? (no missing/extraneous commas?)
- should be covered by sendemail-validate hook now...
openbmc (kernel & u-boot):
- subject-prefix tag on format-patch
- trim CCs when sending backports (git send-email --suppress-cc=...)
#!/bin/bash
pmake() { make -j"$(nproc)" "$@"; }
quote() { sed 's/^/> /'; }
check_commit()
{
local rev="$(git rev-parse $1)"
echo "checking commit $(git show --no-patch --format='%h: %s' "$rev")"
echo
if [ -t 1 ]; then
local colorwhen=always
else
local colorwhen=auto
fi
echo checkpatch --strict:
./scripts/checkpatch.pl --color="$colorwhen" --strict -g "$rev" |& quote
echo
# instead of arrays, use maps with entries as keys for auto-dedupe
local -A check_bindings=()
local -A check_dtstrees=()
while read path; do
if [[ "$path" == Documentation/devicetree/bindings/*/*.yaml ]]; then
check_bindings["$path"]=1
elif [[ "$path" == *.dts ]]; then
check_dtstrees["$(dirname "$path")"]=1
fi
done < <(git show --format='' --no-renames --name-only --diff-filter=AM "$rev")
if ((${#check_bindings[@]})); then
echo dt_binding_check:
{ pmake dt_binding_check DT_CHECKER_FLAGS=-m DT_SCHEMA_FILES="${!check_bindings[*]}" && echo OK; } |& quote
else
echo "[no DT binding changes found, dt_binding_check skipped]"
fi
echo
if ((${#check_dtstrees[@]})); then
for t in "${!check_dtstrees[@]}"; do
echo "dtbs_check ($t):"
{ pmake dtbs_check dtstree="$t" && echo OK; } |& quote
done
else
echo "[no dts changes found, dtbs_check skipped]"
fi
echo
echo maintainers:
git show "$rev" | ./scripts/get_maintainer.pl |& quote
echo
}
check_commit "${1:-HEAD}"
#!/usr/bin/python
# for symlinking to .git/hooks/sendemail-validate
import sys
import re
import email
with open(sys.argv[1]) as f:
msg = email.message_from_file(f)
# Uh-oh, the classic mistake...but being pretty lenient, since the
# main thing I'm aiming for here is just detecting missing or
# extraneous commas. Match on things that look like:
# - Name <email-address>
# - email-address
recipient_pat = re.compile("^([^<>@]+ <[^>]+>|[^\\s<>]+)$")
okay = True
for hdr in ["To", "Cc", "Bcc"]:
val = msg.get(hdr)
if val is None:
continue
recipients = [s.strip() for s in val.split(',')]
for r in recipients:
if not recipient_pat.match(r) or '\n' in r:
sys.stderr.write("Error: bogus-looking '%s:' recipient: '%s'\n" % (hdr, r))
okay = False
exit(int(not okay))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment