@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.

Link external bug trackers

Summary: Fixes T2971.

Test Plan:
/rG1.
Set regexp to one line and URL, then /rG1.
Set regexp to two lines, then /rG1.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2971

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

+73 -1
+15
src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
··· 65 65 pht("Disable Closing Audits"), 66 66 )) 67 67 ->setDescription(pht('Controls whether Author can Close Audits.')), 68 + 69 + $this->newOption('bugtraq.url', 'string', '') 70 + ->addExample('https://bugs.php.net/%BUGID%', pht('PHP bugs')) 71 + ->addExample('/%BUGID%', pht('Local Maniphest URL')) 72 + ->setDescription(pht( 73 + 'URL of external bug tracker used by Diffusion. %s will be '. 74 + 'substituted by the bug ID.', 75 + '%BUGID%')), 76 + $this->newOption('bugtraq.logregex', 'list<string>', array()) 77 + ->addExample(array('\B#([1-9]\d*)\b'), pht('Issue #123')) 78 + ->addExample(array('(?<!#)\b(T[1-9]\d*)\b'), pht('Task T123')) 79 + ->setDescription(pht( 80 + 'Regular expression to link external bug tracker. See '. 81 + 'http://tortoisesvn.net/docs/release/TortoiseSVN_en/'. 82 + 'tsvn-dug-bugtracker.html for further explanation.')), 68 83 ); 69 84 } 70 85
+8 -1
src/applications/diffusion/controller/DiffusionCommitController.php
··· 90 90 $property_list->addProperty($key, $value); 91 91 } 92 92 93 + $message = $commit_data->getCommitMessage(); 94 + 95 + $revision = $commit->getCommitIdentifier(); 96 + $message = $repository->linkBugtraq($message, $revision); 97 + 98 + $message = $engine->markupText($message); 99 + 93 100 $property_list->addTextContent( 94 101 phutil_tag( 95 102 'div', 96 103 array( 97 104 'class' => 'diffusion-commit-message phabricator-remarkup', 98 105 ), 99 - $engine->markupText($commit_data->getCommitMessage()))); 106 + $message)); 100 107 101 108 $content[] = $top_anchor; 102 109 $content[] = $headsup_view;
+50
src/applications/repository/storage/PhabricatorRepository.php
··· 634 634 } 635 635 636 636 637 + /** 638 + * Link external bug tracking system if defined. 639 + * 640 + * @param string Plain text. 641 + * @param string Commit identifier. 642 + * @return string Remarkup 643 + */ 644 + public function linkBugtraq($message, $revision = null) { 645 + $bugtraq_url = PhabricatorEnv::getEnvConfig('bugtraq.url'); 646 + list($bugtraq_re, $id_re) = 647 + PhabricatorEnv::getEnvConfig('bugtraq.logregex') + 648 + array('', ''); 649 + 650 + switch ($this->getVersionControlSystem()) { 651 + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 652 + // TODO: Get bugtraq:logregex and bugtraq:url from SVN properties. 653 + break; 654 + } 655 + 656 + if (!$bugtraq_url || $bugtraq_re == '') { 657 + return $message; 658 + } 659 + 660 + $matches = null; 661 + $flags = PREG_SET_ORDER | PREG_OFFSET_CAPTURE; 662 + preg_match_all('('.$bugtraq_re.')', $message, $matches, $flags); 663 + foreach ($matches as $match) { 664 + list($all, $all_offset) = array_shift($match); 665 + 666 + if ($id_re != '') { 667 + // Match substrings with bug IDs 668 + preg_match_all('('.$id_re.')', $all, $match, PREG_OFFSET_CAPTURE); 669 + list(, $match) = $match; 670 + } else { 671 + $all_offset = 0; 672 + } 673 + 674 + foreach ($match as $val) { 675 + list($s, $offset) = $val; 676 + $message = substr_replace( 677 + $message, 678 + '[[ '.str_replace('%BUGID%', $s, $bugtraq_url).' | '.$s.' ]]', 679 + $offset + $all_offset, 680 + strlen($s)); 681 + } 682 + } 683 + 684 + return $message; 685 + } 686 + 637 687 638 688 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 639 689