Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92729558
DifferentialBranchField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 23, 05:18
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Nov 25, 05:18 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22499049
Attached To
rPH Phabricator
DifferentialBranchField.php
View Options
<?php
final
class
DifferentialBranchField
extends
DifferentialCustomField
{
public
function
getFieldKey
()
{
return
'differential:branch'
;
}
public
function
getFieldName
()
{
return
pht
(
'Branch'
);
}
public
function
getFieldDescription
()
{
return
pht
(
'Shows the branch a diff came from.'
);
}
public
function
shouldAppearInPropertyView
()
{
return
true
;
}
public
function
renderPropertyViewLabel
()
{
return
$this
->
getFieldName
();
}
public
function
renderPropertyViewValue
(
array
$handles
)
{
return
$this
->
getBranchDescription
(
$this
->
getObject
()->
getActiveDiff
());
}
private
function
getBranchDescription
(
DifferentialDiff
$diff
)
{
$branch
=
$diff
->
getBranch
();
$bookmark
=
$diff
->
getBookmark
();
if
(
strlen
(
$branch
)
&&
strlen
(
$bookmark
))
{
return
pht
(
'%s (bookmark) on %s (branch)'
,
$bookmark
,
$branch
);
}
else
if
(
strlen
(
$bookmark
))
{
return
pht
(
'%s (bookmark)'
,
$bookmark
);
}
else
if
(
strlen
(
$branch
))
{
return
$branch
;
}
else
{
return
null
;
}
}
public
function
getProTips
()
{
return
array
(
pht
(
'In Git and Mercurial, use a branch like "%s" to automatically '
.
'associate changes with the corresponding task.'
,
'T123'
),
);
}
public
function
shouldAppearInTransactionMail
()
{
return
true
;
}
public
function
updateTransactionMailBody
(
PhabricatorMetaMTAMailBody
$body
,
PhabricatorApplicationTransactionEditor
$editor
,
array
$xactions
)
{
$status_accepted
=
ArcanistDifferentialRevisionStatus
::
ACCEPTED
;
// Show the "BRANCH" section only if there's a new diff or the revision
// is "Accepted".
if
((!
$editor
->
getDiffUpdateTransaction
(
$xactions
))
&&
(
$this
->
getObject
()->
getStatus
()
!=
$status_accepted
))
{
return
;
}
$branch
=
$this
->
getBranchDescription
(
$this
->
getObject
()->
getActiveDiff
());
if
(
$branch
===
null
)
{
return
;
}
$body
->
addTextSection
(
pht
(
'BRANCH'
),
$branch
);
}
}
Event Timeline
Log In to Comment