1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Adding pro tips to Differential commit message

Summary: Randomly displaying tips about different features of arc.

Test Plan: Will test by running arc diff and seeing if the tips appear in text-based UI of arc

Reviewers: epriestley, AnhNhan

Reviewed By: AnhNhan

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5351
This commit is contained in:
Afaque Hussain 2013-03-19 09:29:24 -07:00 committed by epriestley
parent 23ec113ac8
commit d43bcdc1ee
4 changed files with 41 additions and 0 deletions

View file

@ -48,9 +48,12 @@ final class ConduitAPI_differential_getcommitmessage_Method
$aux_fields = DifferentialFieldSelector::newSelector()
->getFieldSpecifications();
$pro_tips = array();
foreach ($aux_fields as $key => $aux_field) {
$aux_field->setUser($request->getUser());
$aux_field->setRevision($revision);
$pro_tips[] = $aux_field->getCommitMessageTips();
if (!$aux_field->shouldAppearOnCommitMessage()) {
unset($aux_fields[$key]);
}
@ -125,6 +128,26 @@ final class ConduitAPI_differential_getcommitmessage_Method
}
}
}
if ($is_edit) {
$pro_tips = array_mergev($pro_tips);
if (!empty($pro_tips)) {
shuffle($pro_tips);
$pro_tip = "Tip: ".$pro_tips[0];
$pro_tip = wordwrap($pro_tip, 78, "\n", true);
$lines = explode("\n", $pro_tip);
foreach ($lines as $key => $line) {
$lines[$key] = "# ".$line;
}
$pro_tip = implode("\n", $lines);
$commit_message[] = $pro_tip;
}
}
$commit_message = implode("\n\n", $commit_message);
return $commit_message;

View file

@ -47,4 +47,11 @@ final class DifferentialDependsOnFieldSpecification
return 'phabricator:depends-on';
}
public function getCommitMessageTips() {
return array(
'Use "Depends on D123" in your summary to mark '.
'a dependency between revisions.'
);
}
}

View file

@ -667,6 +667,10 @@ abstract class DifferentialFieldSpecification {
return;
}
public function getCommitMessageTips() {
return array();
}
/* -( Loading Additional Data )-------------------------------------------- */

View file

@ -173,4 +173,11 @@ final class DifferentialManiphestTasksFieldSpecification
return implode("\n", $body);
}
public function getCommitMessageTips() {
return array(
'Use "Fixes T123" in your summary to mark that the current '.
'revision completes a given task.'
);
}
}