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

Add default branch, description, and metrics (commit count, recent commit) to "diffusion.repository.search"

Summary: Fixes T13430. Provide more information about repositories in "diffusion.repository.search".

Test Plan: Used API console to call method (with new "metrics" attachment), reviewed output. Saw new fields returned.

Maniphest Tasks: T13430

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

+64
+2
src/__phutil_library_map__.php
··· 996 996 'DiffusionRepositoryManagementOtherPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementOtherPanelGroup.php', 997 997 'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php', 998 998 'DiffusionRepositoryManagementPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementPanelGroup.php', 999 + 'DiffusionRepositoryMetricsSearchEngineAttachment' => 'applications/diffusion/engineextension/DiffusionRepositoryMetricsSearchEngineAttachment.php', 999 1000 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 1000 1001 'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php', 1001 1002 'DiffusionRepositoryProfilePictureController' => 'applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php', ··· 6964 6965 'DiffusionRepositoryManagementOtherPanelGroup' => 'DiffusionRepositoryManagementPanelGroup', 6965 6966 'DiffusionRepositoryManagementPanel' => 'Phobject', 6966 6967 'DiffusionRepositoryManagementPanelGroup' => 'Phobject', 6968 + 'DiffusionRepositoryMetricsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 6967 6969 'DiffusionRepositoryPath' => 'Phobject', 6968 6970 'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel', 6969 6971 'DiffusionRepositoryProfilePictureController' => 'DiffusionController',
+41
src/applications/diffusion/engineextension/DiffusionRepositoryMetricsSearchEngineAttachment.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryMetricsSearchEngineAttachment 4 + extends PhabricatorSearchEngineAttachment { 5 + 6 + public function getAttachmentName() { 7 + return pht('Repository Metrics'); 8 + } 9 + 10 + public function getAttachmentDescription() { 11 + return pht( 12 + 'Get metrics (like commit count and most recent commit) for each '. 13 + 'repository.'); 14 + } 15 + 16 + public function willLoadAttachmentData($query, $spec) { 17 + $query 18 + ->needCommitCounts(true) 19 + ->needMostRecentCommits(true); 20 + } 21 + 22 + public function getAttachmentForObject($object, $data, $spec) { 23 + $commit = $object->getMostRecentCommit(); 24 + if ($commit !== null) { 25 + $recent_commit = $commit->getFieldValuesForConduit(); 26 + } else { 27 + $recent_commit = null; 28 + } 29 + 30 + $commit_count = $object->getCommitCount(); 31 + if ($commit_count !== null) { 32 + $commit_count = (int)$commit_count; 33 + } 34 + 35 + return array( 36 + 'commitCount' => $commit_count, 37 + 'recentCommit' => $recent_commit, 38 + ); 39 + } 40 + 41 + }
+2
src/applications/repository/query/PhabricatorRepositoryQuery.php
··· 215 215 $commits = id(new DiffusionCommitQuery()) 216 216 ->setViewer($this->getViewer()) 217 217 ->withIDs($commit_ids) 218 + ->needCommitData(true) 219 + ->needIdentities(true) 218 220 ->execute(); 219 221 } else { 220 222 $commits = array();
+19
src/applications/repository/storage/PhabricatorRepository.php
··· 2757 2757 ->setDescription( 2758 2758 pht( 2759 2759 'The "Fetch" and "Permanent Ref" rules for this repository.')), 2760 + id(new PhabricatorConduitSearchFieldSpecification()) 2761 + ->setKey('defaultBranch') 2762 + ->setType('string?') 2763 + ->setDescription(pht('Default branch name.')), 2764 + id(new PhabricatorConduitSearchFieldSpecification()) 2765 + ->setKey('description') 2766 + ->setType('remarkup') 2767 + ->setDescription(pht('Repository description.')), 2760 2768 ); 2761 2769 } 2762 2770 ··· 2769 2777 $track_rules = $this->getStringListForConduit($track_rules); 2770 2778 $permanent_rules = $this->getStringListForConduit($permanent_rules); 2771 2779 2780 + $default_branch = $this->getDefaultBranch(); 2781 + if (!strlen($default_branch)) { 2782 + $default_branch = null; 2783 + } 2784 + 2772 2785 return array( 2773 2786 'name' => $this->getName(), 2774 2787 'vcs' => $this->getVersionControlSystem(), ··· 2781 2794 'fetchRules' => $fetch_rules, 2782 2795 'trackRules' => $track_rules, 2783 2796 'permanentRefRules' => $permanent_rules, 2797 + ), 2798 + 'defaultBranch' => $default_branch, 2799 + 'description' => array( 2800 + 'raw' => (string)$this->getDetail('description'), 2784 2801 ), 2785 2802 ); 2786 2803 } ··· 2804 2821 return array( 2805 2822 id(new DiffusionRepositoryURIsSearchEngineAttachment()) 2806 2823 ->setAttachmentKey('uris'), 2824 + id(new DiffusionRepositoryMetricsSearchEngineAttachment()) 2825 + ->setAttachmentKey('metrics'), 2807 2826 ); 2808 2827 } 2809 2828