From 65de9e9f5e7f2ecc018ff300e13227d77ea342da Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 16 Mar 2017 12:22:26 -0700 Subject: [PATCH] Ignore "Auditors: author" when inferring auditors from commit messages Summary: Fixes T12406. When importing commits, we automatically add auditors if the message lists "Auditors: username". If the list of auditors includes the commit author, this edit fails because you can't audit your own commits (previously, you sometimes could and/or we didn't validate). Instead, just ignore "Auditors: author". Test Plan: - Made a commit with "Auditors: epriestley". - Pushed it. - Saw the HeraldWorker get stuck with the error in T12406. - Applied the change; worker now succeeded. Reviewers: chad Reviewed By: chad Subscribers: alexmv Maniphest Tasks: T12406 Differential Revision: https://secure.phabricator.com/D17507 --- .../audit/editor/PhabricatorAuditEditor.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php index 1c43b08905..0cf6339239 100644 --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -306,6 +306,18 @@ final class PhabricatorAuditEditor $field_key = DifferentialAuditorsCommitMessageField::FIELDKEY; $phids = idx($result, $field_key, null); + + if (!$phids) { + return array(); + } + + // If a commit lists its author as an auditor, just pretend it does not. + foreach ($phids as $key => $phid) { + if ($phid == $commit->getAuthorPHID()) { + unset($phids[$key]); + } + } + if (!$phids) { return array(); }