mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
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
This commit is contained in:
parent
f497b93e43
commit
5b36f0c97a
4 changed files with 64 additions and 0 deletions
|
@ -996,6 +996,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRepositoryManagementOtherPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementOtherPanelGroup.php',
|
'DiffusionRepositoryManagementOtherPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementOtherPanelGroup.php',
|
||||||
'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php',
|
'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php',
|
||||||
'DiffusionRepositoryManagementPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementPanelGroup.php',
|
'DiffusionRepositoryManagementPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementPanelGroup.php',
|
||||||
|
'DiffusionRepositoryMetricsSearchEngineAttachment' => 'applications/diffusion/engineextension/DiffusionRepositoryMetricsSearchEngineAttachment.php',
|
||||||
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
|
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
|
||||||
'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php',
|
'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php',
|
||||||
'DiffusionRepositoryProfilePictureController' => 'applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php',
|
'DiffusionRepositoryProfilePictureController' => 'applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php',
|
||||||
|
@ -6964,6 +6965,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRepositoryManagementOtherPanelGroup' => 'DiffusionRepositoryManagementPanelGroup',
|
'DiffusionRepositoryManagementOtherPanelGroup' => 'DiffusionRepositoryManagementPanelGroup',
|
||||||
'DiffusionRepositoryManagementPanel' => 'Phobject',
|
'DiffusionRepositoryManagementPanel' => 'Phobject',
|
||||||
'DiffusionRepositoryManagementPanelGroup' => 'Phobject',
|
'DiffusionRepositoryManagementPanelGroup' => 'Phobject',
|
||||||
|
'DiffusionRepositoryMetricsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||||
'DiffusionRepositoryPath' => 'Phobject',
|
'DiffusionRepositoryPath' => 'Phobject',
|
||||||
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
'DiffusionRepositoryProfilePictureController' => 'DiffusionController',
|
'DiffusionRepositoryProfilePictureController' => 'DiffusionController',
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionRepositoryMetricsSearchEngineAttachment
|
||||||
|
extends PhabricatorSearchEngineAttachment {
|
||||||
|
|
||||||
|
public function getAttachmentName() {
|
||||||
|
return pht('Repository Metrics');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentDescription() {
|
||||||
|
return pht(
|
||||||
|
'Get metrics (like commit count and most recent commit) for each '.
|
||||||
|
'repository.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willLoadAttachmentData($query, $spec) {
|
||||||
|
$query
|
||||||
|
->needCommitCounts(true)
|
||||||
|
->needMostRecentCommits(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentForObject($object, $data, $spec) {
|
||||||
|
$commit = $object->getMostRecentCommit();
|
||||||
|
if ($commit !== null) {
|
||||||
|
$recent_commit = $commit->getFieldValuesForConduit();
|
||||||
|
} else {
|
||||||
|
$recent_commit = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$commit_count = $object->getCommitCount();
|
||||||
|
if ($commit_count !== null) {
|
||||||
|
$commit_count = (int)$commit_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'commitCount' => $commit_count,
|
||||||
|
'recentCommit' => $recent_commit,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -215,6 +215,8 @@ final class PhabricatorRepositoryQuery
|
||||||
$commits = id(new DiffusionCommitQuery())
|
$commits = id(new DiffusionCommitQuery())
|
||||||
->setViewer($this->getViewer())
|
->setViewer($this->getViewer())
|
||||||
->withIDs($commit_ids)
|
->withIDs($commit_ids)
|
||||||
|
->needCommitData(true)
|
||||||
|
->needIdentities(true)
|
||||||
->execute();
|
->execute();
|
||||||
} else {
|
} else {
|
||||||
$commits = array();
|
$commits = array();
|
||||||
|
|
|
@ -2757,6 +2757,14 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
->setDescription(
|
->setDescription(
|
||||||
pht(
|
pht(
|
||||||
'The "Fetch" and "Permanent Ref" rules for this repository.')),
|
'The "Fetch" and "Permanent Ref" rules for this repository.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('defaultBranch')
|
||||||
|
->setType('string?')
|
||||||
|
->setDescription(pht('Default branch name.')),
|
||||||
|
id(new PhabricatorConduitSearchFieldSpecification())
|
||||||
|
->setKey('description')
|
||||||
|
->setType('remarkup')
|
||||||
|
->setDescription(pht('Repository description.')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2769,6 +2777,11 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
$track_rules = $this->getStringListForConduit($track_rules);
|
$track_rules = $this->getStringListForConduit($track_rules);
|
||||||
$permanent_rules = $this->getStringListForConduit($permanent_rules);
|
$permanent_rules = $this->getStringListForConduit($permanent_rules);
|
||||||
|
|
||||||
|
$default_branch = $this->getDefaultBranch();
|
||||||
|
if (!strlen($default_branch)) {
|
||||||
|
$default_branch = null;
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'vcs' => $this->getVersionControlSystem(),
|
'vcs' => $this->getVersionControlSystem(),
|
||||||
|
@ -2782,6 +2795,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
'trackRules' => $track_rules,
|
'trackRules' => $track_rules,
|
||||||
'permanentRefRules' => $permanent_rules,
|
'permanentRefRules' => $permanent_rules,
|
||||||
),
|
),
|
||||||
|
'defaultBranch' => $default_branch,
|
||||||
|
'description' => array(
|
||||||
|
'raw' => (string)$this->getDetail('description'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2804,6 +2821,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
return array(
|
return array(
|
||||||
id(new DiffusionRepositoryURIsSearchEngineAttachment())
|
id(new DiffusionRepositoryURIsSearchEngineAttachment())
|
||||||
->setAttachmentKey('uris'),
|
->setAttachmentKey('uris'),
|
||||||
|
id(new DiffusionRepositoryMetricsSearchEngineAttachment())
|
||||||
|
->setAttachmentKey('metrics'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue