diff --git a/src/applications/config/check/PhabricatorPygmentSetupCheck.php b/src/applications/config/check/PhabricatorPygmentSetupCheck.php --- a/src/applications/config/check/PhabricatorPygmentSetupCheck.php +++ b/src/applications/config/check/PhabricatorPygmentSetupCheck.php @@ -12,8 +12,9 @@ if ($pygment) { if (!Filesystem::binaryExists('pygmentize')) { $summary = pht( - 'You enabled pygments but the %s script is not '. + 'You enabled %s but the %s script is not '. 'actually available, your %s is probably broken.', + 'pygments', 'pygmentize', '$PATH'); @@ -21,10 +22,10 @@ 'The environmental variable %s does not contain %s. '. 'You have enabled pygments, which requires '. '%s to be available in your %s variable.', - '$PATH', - 'pygmentize', - 'pygmentize', - '$PATH'); + phutil_tag('tt', array(), '$PATH'), + phutil_tag('tt', array(), 'pygmentize'), + phutil_tag('tt', array(), 'pygmentize'), + phutil_tag('tt', array(), '$PATH')); $this ->newIssue('pygments.enabled') @@ -34,11 +35,14 @@ ->addRelatedPhabricatorConfig('pygments.enabled') ->addPhabricatorConfig('environment.append-paths'); } else { - list($err) = exec_manual('pygmentize -h'); + list($err, $stdout) = exec_manual('pygmentize -V'); + $version_matches = null; + preg_match('/Pygments version (\d(\.\d)+)/', $stdout, $version_matches); if ($err) { $summary = pht( - 'You have enabled pygments and the %s script is '. + 'You have enabled %s and the %s script is '. 'available, but does not seem to work.', + 'pygment', 'pygmentize'); $message = pht( @@ -47,7 +51,7 @@ 'installed correctly.', phutil_tag('tt', array(), 'pygmentize'), phutil_tag('tt', array(), '$PATH'), - phutil_tag('tt', array(), 'pygmentize -h')); + phutil_tag('tt', array(), 'pygmentize -V')); $this ->newIssue('pygments.failed') @@ -56,7 +60,59 @@ ->setMessage($message) ->addRelatedPhabricatorConfig('pygments.enabled') ->addPhabricatorConfig('environment.append-paths'); - } + } else if (empty($version_matches)) { + $summary = pht( + 'You have enabled %s and the %s script is '. + 'available, but does not seem to output a valid '. + 'version number.', + 'pygments', + 'pygmentize'); + + $message = pht( + 'Phabricator has %s available in %s, but the binary '. + 'output is not a valid version number when run as %s. '. + 'Check that it is installed correctly.', + phutil_tag('tt', array(), 'pygmentize'), + phutil_tag('tt', array(), '$PATH'), + phutil_tag('tt', array(), 'pygmentize -V')); + + $this + ->newIssue('pygments.invalide') + ->setName(pht('%s Invalide Version', 'pygmentize')) + ->setSummary($summary) + ->setMessage($message) + ->addRelatedPhabricatorConfig('pygments.enabled'); + } else if (version_compare($version_matches[1], '2.0.0', '<')) { + $summary = pht( + 'You have enabled %s and the %s script is '. + 'available. Upgrading %s from version %s '. + 'to version %s or greater can improve performance.', + 'pygments', + 'pygmentize', + 'pygments', + $version_matches[1], + '2.0'); + + $message = pht( + 'You may want to upgrade %s '. + 'from version %s to version %s or greater. '. + 'To upgrade %s, visit '. + '%s and follow the '. + 'upgrade instructions.', + phutil_tag('tt', array(), 'pygments'), + $version_matches[1], + '2.0', + phutil_tag('tt', array(), 'pygments'), + phutil_tag('a', array('href' => 'http://pygments.org'), + 'pygments.org')); + + $this + ->newIssue('pygments.outdated') + ->setName(pht('Outdated %s', 'pygmentize')) + ->setSummary($summary) + ->setMessage($message) + ->addRelatedPhabricatorConfig('pygments.enabled'); + } } } else { $summary = pht(