mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Remove "Revision ID" custom field
Summary: Ref T11114. Obsoleted by `DifferentialRevisionIDCommitMessageField`. Test Plan: - Grepped for removed class. - Created a new revision, verified that the amended message included a proper revision ID. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114 Differential Revision: https://secure.phabricator.com/D17080
This commit is contained in:
parent
77601bf58c
commit
3893b5f1a5
4 changed files with 1 additions and 92 deletions
|
@ -532,7 +532,6 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionHeraldField' => 'applications/differential/herald/DifferentialRevisionHeraldField.php',
|
'DifferentialRevisionHeraldField' => 'applications/differential/herald/DifferentialRevisionHeraldField.php',
|
||||||
'DifferentialRevisionHeraldFieldGroup' => 'applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php',
|
'DifferentialRevisionHeraldFieldGroup' => 'applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php',
|
||||||
'DifferentialRevisionIDCommitMessageField' => 'applications/differential/field/DifferentialRevisionIDCommitMessageField.php',
|
'DifferentialRevisionIDCommitMessageField' => 'applications/differential/field/DifferentialRevisionIDCommitMessageField.php',
|
||||||
'DifferentialRevisionIDField' => 'applications/differential/customfield/DifferentialRevisionIDField.php',
|
|
||||||
'DifferentialRevisionLandController' => 'applications/differential/controller/DifferentialRevisionLandController.php',
|
'DifferentialRevisionLandController' => 'applications/differential/controller/DifferentialRevisionLandController.php',
|
||||||
'DifferentialRevisionListController' => 'applications/differential/controller/DifferentialRevisionListController.php',
|
'DifferentialRevisionListController' => 'applications/differential/controller/DifferentialRevisionListController.php',
|
||||||
'DifferentialRevisionListView' => 'applications/differential/view/DifferentialRevisionListView.php',
|
'DifferentialRevisionListView' => 'applications/differential/view/DifferentialRevisionListView.php',
|
||||||
|
@ -5199,7 +5198,6 @@ phutil_register_library_map(array(
|
||||||
'DifferentialRevisionHeraldField' => 'HeraldField',
|
'DifferentialRevisionHeraldField' => 'HeraldField',
|
||||||
'DifferentialRevisionHeraldFieldGroup' => 'HeraldFieldGroup',
|
'DifferentialRevisionHeraldFieldGroup' => 'HeraldFieldGroup',
|
||||||
'DifferentialRevisionIDCommitMessageField' => 'DifferentialCommitMessageField',
|
'DifferentialRevisionIDCommitMessageField' => 'DifferentialCommitMessageField',
|
||||||
'DifferentialRevisionIDField' => 'DifferentialCustomField',
|
|
||||||
'DifferentialRevisionLandController' => 'DifferentialController',
|
'DifferentialRevisionLandController' => 'DifferentialController',
|
||||||
'DifferentialRevisionListController' => 'DifferentialController',
|
'DifferentialRevisionListController' => 'DifferentialController',
|
||||||
'DifferentialRevisionListView' => 'AphrontView',
|
'DifferentialRevisionListView' => 'AphrontView',
|
||||||
|
|
|
@ -37,11 +37,9 @@ final class DifferentialParseCommitMessageConduitAPIMethod
|
||||||
|
|
||||||
$errors = $parser->getErrors();
|
$errors = $parser->getErrors();
|
||||||
|
|
||||||
// grab some extra information about the Differential Revision: field...
|
|
||||||
$revision_id_field = new DifferentialRevisionIDField();
|
|
||||||
$revision_id_value = idx(
|
$revision_id_value = idx(
|
||||||
$field_map,
|
$field_map,
|
||||||
$revision_id_field->getFieldKeyForConduit());
|
DifferentialRevisionIDCommitMessageField::FIELDKEY);
|
||||||
$revision_id_valid_domain = PhabricatorEnv::getProductionURI('');
|
$revision_id_valid_domain = PhabricatorEnv::getProductionURI('');
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -49,8 +49,6 @@ final class PhabricatorDifferentialConfigOptions
|
||||||
new DifferentialLintField(),
|
new DifferentialLintField(),
|
||||||
new DifferentialUnitField(),
|
new DifferentialUnitField(),
|
||||||
new DifferentialRevertPlanField(),
|
new DifferentialRevertPlanField(),
|
||||||
|
|
||||||
new DifferentialRevisionIDField(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$default_fields = array();
|
$default_fields = array();
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DifferentialRevisionIDField
|
|
||||||
extends DifferentialCustomField {
|
|
||||||
|
|
||||||
private $revisionID;
|
|
||||||
|
|
||||||
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 permanent link between them.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function canDisableField() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldAppearInCommitMessage() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function parseValueFromCommitMessage($value) {
|
|
||||||
// If the value is just "D123" or similar, parse the ID from it directly.
|
|
||||||
$value = trim($value);
|
|
||||||
$matches = null;
|
|
||||||
if (preg_match('/^[dD]([1-9]\d*)\z/', $value, $matches)) {
|
|
||||||
return (int)$matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, try to extract a URI value.
|
|
||||||
return self::parseRevisionIDFromURI($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function renderCommitMessageValue(array $handles) {
|
|
||||||
$id = coalesce($this->revisionID, $this->getObject()->getID());
|
|
||||||
if (!$id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return PhabricatorEnv::getProductionURI('/D'.$id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readValueFromCommitMessage($value) {
|
|
||||||
$this->revisionID = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function parseRevisionIDFromURI($uri_string) {
|
|
||||||
$uri = new PhutilURI($uri_string);
|
|
||||||
$path = $uri->getPath();
|
|
||||||
|
|
||||||
$matches = null;
|
|
||||||
if (preg_match('#^/D(\d+)$#', $path, $matches)) {
|
|
||||||
$id = (int)$matches[1];
|
|
||||||
|
|
||||||
$prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/D'.$id));
|
|
||||||
|
|
||||||
// Make sure the URI is the same as our URI. Basically, we want to ignore
|
|
||||||
// commits from other Phabricator installs.
|
|
||||||
if ($uri->getDomain() == $prod_uri->getDomain()) {
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$allowed_uris = PhabricatorEnv::getAllowedURIs('/D'.$id);
|
|
||||||
|
|
||||||
foreach ($allowed_uris as $allowed_uri) {
|
|
||||||
if ($uri_string == $allowed_uri) {
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue