[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialRevisionIDField 4 extends DifferentialCustomField { 5 6 private $revisionID; 7 8 public function getFieldKey() { 9 return 'differential:revision-id'; 10 } 11 12 public function getFieldKeyForConduit() { 13 return 'revisionID'; 14 } 15 16 public function getFieldName() { 17 return pht('Differential Revision'); 18 } 19 20 public function getFieldDescription() { 21 return pht( 22 'Ties commits to revisions and provides a permananent link between '. 23 'them.'); 24 } 25 26 public function canDisableField() { 27 return false; 28 } 29 30 public function shouldAppearInCommitMessage() { 31 return true; 32 } 33 34 public function parseValueFromCommitMessage($value) { 35 return self::parseRevisionIDFromURI($value); 36 } 37 38 public function renderCommitMessageValue(array $handles) { 39 $id = coalesce($this->revisionID, $this->getObject()->getID()); 40 if (!$id) { 41 return null; 42 } 43 return PhabricatorEnv::getProductionURI('/D'.$id); 44 } 45 46 public function readValueFromCommitMessage($value) { 47 $this->revisionID = $value; 48 } 49 50 private static function parseRevisionIDFromURI($uri_string) { 51 $uri = new PhutilURI($uri_string); 52 $path = $uri->getPath(); 53 54 $matches = null; 55 if (preg_match('#^/D(\d+)$#', $path, $matches)) { 56 $id = (int)$matches[1]; 57 58 $prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/D'.$id)); 59 60 // Make sure the URI is the same as our URI. Basically, we want to ignore 61 // commits from other Phabricator installs. 62 if ($uri->getDomain() == $prod_uri->getDomain()) { 63 return $id; 64 } 65 66 $allowed_uris = PhabricatorEnv::getAllowedURIs('/D'.$id); 67 68 foreach ($allowed_uris as $allowed_uri) { 69 if ($uri_string == $allowed_uri) { 70 return $id; 71 } 72 } 73 } 74 75 return null; 76 } 77 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |