From 2ef3e69e583bf632c48d28224b17e5be57913e4f Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 23 Mar 2012 11:08:18 -0700 Subject: [PATCH] Improve Herald commit emails Summary: - Show the canonical (i.e., shorter) commit identifier in the subject. - For commits without a revision, put the commit summary in the subject. Test Plan: Ran "scripts/repository/reparse.php --herald" for a number of different commits (with revision, without revision); got more useful email subjects. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T1028 Differential Revision: https://secure.phabricator.com/D2004 --- ...habricatorRepositoryCommitHeraldWorker.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php index 0ecbb7f3bc..ebf2bf86b0 100644 --- a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php @@ -64,23 +64,27 @@ final class PhabricatorRepositoryCommitHeraldWorker $xscript = $engine->getTranscript(); - $commit_name = $adapter->getHeraldName(); $revision = $adapter->loadDifferentialRevision(); - - $name = null; if ($revision) { - $name = ' '.$revision->getTitle(); + $name = $revision->getTitle(); + } else { + $name = $data->getSummary(); } $author_phid = $data->getCommitDetail('authorPHID'); $reviewer_phid = $data->getCommitDetail('reviewerPHID'); - $phids = array_filter(array($author_phid, $reviewer_phid)); + $phids = array_filter( + array( + $author_phid, + $reviewer_phid, + $commit->getPHID(), + )); - $handles = array(); - if ($phids) { - $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); - } + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + + $commit_handle = $handles[$commit->getPHID()]; + $commit_name = $commit_handle->getName(); if ($author_phid) { $author_name = $handles[$author_phid]->getName(); @@ -98,7 +102,7 @@ final class PhabricatorRepositoryCommitHeraldWorker $description = $data->getCommitMessage(); - $details = PhabricatorEnv::getProductionURI('/'.$commit_name); + $commit_uri = PhabricatorEnv::getProductionURI($commit_handle->getURI()); $differential = $revision ? PhabricatorEnv::getProductionURI('/D'.$revision->getID()) : 'No revision.'; @@ -130,7 +134,7 @@ DESCRIPTION {$description} DETAILS - {$details} + {$commit_uri} DIFFERENTIAL REVISION {$differential} @@ -146,7 +150,7 @@ WHY DID I GET THIS EMAIL? EOBODY; - $subject = "[Herald/Commit] {$commit_name} ({$who}){$name}"; + $subject = "[Herald/Commit] {$commit_name} ({$who}) {$name}"; $threading = PhabricatorAuditCommentEditor::getMailThreading( $commit->getPHID());