From cebbca9e08e4072d16503cc345f991d2d39ddc7d Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 14 Aug 2014 12:14:02 -0700 Subject: [PATCH] Add a "USERS" section to audit emails listing commit authors and committers Summary: Fixes T5872. This won't show up in the initial email until T4896 is further along. Test Plan: ``` RECIPIENTS discoball (Disco Ball) BODY epriestley added a comment. ffkn USERS epriestley (Author) COMMIT http://local.aphront.com:8080/rPOEMS165b6c54f487 ``` Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5872 Differential Revision: https://secure.phabricator.com/D10266 --- .../audit/editor/PhabricatorAuditEditor.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php index 7d45d4e01e..7b66ddc843 100644 --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -428,6 +428,49 @@ final class PhabricatorAuditEditor $this->renderInlineCommentsForMail($object, $inlines)); } + // Reload the commit to pull commit data. + $commit = id(new DiffusionCommitQuery()) + ->setViewer($this->requireActor()) + ->withIDs(array($object->getID())) + ->needCommitData(true) + ->executeOne(); + $data = $commit->getCommitData(); + + $user_phids = array(); + + $author_phid = $commit->getAuthorPHID(); + if ($author_phid) { + $user_phids[$commit->getAuthorPHID()][] = pht('Author'); + } + + $committer_phid = $data->getCommitDetail('committerPHID'); + if ($committer_phid && ($committer_phid != $author_phid)) { + $user_phids[$committer_phid][] = pht('Committer'); + } + + // TODO: It would be nice to show pusher here too, but that information + // is a little tricky to get at right now. + + if ($user_phids) { + $handle_phids = array_keys($user_phids); + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->requireActor()) + ->withPHIDs($handle_phids) + ->execute(); + + $user_info = array(); + foreach ($user_phids as $phid => $roles) { + $user_info[] = pht( + '%s (%s)', + $handles[$phid]->getName(), + implode(', ', $roles)); + } + + $body->addTextSection( + pht('USERS'), + implode("\n", $user_info)); + } + $monogram = $object->getRepository()->formatCommitName( $object->getCommitIdentifier());