mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Fixes T6637, "closing by commit" should update task status and specify responsible commit, but drop the artificial comment.
Summary: When updating the status of a task via commit, transaction should show responsible commit and status update if it was changed. Test Plan: Push a commit "Fixes Txx", transaction should include status update and commit number. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6637 Differential Revision: https://secure.phabricator.com/D11230
This commit is contained in:
parent
ad1da6ec5e
commit
204ae221d2
2 changed files with 121 additions and 41 deletions
|
@ -114,6 +114,12 @@ final class ManiphestTransaction
|
|||
$phids[] = $phid;
|
||||
}
|
||||
break;
|
||||
case self::TYPE_STATUS:
|
||||
$commit_phid = $this->getMetadataValue('commitPHID');
|
||||
if ($commit_phid) {
|
||||
$phids[] = $commit_phid;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $phids;
|
||||
|
@ -121,6 +127,16 @@ final class ManiphestTransaction
|
|||
|
||||
public function shouldHide() {
|
||||
switch ($this->getTransactionType()) {
|
||||
case PhabricatorTransactions::TYPE_EDGE:
|
||||
$commit_phid = $this->getMetadataValue('commitPHID');
|
||||
$edge_type = $this->getMetadataValue('edge:type');
|
||||
|
||||
if ($edge_type == ManiphestTaskHasCommitEdgeType::EDGECONST) {
|
||||
if ($commit_phid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::TYPE_DESCRIPTION:
|
||||
case self::TYPE_PRIORITY:
|
||||
case self::TYPE_STATUS:
|
||||
|
@ -385,28 +401,62 @@ final class ManiphestTransaction
|
|||
$old_name = ManiphestTaskStatus::getTaskStatusName($old);
|
||||
$new_name = ManiphestTaskStatus::getTaskStatusName($new);
|
||||
|
||||
$commit_phid = $this->getMetadataValue('commitPHID');
|
||||
|
||||
if ($new_closed && !$old_closed) {
|
||||
if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s closed this task as a duplicate by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s closed this task as a duplicate.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
} else {
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s closed this task as "%s" by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$new_name,
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s closed this task as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$new_name);
|
||||
}
|
||||
}
|
||||
} else if (!$new_closed && $old_closed) {
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s closed this task as a duplicate.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
'%s reopened this task as "%s" by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$new_name,
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s closed this task as "%s".',
|
||||
'%s reopened this task as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$new_name);
|
||||
}
|
||||
} else if (!$new_closed && $old_closed) {
|
||||
return pht(
|
||||
'%s reopened this task as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$new_name);
|
||||
} else {
|
||||
return pht(
|
||||
'%s changed the task status from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s changed the task status from "%s" to "%s" by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old_name,
|
||||
$new_name,
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s changed the task status from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
}
|
||||
}
|
||||
|
||||
case self::TYPE_UNBLOCK:
|
||||
|
@ -590,32 +640,70 @@ final class ManiphestTransaction
|
|||
$old_name = ManiphestTaskStatus::getTaskStatusName($old);
|
||||
$new_name = ManiphestTaskStatus::getTaskStatusName($new);
|
||||
|
||||
$commit_phid = $this->getMetadataValue('commitPHID');
|
||||
|
||||
if ($new_closed && !$old_closed) {
|
||||
if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s closed %s as a duplicate by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s closed %s as a duplicate.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
}
|
||||
} else {
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s closed %s as "%s" by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$new_name,
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s closed %s as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$new_name);
|
||||
}
|
||||
}
|
||||
} else if (!$new_closed && $old_closed) {
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s closed %s as a duplicate.',
|
||||
'%s reopened %s as "%s" by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
$this->renderHandleLink($object_phid),
|
||||
$new_name,
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s closed %s as "%s".',
|
||||
'%s reopened %s as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$new_name);
|
||||
}
|
||||
} else if (!$new_closed && $old_closed) {
|
||||
return pht(
|
||||
'%s reopened %s as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$new_name);
|
||||
} else {
|
||||
return pht(
|
||||
'%s changed the status of %s from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
if ($commit_phid) {
|
||||
return pht(
|
||||
'%s changed the status of %s from "%s" to "%s" by committing %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$old_name,
|
||||
$new_name,
|
||||
$this->renderHandleLink($commit_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s changed the status of %s from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
}
|
||||
}
|
||||
|
||||
case self::TYPE_UNBLOCK:
|
||||
|
|
|
@ -466,7 +466,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
|||
$xactions = array();
|
||||
|
||||
$edge_type = ManiphestTaskHasCommitEdgeType::EDGECONST;
|
||||
$xactions[] = id(new ManiphestTransaction())
|
||||
$edge_xaction = id(new ManiphestTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $edge_type)
|
||||
->setNewValue(
|
||||
|
@ -481,23 +481,15 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
|||
if ($task->getStatus() != $status) {
|
||||
$xactions[] = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_STATUS)
|
||||
->setMetadataValue('commitPHID', $commit->getPHID())
|
||||
->setNewValue($status);
|
||||
|
||||
$commit_name = $repository->formatCommitName(
|
||||
$commit->getCommitIdentifier());
|
||||
|
||||
$status_message = pht(
|
||||
'Closed by commit %s.',
|
||||
$commit_name);
|
||||
|
||||
$xactions[] = id(new ManiphestTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||
->attachComment(
|
||||
id(new ManiphestTransactionComment())
|
||||
->setContent($status_message));
|
||||
$edge_xaction->setMetadataValue('commitPHID', $commit->getPHID());
|
||||
}
|
||||
}
|
||||
|
||||
$xactions[] = $edge_xaction;
|
||||
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_DAEMON,
|
||||
array());
|
||||
|
|
Loading…
Reference in a new issue