1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- validate_cover_letter () {
- file="$1"
- # TODO: Replace with appropriate checks (e.g. spell checking).
- true
- }
- validate_patch () {
- file="$1"
- # Ensure that the patch applies without conflicts.
- git am -3 "$file" || return
- # TODO: Replace with appropriate checks for this patch
- # (e.g. checkpatch.pl).
- true
- }
- validate_series () {
- # TODO: Replace with appropriate checks for the whole series
- # (e.g. quick build, coding style checks, etc.).
- true
- }
- if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
- then
- remote=$(git config --default origin --get sendemail.validateRemote) &&
- ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
- worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
- git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
- git config --replace-all sendemail.validateWorktree "$worktree"
- else
- worktree=$(git config --get sendemail.validateWorktree)
- fi || {
- echo "sendemail-validate: error: failed to prepare worktree" >&2
- exit 1
- }
- unset GIT_DIR GIT_WORK_TREE
- cd "$worktree" &&
- if grep -q "^diff --git " "$1"
- then
- validate_patch "$1"
- else
- validate_cover_letter "$1"
- fi &&
- if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
- then
- git config --unset-all sendemail.validateWorktree &&
- trap 'git worktree remove -ff "$worktree"' EXIT &&
- validate_series
- fi
|