From 89d31d354dde395ad4e6bbd14cc7b93b47f1ff23 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Tue, 11 Aug 2015 16:07:14 -0700 Subject: [PATCH] email: skip applied patches in autodetect project Update the project autodetection hook to use git-patch-id to search for patches which have already been applied. This helps ensure that patches which have already been applied to the "branch_base" are skipped with a different warning message. Otherwise, git-find-base will not work for these patches, and they will be sent a more confusing message. Signed-off-by: Jacob Keller --- email/aiaiai-email-autodetect-project | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/email/aiaiai-email-autodetect-project b/email/aiaiai-email-autodetect-project index aee5a7c..6e832a4 100755 --- a/email/aiaiai-email-autodetect-project +++ b/email/aiaiai-email-autodetect-project @@ -77,6 +77,9 @@ cc="$(fetch_header "Cc" < "$mbox")" list="$(merge_addresses "$to" "$cc")" expected_prj="$(fetch_project_name "$list" "cfg_ownmail")" +# Get the patch-id for this mbox +patchid="$(git patch-id --stable < "$mbox" | awk '{print $1}')" + # Loop through every project and check if we can find a base commit. If we're # given an expected project in the email address, try it first, so that we # don't accidentally land on the wrong one. @@ -96,6 +99,27 @@ for prj in $expected_prj $(get_cfgfile_projects_list "$cfgfile"); do # We set our own project variable called branch_base branch_base="$(ini_config_get "$cfgfile" "prj_$prj" "branch_base")" + # use git-patch-id to check if the patch has already been applied the + # branch_base and reject the patch in this case. + for rev in $(git --git-dir="$(git_dir "$pcfg_path")" "$branch_base"); do + revid="$(git --git-dir="$(git_dir "$pcfg_path")" show $rev | git patch-id --stable | awk '{print $1}')" + shortname="$(git --git-dir="$(git_dir "$pcfg_path")" log -1 --pretty="%h (\"%s\")" $rev)" + + # if we find a patch-id equivalent commit, exit and skip the patch with a warning to the user. + if [ "$patchid" = "$revid" ]; then + cat < ${shortname} + +It is likely that the maintainer applied your patch before Aiaiai got around to +testing it. No further testing will be performed for your patch, as Aiaiai +would not be able to apply it cleanly. +EOF + exit 127 + fi + done + # Use git-find-base with the mbox file as input, and check to see if we # can find a commit in this project. Use the branch_base if it's # supplied, otherwise use the parent(s) of pcfg_branch as the limiter. -- 2.49.0