1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Reference task based on branch name in arc diff

Summary:
This was mentioned in T2928 and nobody objected.
It just references the task instead of fixing it as that would be too aggressive.
It also doesn't check assignee of the task (by purpose).

Test Plan: Created diff from a branch named T2928.

Reviewers: epriestley, edward

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2928

Differential Revision: https://secure.phabricator.com/D5640
This commit is contained in:
Jakub Vrana 2013-05-30 17:33:17 -07:00
parent bccc1e1244
commit 2427d317b2
3 changed files with 33 additions and 10 deletions

View file

@ -60,9 +60,9 @@ final class ConduitAPI_differential_updaterevision_Method
$editor->setActor($request->getUser());
$editor->setContentSource($content_source);
$fields = $request->getValue('fields');
$editor->addDiff($diff, $request->getValue('message'));
$editor->copyFieldsFromConduit($fields);
$editor->addDiff($diff, $request->getValue('message'));
$editor->save();
return array(

View file

@ -34,9 +34,9 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$editor = new DifferentialRevisionEditor($revision);
$editor->setActor($actor);
$editor->addDiff($diff, null);
$editor->copyFieldsFromConduit($fields);
$editor->addDiff($diff, null);
$editor->save();
return $revision;
@ -48,19 +48,19 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$revision = $this->revision;
$revision->loadRelationships();
$aux_fields = DifferentialFieldSelector::newSelector()
$all_fields = DifferentialFieldSelector::newSelector()
->getFieldSpecifications();
foreach ($aux_fields as $key => $aux_field) {
$aux_fields = array();
foreach ($all_fields as $aux_field) {
$aux_field->setRevision($revision);
$aux_field->setDiff($this->diff);
$aux_field->setUser($actor);
if (!$aux_field->shouldAppearOnCommitMessage()) {
unset($aux_fields[$key]);
if ($aux_field->shouldAppearOnCommitMessage()) {
$aux_fields[$aux_field->getCommitMessageKey()] = $aux_field;
}
}
$aux_fields = mpull($aux_fields, null, 'getCommitMessageKey');
foreach ($fields as $field => $value) {
if (empty($aux_fields[$field])) {
throw new Exception(
@ -73,8 +73,7 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$aux_field->validateField();
}
$aux_fields = array_values($aux_fields);
$this->setAuxiliaryFields($aux_fields);
$this->setAuxiliaryFields($all_fields);
}
public function setAuxiliaryFields(array $auxiliary_fields) {

View file

@ -46,4 +46,28 @@ final class DifferentialBranchFieldSpecification
}
}
public function didWriteRevision(DifferentialRevisionEditor $editor) {
$branch = $this->getDiff()->getBranch();
$match = null;
if (preg_match('/^T(\d+)/i', $branch, $match)) { // No $ to allow T123_demo.
list(, $task_id) = $match;
$task = id(new ManiphestTask())->load($task_id);
if ($task) {
id(new PhabricatorEdgeEditor())
->setActor($this->getUser())
->addEdge(
$this->getRevision()->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK,
$task->getPHID())
->save();
}
}
}
public function getCommitMessageTips() {
return array(
'Name branch "T123" to attach the diff to a task.',
);
}
}