1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

Provide more informative messages when autoclosing revisions

Summary: This has been a point of some confusion, make the messages more explicit.

Test Plan:
Added var_dump() stuff and ran on some commits:

  $ ./scripts/repository/reparse.php --message rP9fc54f4dfb61f7338cb1cfe819bc72d2a3404264
  Running 'PhabricatorRepositoryGitCommitMessageParserWorker'...
  string(58) "Closed by commit rP9fc54f4dfb61 (authored by @epriestley)."
  $ ./scripts/repository/reparse.php --message rP444c634b6c6612fc7b36ddffab8023ef67372ab9
  Running 'PhabricatorRepositoryGitCommitMessageParserWorker'...
  string(83) "Closed by commit rP444c634b6c66 (authored by Ben Rogers, committed by @epriestley)."
  $ ./scripts/repository/reparse.php --message rP22d12fe499e3ecb62392397f2ac2a91768c974aa
  Running 'PhabricatorRepositoryGitCommitMessageParserWorker'...
  string(52) "Closed by commit rP22d12fe499e3 (authored by vrana)."
  $ ./scripts/repository/reparse.php --message rPe51958159483cd0acf00adcff51edf8717b4a23b
  Running 'PhabricatorRepositoryGitCommitMessageParserWorker'...
  string(85) "Closed by commit rPe51958159483 (authored by David Fisher, committed by @epriestley)."

Reviewers: csilvers, vrana

Reviewed By: csilvers

CC: aran

Differential Revision: https://secure.phabricator.com/D2765
This commit is contained in:
epriestley 2012-06-15 17:00:08 -07:00
parent 2f85be0243
commit 14648d6d7a
2 changed files with 45 additions and 27 deletions

View file

@ -97,47 +97,64 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
$commit->getPHID());
$commit_is_new = $conn_w->getAffectedRows();
$message = null;
$name = $data->getCommitDetail('committer');
if ($name !== null) {
$committer = $data->getCommitDetail('committerPHID');
$committer_phid = $data->getCommitDetail('committerPHID');
if ($committer_phid) {
$handle = PhabricatorObjectHandleData::loadOneHandle($committer_phid);
$committer_name = '@'.$handle->getName();
} else {
$committer = $data->getCommitDetail('authorPHID');
$name = $data->getAuthorName();
}
if (!$committer) {
$committer = $revision->getAuthorPHID();
$message = 'Closed by '.$name.'.';
$committer_name = $data->getCommitDetail('committer');
}
if ($commit_is_new) {
$diff = $this->attachToRevision($revision, $committer);
$author_phid = $data->getCommitDetail('authorPHID');
if ($author_phid) {
$handle = PhabricatorObjectHandleData::loadOneHandle($author_phid);
$author_name = '@'.$handle->getName();
} else {
$author_name = $data->getAuthorName();
}
$commit_name = $repository->formatCommitName(
$commit->getCommitIdentifier());
$info = array();
$info[] = "authored by {$author_name}";
if ($committer_name && ($committer_name != $author_name)) {
$info[] = "committed by {$committer_name}";
}
$info = implode(', ', $info);
$message = "Closed by commit {$commit_name} ({$info}).";
$actor_phid = nonempty(
$committer_phid,
$author_phid,
$revision->getAuthorPHID());
$status_closed = ArcanistDifferentialRevisionStatus::CLOSED;
$should_close = ($revision->getStatus() != $status_closed) &&
$should_close = $commit_is_new &&
($revision->getStatus() != $status_closed) &&
$repository->shouldAutocloseCommit($commit, $data);
if ($should_close) {
$diff = $this->attachToRevision($revision, $actor_phid);
$revision->setDateCommitted($commit->getEpoch());
$editor = new DifferentialCommentEditor(
$revision,
$committer,
$actor_phid,
DifferentialAction::ACTION_CLOSE);
$editor->setIsDaemonWorkflow(true);
if ($commit_is_new) {
$vs_diff = $this->loadChangedByCommit($diff);
if ($vs_diff) {
$data->setCommitDetail('vsDiff', $vs_diff->getID());
$vs_diff = $this->loadChangedByCommit($diff);
if ($vs_diff) {
$data->setCommitDetail('vsDiff', $vs_diff->getID());
$changed_by_commit = PhabricatorEnv::getProductionURI(
'/D'.$revision->getID().
'?vs='.$vs_diff->getID().
'&id='.$diff->getID().
'#differential-review-toc');
$editor->setChangedByCommit($changed_by_commit);
}
$changed_by_commit = PhabricatorEnv::getProductionURI(
'/D'.$revision->getID().
'?vs='.$vs_diff->getID().
'&id='.$diff->getID().
'#differential-review-toc');
$editor->setChangedByCommit($changed_by_commit);
}
$editor->setMessage($message)->save();
@ -151,7 +168,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
private function attachToRevision(
DifferentialRevision $revision,
$committer) {
$actor_phid) {
$drequest = DiffusionRequest::newFromDictionary(array(
'repository' => $this->repository,
@ -164,7 +181,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
$changes = id(new ArcanistDiffParser())->parseDiff($raw_diff);
$diff = DifferentialDiff::newFromRawChanges($changes)
->setRevisionID($revision->getID())
->setAuthorPHID($committer)
->setAuthorPHID($actor_phid)
->setCreationMethod('commit')
->setSourceControlSystem($this->repository->getVersionControlSystem())
->setLintStatus(DifferentialLintStatus::LINT_SKIP)

View file

@ -386,6 +386,7 @@ final class PhabricatorStandardPageView extends AphrontPageView {
$notification_container = '';
if (PhabricatorEnv::getEnvConfig('notification.enabled') &&
$user &&
$user->isLoggedIn()) {
$aphlict_object_id = 'aphlictswfobject';