Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/field/DifferentialTitleCommitMessageField.php
12256 views
1
<?php
2
3
final class DifferentialTitleCommitMessageField
4
extends DifferentialCommitMessageField {
5
6
const FIELDKEY = 'title';
7
8
public function getFieldName() {
9
return pht('Title');
10
}
11
12
public function getFieldOrder() {
13
return 1000;
14
}
15
16
public static function getDefaultTitle() {
17
return pht('<<Replace this line with your revision title>');
18
}
19
20
public function parseFieldValue($value) {
21
if ($value === self::getDefaultTitle()) {
22
$this->raiseParseException(
23
pht(
24
'Replace the default title line with a human-readable revision '.
25
'title which describes the changes you are making.'));
26
}
27
28
return parent::parseFieldValue($value);
29
}
30
31
public function validateFieldValue($value) {
32
if (!strlen($value)) {
33
$this->raiseValidationException(
34
pht(
35
'You must provide a revision title in the first line '.
36
'of your commit message.'));
37
}
38
}
39
40
public function readFieldValueFromObject(DifferentialRevision $revision) {
41
$value = $revision->getTitle();
42
43
if (!strlen($value)) {
44
return self::getDefaultTitle();
45
}
46
47
return $value;
48
}
49
50
public function getFieldTransactions($value) {
51
return array(
52
array(
53
'type' => DifferentialRevisionTitleTransaction::EDITKEY,
54
'value' => $value,
55
),
56
);
57
}
58
59
}
60
61