summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2015-08-11 16:07:14 -0700
committerJacob Keller <jacob.e.keller@intel.com>2015-08-11 16:07:14 -0700
commit89d31d354dde395ad4e6bbd14cc7b93b47f1ff23 (patch)
tree0474af48f942704237aec3e750d634b05618f845
parent5b6acc1c2bc7d938437dcbdd22a55720b7f68554 (diff)
downloadaiaiai-89d31d354dde395ad4e6bbd14cc7b93b47f1ff23.tar.gz
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 <jacob.e.keller@intel.com>
-rwxr-xr-xemail/aiaiai-email-autodetect-project24
1 files changed, 24 insertions, 0 deletions
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 <<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.