mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Build "DiffusionCommitRef" objects from "internal.commit.search", not "diffusion.querycommits", in the message parser worker
Summary: Ref T13552. Swap the call we're using to build "CommitRef" objects here to the recently-introduced "internal.commit.search" method. Test Plan: Used "bin/repository reparse --message ..." to reparse commits, added "var_dump()" to inspect results. Saw sensible CommitRef and CommitData objects get built. Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21446
This commit is contained in:
parent
f6238f9d9b
commit
3a80efa440
5 changed files with 76 additions and 32 deletions
|
@ -73,17 +73,11 @@ abstract class DiffusionQuery extends PhabricatorQuery {
|
||||||
|
|
||||||
$params = $params + $core_params;
|
$params = $params + $core_params;
|
||||||
|
|
||||||
$client = $repository->newConduitClient(
|
$future = $repository->newConduitFuture(
|
||||||
$user,
|
$user,
|
||||||
|
$method,
|
||||||
|
$params,
|
||||||
$drequest->getIsClusterRequest());
|
$drequest->getIsClusterRequest());
|
||||||
if (!$client) {
|
|
||||||
$result = id(new ConduitCall($method, $params))
|
|
||||||
->setUser($user)
|
|
||||||
->execute();
|
|
||||||
$future = new ImmediateFuture($result);
|
|
||||||
} else {
|
|
||||||
$future = $client->callMethod($method, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$return_future) {
|
if (!$return_future) {
|
||||||
return $future->resolve();
|
return $future->resolve();
|
||||||
|
|
|
@ -2258,6 +2258,28 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newConduitFuture(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
$method,
|
||||||
|
array $params,
|
||||||
|
$never_proxy = false) {
|
||||||
|
|
||||||
|
$client = $this->newConduitClient(
|
||||||
|
$viewer,
|
||||||
|
$never_proxy);
|
||||||
|
|
||||||
|
if (!$client) {
|
||||||
|
$result = id(new ConduitCall($method, $params))
|
||||||
|
->setUser($viewer)
|
||||||
|
->execute();
|
||||||
|
$future = new ImmediateFuture($result);
|
||||||
|
} else {
|
||||||
|
$future = $client->callMethod($method, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $future;
|
||||||
|
}
|
||||||
|
|
||||||
public function getPassthroughEnvironmentalVariables() {
|
public function getPassthroughEnvironmentalVariables() {
|
||||||
$env = $_ENV;
|
$env = $_ENV;
|
||||||
|
|
||||||
|
|
|
@ -523,6 +523,50 @@ final class PhabricatorRepositoryCommit
|
||||||
return $data->getCommitDetail('committer');
|
return $data->getCommitDetail('committer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newCommitRef(PhabricatorUser $viewer) {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
|
||||||
|
$future = $repository->newConduitFuture(
|
||||||
|
$viewer,
|
||||||
|
'internal.commit.search',
|
||||||
|
array(
|
||||||
|
'constraints' => array(
|
||||||
|
'repositoryPHIDs' => array($repository->getPHID()),
|
||||||
|
'phids' => array($this->getPHID()),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$result = $future->resolve();
|
||||||
|
|
||||||
|
$commit_display = $this->getMonogram();
|
||||||
|
|
||||||
|
if (empty($result['data'])) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Unable to retrieve details for commit "%s"!',
|
||||||
|
$commit_display));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($result['data']) !== 1) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Got too many results (%s) for commit "%s", expected %s.',
|
||||||
|
phutil_count($result['data']),
|
||||||
|
$commit_display,
|
||||||
|
1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$record = head($result['data']);
|
||||||
|
$ref_record = idxv($record, array('fields', 'ref'));
|
||||||
|
|
||||||
|
if (!$ref_record) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Unable to retrieve CommitRef record for commit "%s".',
|
||||||
|
$commit_display));
|
||||||
|
}
|
||||||
|
|
||||||
|
return DiffusionCommitRef::newFromDictionary($ref_record);
|
||||||
|
}
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -124,4 +124,9 @@ abstract class PhabricatorRepositoryCommitParserWorker
|
||||||
|
|
||||||
return array($link, $suffix);
|
return array($link, $suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public function getViewer() {
|
||||||
|
return PhabricatorUser::getOmnipotentUser();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,31 +14,10 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
PhabricatorRepositoryCommit $commit) {
|
PhabricatorRepositoryCommit $commit) {
|
||||||
|
|
||||||
if (!$this->shouldSkipImportStep()) {
|
if (!$this->shouldSkipImportStep()) {
|
||||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$refs_raw = DiffusionQuery::callConduitWithDiffusionRequest(
|
$ref = $commit->newCommitRef($viewer);
|
||||||
$viewer,
|
|
||||||
DiffusionRequest::newFromDictionary(
|
|
||||||
array(
|
|
||||||
'repository' => $repository,
|
|
||||||
'user' => $viewer,
|
|
||||||
)),
|
|
||||||
'diffusion.querycommits',
|
|
||||||
array(
|
|
||||||
'repositoryPHID' => $repository->getPHID(),
|
|
||||||
'phids' => array($commit->getPHID()),
|
|
||||||
'bypassCache' => true,
|
|
||||||
'needMessages' => true,
|
|
||||||
));
|
|
||||||
|
|
||||||
if (empty($refs_raw['data'])) {
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
'Unable to retrieve details for commit "%s"!',
|
|
||||||
$commit->getPHID()));
|
|
||||||
}
|
|
||||||
|
|
||||||
$ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data']));
|
|
||||||
$this->updateCommitData($ref);
|
$this->updateCommitData($ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue