Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2889496
DifferentialRevisionCloseDetailsController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
DifferentialRevisionCloseDetailsController.php
View Options
<?php
final
class
DifferentialRevisionCloseDetailsController
extends
DifferentialController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
(
)
;
$xaction
=
id
(
new
PhabricatorObjectQuery
(
)
)
->
withPHIDs
(
array
(
$request
->
getURIData
(
'phid'
)
)
)
->
setViewer
(
$viewer
)
->
executeOne
(
)
;
if
(
!
$xaction
)
{
return
new
Aphront404Response
(
)
;
}
$obj_phid
=
$xaction
->
getObjectPHID
(
)
;
$obj_handle
=
id
(
new
PhabricatorHandleQuery
(
)
)
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$obj_phid
)
)
->
executeOne
(
)
;
$body
=
$this
->
getRevisionMatchExplanation
(
$xaction
->
getMetadataValue
(
'revisionMatchData'
)
,
$obj_handle
)
;
$dialog
=
id
(
new
AphrontDialogView
(
)
)
->
setUser
(
$viewer
)
->
setTitle
(
pht
(
'Commit Close Explanation'
)
)
->
appendParagraph
(
$body
)
->
addCancelButton
(
$obj_handle
->
getURI
(
)
)
;
return
id
(
new
AphrontDialogResponse
(
)
)
->
setDialog
(
$dialog
)
;
}
private
function
getRevisionMatchExplanation
(
$revision_match_data
,
PhabricatorObjectHandle
$obj_handle
)
{
if
(
!
$revision_match_data
)
{
return
pht
(
'This commit was made before this feature was built and thus this '
.
'information is unavailable.'
)
;
}
$body_why
=
array
(
)
;
if
(
$revision_match_data
[
'usedURI'
]
)
{
return
pht
(
'We found a "%s" field with value "%s" in the commit message, '
.
'and the domain on the URI matches this install, so '
.
'we linked this commit to %s.'
,
'Differential Revision'
,
$revision_match_data
[
'foundURI'
]
,
phutil_tag
(
'a'
,
array
(
'href'
=>
$obj_handle
->
getURI
(
)
,
)
,
$obj_handle
->
getName
(
)
)
)
;
}
else
if
(
$revision_match_data
[
'foundURI'
]
)
{
$body_why
[
]
=
pht
(
'We found a "%s" field with value "%s" in the commit message, '
.
'but the domain on this URI did not match the configured '
.
'domain for this install, "%s", so we ignored it under '
.
'the assumption that it refers to some third-party revision.'
,
'Differential Revision'
,
$revision_match_data
[
'foundURI'
]
,
$revision_match_data
[
'validDomain'
]
)
;
}
else
{
$body_why
[
]
=
pht
(
'We didn\'t find a "%s" field in the commit message.'
,
'Differential Revision'
)
;
}
switch
(
$revision_match_data
[
'matchHashType'
]
)
{
case
ArcanistDifferentialRevisionHash
::
HASH_GIT_TREE
:
$hash_info
=
true
;
$hash_type
=
'tree'
;
break
;
case
ArcanistDifferentialRevisionHash
::
HASH_GIT_COMMIT
:
case
ArcanistDifferentialRevisionHash
::
HASH_MERCURIAL_COMMIT
:
$hash_info
=
true
;
$hash_type
=
'commit'
;
break
;
default
:
$hash_info
=
false
;
break
;
}
if
(
$hash_info
)
{
$diff_link
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$obj_handle
->
getURI
(
)
,
)
,
$obj_handle
->
getName
(
)
)
;
$body_why
[
]
=
pht
(
'This commit and the active diff of %s had the same %s hash '
.
'(%s) so we linked this commit to %s.'
,
$diff_link
,
$hash_type
,
$revision_match_data
[
'matchHashValue'
]
,
$diff_link
)
;
}
return
phutil_implode_html
(
"\n"
,
$body_why
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 12:14 (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1124451
Default Alt Text
DifferentialRevisionCloseDetailsController.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment