Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100769898
DifferentialRevisionIDField.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, Feb 2, 14:54
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Feb 4, 14:54 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24028530
Attached To
rPH Phabricator
DifferentialRevisionIDField.php
View Options
<?php
final
class
DifferentialRevisionIDField
extends
DifferentialCustomField
{
public
function
getFieldKey
()
{
return
'differential:revision-id'
;
}
public
function
getFieldKeyForConduit
()
{
return
'revisionID'
;
}
public
function
getFieldName
()
{
return
pht
(
'Differential Revision'
);
}
public
function
getFieldDescription
()
{
return
pht
(
'Ties commits to revisions and provides a permananent link between '
.
'them.'
);
}
public
function
canDisableField
()
{
return
false
;
}
public
function
shouldAppearInCommitMessage
()
{
return
true
;
}
public
function
shouldAllowEditInCommitMessage
()
{
return
false
;
}
public
function
parseValueFromCommitMessage
(
$value
)
{
return
self
::
parseRevisionIDFromURI
(
$value
);
}
public
function
renderCommitMessageValue
(
array
$handles
)
{
return
PhabricatorEnv
::
getProductionURI
(
'/D'
.
$this
->
getObject
()->
getID
());
}
private
static
function
parseRevisionIDFromURI
(
$uri
)
{
$path
=
id
(
new
PhutilURI
(
$uri
))->
getPath
();
$matches
=
null
;
if
(
preg_match
(
'#^/D(
\d
+)$#'
,
$path
,
$matches
))
{
$id
=
(
int
)
$matches
[
1
];
// Make sure the URI is the same as our URI. Basically, we want to ignore
// commits from other Phabricator installs.
if
(
$uri
==
PhabricatorEnv
::
getProductionURI
(
'/D'
.
$id
))
{
return
$id
;
}
$allowed_uris
=
PhabricatorEnv
::
getAllowedURIs
(
'/D'
.
$id
);
foreach
(
$allowed_uris
as
$allowed_uri
)
{
if
(
$uri
==
$allowed_uri
)
{
return
$id
;
}
}
}
return
null
;
}
}
Event Timeline
Log In to Comment