Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F66204140
DifferentialBranchFieldSpecification.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
Sun, Jun 9, 00:01
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Jun 11, 00:01 (2 d)
Engine
blob
Format
Raw Data
Handle
18185831
Attached To
rPH Phabricator
DifferentialBranchFieldSpecification.php
View Options
<?php
final
class
DifferentialBranchFieldSpecification
extends
DifferentialFieldSpecification
{
public
function
shouldAppearOnRevisionView
()
{
return
true
;
}
public
function
renderLabelForRevisionView
()
{
return
'Branch:'
;
}
public
function
renderValueForRevisionView
()
{
$diff
=
$this
->
getManualDiff
();
$branch
=
$diff
->
getBranch
();
$bookmark
=
$diff
->
getBookmark
();
$has_branch
=
(
$branch
!=
''
);
$has_bookmark
=
(
$bookmark
!=
''
);
if
(
$has_branch
&&
$has_bookmark
)
{
$branch
=
"{$bookmark} bookmark on {$branch} branch"
;
}
else
if
(
$has_bookmark
)
{
$branch
=
"{$bookmark} bookmark"
;
}
else
if
(!
$has_branch
)
{
return
null
;
}
return
$branch
;
}
public
function
renderValueForMail
(
$phase
)
{
$status
=
$this
->
getRevision
()->
getStatus
();
if
(
$status
!=
ArcanistDifferentialRevisionStatus
::
NEEDS_REVISION
&&
$status
!=
ArcanistDifferentialRevisionStatus
::
ACCEPTED
)
{
return
null
;
}
$diff
=
$this
->
getRevision
()->
loadActiveDiff
();
if
(
$diff
)
{
$branch
=
$diff
->
getBranch
();
if
(
$branch
)
{
return
"BRANCH
\n
$branch"
;
}
}
}
public
function
didWriteRevision
(
DifferentialRevisionEditor
$editor
)
{
$maniphest
=
'PhabricatorApplicationManiphest'
;
if
(!
PhabricatorApplication
::
isClassInstalled
(
$maniphest
))
{
return
;
}
$branch
=
$this
->
getDiff
()->
getBranch
();
$match
=
null
;
if
(
preg_match
(
'/^T(
\d
+)/i'
,
$branch
,
$match
))
{
// No $ to allow T123_demo.
list
(,
$task_id
)
=
$match
;
$task
=
id
(
new
ManiphestTaskQuery
())
->
setViewer
(
$editor
->
requireActor
())
->
withIDs
(
array
(
$task_id
))
->
executeOne
();
if
(
$task
)
{
id
(
new
PhabricatorEdgeEditor
())
->
setActor
(
$this
->
getUser
())
->
addEdge
(
$this
->
getRevision
()->
getPHID
(),
PhabricatorEdgeConfig
::
TYPE_DREV_HAS_RELATED_TASK
,
$task
->
getPHID
())
->
save
();
}
}
}
public
function
getCommitMessageTips
()
{
return
array
(
'Name branch "T123" to attach the diff to a task.'
,
);
}
}
Event Timeline
Log In to Comment