]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
email: skip applied patches in autodetect project
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 11 Aug 2015 23:07:14 +0000 (16:07 -0700)
committerJacob Keller <jacob.e.keller@intel.com>
Tue, 11 Aug 2015 23:07:14 +0000 (16:07 -0700)
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 <jacob.e.keller@intel.com>
email/aiaiai-email-autodetect-project

index aee5a7c74e6a683eaec404dbfb0fa7703969da3f..6e832a486115f4bec7a8dafeaae481f027abbd7c 100755 (executable)
@@ -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 <<EOF
+Aiaiai found an equivalent commit for this patch already applied to the branch base
+
+${prj} : ${branch_base} -> ${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.