Skip to content

Commit d43bcdc

Browse files
afaquejamepriestley
authored and
epriestley
committedMar 19, 2013
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
1 parent 23ec113 commit d43bcdc

4 files changed

+41
-0
lines changed
 

‎src/applications/differential/conduit/ConduitAPI_differential_getcommitmessage_Method.php

+23
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ protected function execute(ConduitAPIRequest $request) {
4848
$aux_fields = DifferentialFieldSelector::newSelector()
4949
->getFieldSpecifications();
5050

51+
$pro_tips = array();
52+
5153
foreach ($aux_fields as $key => $aux_field) {
5254
$aux_field->setUser($request->getUser());
5355
$aux_field->setRevision($revision);
56+
$pro_tips[] = $aux_field->getCommitMessageTips();
5457
if (!$aux_field->shouldAppearOnCommitMessage()) {
5558
unset($aux_fields[$key]);
5659
}
@@ -125,6 +128,26 @@ protected function execute(ConduitAPIRequest $request) {
125128
}
126129
}
127130
}
131+
132+
if ($is_edit) {
133+
$pro_tips = array_mergev($pro_tips);
134+
135+
if (!empty($pro_tips)) {
136+
shuffle($pro_tips);
137+
$pro_tip = "Tip: ".$pro_tips[0];
138+
$pro_tip = wordwrap($pro_tip, 78, "\n", true);
139+
140+
$lines = explode("\n", $pro_tip);
141+
142+
foreach ($lines as $key => $line) {
143+
$lines[$key] = "# ".$line;
144+
}
145+
146+
$pro_tip = implode("\n", $lines);
147+
$commit_message[] = $pro_tip;
148+
}
149+
}
150+
128151
$commit_message = implode("\n\n", $commit_message);
129152

130153
return $commit_message;

‎src/applications/differential/field/specification/DifferentialDependsOnFieldSpecification.php

+7
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@ public function getKeyForConduit() {
4747
return 'phabricator:depends-on';
4848
}
4949

50+
public function getCommitMessageTips() {
51+
return array(
52+
'Use "Depends on D123" in your summary to mark '.
53+
'a dependency between revisions.'
54+
);
55+
}
56+
5057
}

‎src/applications/differential/field/specification/DifferentialFieldSpecification.php

+4
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ public function didParseCommit(
667667
return;
668668
}
669669

670+
public function getCommitMessageTips() {
671+
return array();
672+
}
673+
670674

671675
/* -( Loading Additional Data )-------------------------------------------- */
672676

‎src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php

+7
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,11 @@ public function renderValueForMail($phase) {
173173
return implode("\n", $body);
174174
}
175175

176+
public function getCommitMessageTips() {
177+
return array(
178+
'Use "Fixes T123" in your summary to mark that the current '.
179+
'revision completes a given task.'
180+
);
181+
}
182+
176183
}

0 commit comments

Comments
 (0)
Failed to load comments.