mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-22 19:49:02 +01:00
Enrich "diffusion.commit.search" with identity, status, and message information
Summary: Depends on D19657. Ref T13197. See PHI841. This enriches the results from `diffusion.commit.search` with information similar to the information returned by the "commits" attachment from `differential.diff.search`. Also include unreachable, imported, message, audit status, and repository PHID. Test Plan: Called `diffusion.commit.search` and reviewed the results, which looked sensible. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13197 Differential Revision: https://secure.phabricator.com/D19658
This commit is contained in:
parent
c7e7b63f15
commit
8268abcb78
3 changed files with 107 additions and 2 deletions
|
@ -15,6 +15,7 @@ final class PhabricatorCommitSearchEngine
|
|||
return id(new DiffusionCommitQuery())
|
||||
->needAuditRequests(true)
|
||||
->needCommitData(true)
|
||||
->needIdentities(true)
|
||||
->needDrafts(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
return idx($this->spec, 'color');
|
||||
}
|
||||
|
||||
public function getAnsiColor() {
|
||||
return idx($this->spec, 'color.ansi');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return idx($this->spec, 'name', pht('Unknown ("%s")', $this->key));
|
||||
}
|
||||
|
@ -122,6 +126,7 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
'icon' => 'fa-check',
|
||||
'color' => 'bluegrey',
|
||||
'closed' => true,
|
||||
'color.ansi' => null,
|
||||
),
|
||||
self::NEEDS_AUDIT => array(
|
||||
'name' => pht('Audit Required'),
|
||||
|
@ -129,6 +134,7 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
'icon' => 'fa-exclamation-circle',
|
||||
'color' => 'orange',
|
||||
'closed' => false,
|
||||
'color.ansi' => 'magenta',
|
||||
),
|
||||
self::CONCERN_RAISED => array(
|
||||
'name' => pht('Concern Raised'),
|
||||
|
@ -136,6 +142,7 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
'icon' => 'fa-times-circle',
|
||||
'color' => 'red',
|
||||
'closed' => false,
|
||||
'color.ansi' => 'red',
|
||||
),
|
||||
self::PARTIALLY_AUDITED => array(
|
||||
'name' => pht('Partially Audited'),
|
||||
|
@ -143,6 +150,7 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
'icon' => 'fa-check-circle-o',
|
||||
'color' => 'yellow',
|
||||
'closed' => false,
|
||||
'color.ansi' => 'yellow',
|
||||
),
|
||||
self::AUDITED => array(
|
||||
'name' => pht('Audited'),
|
||||
|
@ -150,6 +158,7 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
'icon' => 'fa-check-circle',
|
||||
'color' => 'green',
|
||||
'closed' => true,
|
||||
'color.ansi' => 'green',
|
||||
),
|
||||
self::NEEDS_VERIFICATION => array(
|
||||
'name' => pht('Needs Verification'),
|
||||
|
@ -157,6 +166,7 @@ final class DiffusionCommitAuditStatus extends Phobject {
|
|||
'icon' => 'fa-refresh',
|
||||
'color' => 'indigo',
|
||||
'closed' => false,
|
||||
'color.ansi' => 'magenta',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -851,16 +851,110 @@ final class PhabricatorRepositoryCommit
|
|||
->setKey('identifier')
|
||||
->setType('string')
|
||||
->setDescription(pht('The commit identifier.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('repositoryPHID')
|
||||
->setType('phid')
|
||||
->setDescription(pht('The repository this commit belongs to.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('author')
|
||||
->setType('map<string, wild>')
|
||||
->setDescription(pht('Information about the commit author.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('committer')
|
||||
->setType('map<string, wild>')
|
||||
->setDescription(pht('Information about the committer.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('isImported')
|
||||
->setType('bool')
|
||||
->setDescription(pht('True if the commit is fully imported.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('isUnreachable')
|
||||
->setType('bool')
|
||||
->setDescription(
|
||||
pht(
|
||||
'True if the commit is not the ancestor of any tag, branch, or '.
|
||||
'ref.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('auditStatus')
|
||||
->setType('map<string, wild>')
|
||||
->setDescription(pht('Information about the current audit status.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('message')
|
||||
->setType('string')
|
||||
->setDescription(pht('The commit message.')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit() {
|
||||
$data = $this->getCommitData();
|
||||
|
||||
// NOTE: This data should be similar to the information returned about
|
||||
// commmits by "differential.diff.search" with the "commits" attachment.
|
||||
$author_identity = $this->getAuthorIdentity();
|
||||
if ($author_identity) {
|
||||
$author_name = $author_identity->getIdentityDisplayName();
|
||||
$author_email = $author_identity->getIdentityEmailAddress();
|
||||
$author_raw = $author_identity->getIdentityName();
|
||||
$author_identity_phid = $author_identity->getPHID();
|
||||
$author_user_phid = $author_identity->getCurrentEffectiveUserPHID();
|
||||
} else {
|
||||
$author_name = null;
|
||||
$author_email = null;
|
||||
$author_raw = null;
|
||||
$author_identity_phid = null;
|
||||
$author_user_phid = null;
|
||||
}
|
||||
|
||||
$committer_identity = $this->getCommitterIdentity();
|
||||
if ($committer_identity) {
|
||||
$committer_name = $committer_identity->getIdentityDisplayName();
|
||||
$committer_email = $committer_identity->getIdentityEmailAddress();
|
||||
$committer_raw = $committer_identity->getIdentityName();
|
||||
$committer_identity_phid = $committer_identity->getPHID();
|
||||
$committer_user_phid = $committer_identity->getCurrentEffectiveUserPHID();
|
||||
} else {
|
||||
$committer_name = null;
|
||||
$committer_email = null;
|
||||
$committer_raw = null;
|
||||
$committer_identity_phid = null;
|
||||
$committer_user_phid = null;
|
||||
}
|
||||
|
||||
$author_epoch = $data->getCommitDetail('authorEpoch');
|
||||
if ($author_epoch) {
|
||||
$author_epoch = (int)$author_epoch;
|
||||
} else {
|
||||
$author_epoch = null;
|
||||
}
|
||||
|
||||
$audit_status = $this->getAuditStatusObject();
|
||||
|
||||
return array(
|
||||
'identifier' => $this->getCommitIdentifier(),
|
||||
'repositoryPHID' => $this->getRepository()->getPHID(),
|
||||
'author' => array(
|
||||
'name' => $author_name,
|
||||
'email' => $author_email,
|
||||
'raw' => $author_raw,
|
||||
'epoch' => $author_epoch,
|
||||
'identityPHID' => $author_identity_phid,
|
||||
'userPHID' => $author_user_phid,
|
||||
),
|
||||
'committer' => array(
|
||||
'name' => $committer_name,
|
||||
'email' => $committer_email,
|
||||
'raw' => $committer_raw,
|
||||
'epoch' => (int)$this->getEpoch(),
|
||||
'identityPHID' => $committer_identity_phid,
|
||||
'userPHID' => $committer_user_phid,
|
||||
),
|
||||
'isUnreachable' => (bool)$this->isUnreachable(),
|
||||
'isImported' => (bool)$this->isImported(),
|
||||
'auditStatus' => array(
|
||||
'value' => $audit_status->getKey(),
|
||||
'name' => $audit_status->getName(),
|
||||
'closed' => (bool)$audit_status->getIsClosed(),
|
||||
'color.ansi' => $audit_status->getAnsiColor(),
|
||||
),
|
||||
'message' => $data->getCommitMessage(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue