@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+33 -10
+1 -1
src/applications/differential/conduit/ConduitAPI_differential_updaterevision_Method.php
··· 60 60 $editor->setActor($request->getUser()); 61 61 $editor->setContentSource($content_source); 62 62 $fields = $request->getValue('fields'); 63 + $editor->addDiff($diff, $request->getValue('message')); 63 64 $editor->copyFieldsFromConduit($fields); 64 65 65 - $editor->addDiff($diff, $request->getValue('message')); 66 66 $editor->save(); 67 67 68 68 return array(
+8 -9
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 34 34 35 35 $editor = new DifferentialRevisionEditor($revision); 36 36 $editor->setActor($actor); 37 + $editor->addDiff($diff, null); 37 38 $editor->copyFieldsFromConduit($fields); 38 39 39 - $editor->addDiff($diff, null); 40 40 $editor->save(); 41 41 42 42 return $revision; ··· 48 48 $revision = $this->revision; 49 49 $revision->loadRelationships(); 50 50 51 - $aux_fields = DifferentialFieldSelector::newSelector() 51 + $all_fields = DifferentialFieldSelector::newSelector() 52 52 ->getFieldSpecifications(); 53 53 54 - foreach ($aux_fields as $key => $aux_field) { 54 + $aux_fields = array(); 55 + foreach ($all_fields as $aux_field) { 55 56 $aux_field->setRevision($revision); 57 + $aux_field->setDiff($this->diff); 56 58 $aux_field->setUser($actor); 57 - if (!$aux_field->shouldAppearOnCommitMessage()) { 58 - unset($aux_fields[$key]); 59 + if ($aux_field->shouldAppearOnCommitMessage()) { 60 + $aux_fields[$aux_field->getCommitMessageKey()] = $aux_field; 59 61 } 60 62 } 61 - 62 - $aux_fields = mpull($aux_fields, null, 'getCommitMessageKey'); 63 63 64 64 foreach ($fields as $field => $value) { 65 65 if (empty($aux_fields[$field])) { ··· 73 73 $aux_field->validateField(); 74 74 } 75 75 76 - $aux_fields = array_values($aux_fields); 77 - $this->setAuxiliaryFields($aux_fields); 76 + $this->setAuxiliaryFields($all_fields); 78 77 } 79 78 80 79 public function setAuxiliaryFields(array $auxiliary_fields) {
+24
src/applications/differential/field/specification/DifferentialBranchFieldSpecification.php
··· 46 46 } 47 47 } 48 48 49 + public function didWriteRevision(DifferentialRevisionEditor $editor) { 50 + $branch = $this->getDiff()->getBranch(); 51 + $match = null; 52 + if (preg_match('/^T(\d+)/i', $branch, $match)) { // No $ to allow T123_demo. 53 + list(, $task_id) = $match; 54 + $task = id(new ManiphestTask())->load($task_id); 55 + if ($task) { 56 + id(new PhabricatorEdgeEditor()) 57 + ->setActor($this->getUser()) 58 + ->addEdge( 59 + $this->getRevision()->getPHID(), 60 + PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK, 61 + $task->getPHID()) 62 + ->save(); 63 + } 64 + } 65 + } 66 + 67 + public function getCommitMessageTips() { 68 + return array( 69 + 'Name branch "T123" to attach the diff to a task.', 70 + ); 71 + } 72 + 49 73 }