@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Raise a setup warning for an unparseable VCS binary version

Summary:
Hit this locally, with an error like:

> Version <empty string> is older than 1.9, the minimum supported version.

(Where `<empty string>` was just the empty string, not literally the text `<empty string>`.)

Be more careful about parsing versions, and parse the newer string.

Test Plan: Got "unknown version" with intentionally-broken test data, then clean readout.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11558

+122 -17
+65 -17
src/applications/config/check/PhabricatorBinariesSetupCheck.php
··· 93 93 $this->raiseWarning($binary, $message); 94 94 } 95 95 96 + $version = null; 96 97 switch ($binary) { 97 98 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 98 99 $minimum_version = null; ··· 118 119 'leak, fixed in 2.2.1. Pushing fails with this '. 119 120 'version as well; see T3046#54922.'),); 120 121 list($err, $stdout, $stderr) = exec_manual('hg --version --quiet'); 121 - $version = rtrim( 122 - substr($stdout, strlen('Mercurial Distributed SCM (version ')), 123 - ")\n"); 122 + 123 + // NOTE: At least on OSX, recent versions of Mercurial report this 124 + // string in this format: 125 + // 126 + // Mercurial Distributed SCM (version 3.1.1+20140916) 127 + 128 + $matches = null; 129 + $pattern = '/^Mercurial Distributed SCM \(version ([\d.]+)/m'; 130 + if (preg_match($pattern, $stdout, $matches)) { 131 + $version = $matches[1]; 132 + } 124 133 break; 125 134 } 126 135 127 - if ($minimum_version && 128 - version_compare($version, $minimum_version, '<')) { 129 - $this->raiseMinimumVersionWarning( 130 - $binary, 131 - $minimum_version, 132 - $version); 133 - } 134 - 135 - foreach ($bad_versions as $bad_version => $details) { 136 - if ($bad_version === $version) { 137 - $this->raiseBadVersionWarning( 136 + if ($version === null) { 137 + $this->raiseUnknownVersionWarning($binary); 138 + } else { 139 + if ($minimum_version && 140 + version_compare($version, $minimum_version, '<')) { 141 + $this->raiseMinimumVersionWarning( 138 142 $binary, 139 - $bad_version); 143 + $minimum_version, 144 + $version); 145 + } 146 + 147 + foreach ($bad_versions as $bad_version => $details) { 148 + if ($bad_version === $version) { 149 + $this->raiseBadVersionWarning( 150 + $binary, 151 + $bad_version); 152 + } 140 153 } 141 154 } 142 155 } ··· 173 186 ->addPhabricatorConfig('environment.append-paths'); 174 187 } 175 188 189 + private function raiseUnknownVersionWarning($binary) { 190 + $summary = pht( 191 + 'Unable to determine the version number of "%s".', 192 + $binary); 193 + 194 + $message = pht( 195 + 'Unable to determine the version number of "%s". Usually, this means '. 196 + 'the program changed its version format string recently and Phabricator '. 197 + 'does not know how to parse the new one yet, but might indicate that '. 198 + 'you have a very old (or broken) binary.'. 199 + "\n\n". 200 + 'Because we can not determine the version number, checks against '. 201 + 'minimum and known-bad versions will be skipped, so we might fail '. 202 + 'to detect an incompatible binary.'. 203 + "\n\n". 204 + 'You may be able to resolve this issue by updating Phabricator, since '. 205 + 'a newer version of Phabricator is likely to be able to parse the '. 206 + 'newer version string.'. 207 + "\n\n". 208 + 'If updating Phabricator does not fix this, you can report the issue '. 209 + 'to the upstream so we can adjust the parser.'. 210 + "\n\n". 211 + 'If you are confident you have a recent version of "%s" installed and '. 212 + 'working correctly, it is usually safe to ignore this warning.', 213 + $binary, 214 + $binary); 215 + 216 + $this->newIssue('bin.'.$binary.'.unknown-version') 217 + ->setShortName(pht("Unknown '%s' Version", $binary)) 218 + ->setName(pht("Unknown '%s' Version", $binary)) 219 + ->setSummary($summary) 220 + ->setMessage($message) 221 + ->addLink( 222 + PhabricatorEnv::getDoclink('Contributing Bug Reports'), 223 + pht('Report this Issue to the Upstream')); 224 + } 225 + 176 226 private function raiseMinimumVersionWarning( 177 227 $binary, 178 228 $minimum_version, ··· 200 250 ->setMessage($summary.' '.$message); 201 251 break; 202 252 } 203 - 204 - 205 253 } 206 254 207 255 private function raiseBadVersionWarning($binary, $bad_version) {
+14
src/applications/config/issue/PhabricatorSetupIssue.php
··· 17 17 private $commands = array(); 18 18 private $mysqlConfig = array(); 19 19 private $originalPHPConfigValues = array(); 20 + private $links; 20 21 21 22 public function addCommand($command) { 22 23 $this->commands[] = $command; ··· 162 163 public function getIsIgnored() { 163 164 return $this->isIgnored; 164 165 } 166 + 167 + public function addLink($href, $name) { 168 + $this->links[] = array( 169 + 'href' => $href, 170 + 'name' => $name, 171 + ); 172 + return $this; 173 + } 174 + 175 + public function getLinks() { 176 + return $this->links; 177 + } 178 + 165 179 }
+38
src/applications/config/view/PhabricatorSetupIssueView.php
··· 107 107 108 108 } 109 109 110 + $related_links = $issue->getLinks(); 111 + if ($related_links) { 112 + $description[] = $this->renderRelatedLinks($related_links); 113 + } 114 + 110 115 $actions = array(); 111 116 if (!$issue->getIsFatal()) { 112 117 if ($issue->getIsIgnored()) { ··· 506 511 } else { 507 512 return PhabricatorConfigJSON::prettyPrintJSON($value); 508 513 } 514 + } 515 + 516 + private function renderRelatedLinks(array $links) { 517 + $link_info = phutil_tag( 518 + 'p', 519 + array(), 520 + pht( 521 + '%d related link(s):', 522 + count($links))); 523 + 524 + $link_list = array(); 525 + foreach ($links as $link) { 526 + $link_tag = phutil_tag( 527 + 'a', 528 + array( 529 + 'target' => '_blank', 530 + 'href' => $link['href'], 531 + ), 532 + $link['name']); 533 + $link_item = phutil_tag('li', array(), $link_tag); 534 + $link_list[] = $link_item; 535 + } 536 + $link_list = phutil_tag('ul', array(), $link_list); 537 + 538 + return phutil_tag( 539 + 'div', 540 + array( 541 + 'class' => 'setup-issue-config', 542 + ), 543 + array( 544 + $link_info, 545 + $link_list, 546 + )); 509 547 } 510 548 511 549 }
+5
src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php
··· 885 885 886 886 '%s edited %s edge(s) for %s, added %s: %s; removed %s: %s.' => 887 887 '%s edited edges for %3$s, added: %5$s; removed %7$s.', 888 + 889 + '%d related link(s):' => array( 890 + 'Related link:', 891 + 'Related links:', 892 + ), 888 893 ); 889 894 } 890 895