Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893123
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
6 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/diffusion/data/DiffusionCommitRef.php b/src/applications/diffusion/data/DiffusionCommitRef.php
index 4d6b99d8a6..a3b10c2764 100644
--- a/src/applications/diffusion/data/DiffusionCommitRef.php
+++ b/src/applications/diffusion/data/DiffusionCommitRef.php
@@ -1,94 +1,114 @@
<?php
final class DiffusionCommitRef extends Phobject {
private $message;
private $authorName;
private $authorEmail;
private $committerName;
private $committerEmail;
private $hashes = array();
+ public static function newFromConduitResult(array $result) {
+ $ref = id(new DiffusionCommitRef())
+ ->setCommitterEmail(idx($result, 'committerEmail'))
+ ->setCommitterName(idx($result, 'committerName'))
+ ->setAuthorEmail(idx($result, 'authorEmail'))
+ ->setAuthorName(idx($result, 'authorName'))
+ ->setMessage(idx($result, 'message'));
+
+ $hashes = array();
+ foreach (idx($result, 'hashes', array()) as $hash_result) {
+ $hashes[] = id(new DiffusionCommitHash())
+ ->setHashType(idx($hash_result, 'type'))
+ ->setHashValue(idx($hash_result, 'value'));
+ }
+
+ $ref->setHashes($hashes);
+
+ return $ref;
+ }
+
public function setHashes(array $hashes) {
$this->hashes = $hashes;
return $this;
}
public function getHashes() {
return $this->hashes;
}
public function setCommitterEmail($committer_email) {
$this->committerEmail = $committer_email;
return $this;
}
public function getCommitterEmail() {
return $this->committerEmail;
}
public function setCommitterName($committer_name) {
$this->committerName = $committer_name;
return $this;
}
public function getCommitterName() {
return $this->committerName;
}
public function setAuthorEmail($author_email) {
$this->authorEmail = $author_email;
return $this;
}
public function getAuthorEmail() {
return $this->authorEmail;
}
public function setAuthorName($author_name) {
$this->authorName = $author_name;
return $this;
}
public function getAuthorName() {
return $this->authorName;
}
public function setMessage($message) {
$this->message = $message;
return $this;
}
public function getMessage() {
return $this->message;
}
public function getAuthor() {
return $this->formatUser($this->authorName, $this->authorEmail);
}
public function getCommitter() {
return $this->formatUser($this->committerName, $this->committerEmail);
}
public function getSummary() {
return PhabricatorRepositoryCommitData::summarizeCommitMessage(
$this->getMessage());
}
private function formatUser($name, $email) {
if (strlen($name) && strlen($email)) {
return "{$name} <{$email}>";
} else if (strlen($email)) {
return $email;
} else if (strlen($name)) {
return $name;
} else {
return null;
}
}
}
diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php
index dc2781ea05..c06cdcd1f4 100644
--- a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php
+++ b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php
@@ -1,97 +1,112 @@
<?php
final class PhabricatorRepositoryManagementLookupUsersWorkflow
extends PhabricatorRepositoryManagementWorkflow {
public function didConstruct() {
$this
->setName('lookup-users')
->setExamples('**lookup-users** __commit__ ...')
->setSynopsis('Resolve user accounts for users attached to __commit__.')
->setArguments(
array(
array(
'name' => 'commits',
'wildcard' => true,
),
));
}
public function execute(PhutilArgumentParser $args) {
$commits = $this->loadCommits($args, 'commits');
if (!$commits) {
throw new PhutilArgumentUsageException(
'Specify one or more commits to resolve users for.');
}
$console = PhutilConsole::getConsole();
foreach ($commits as $commit) {
$repo = $commit->getRepository();
$name = $repo->formatCommitName($commit->getCommitIdentifier());
$console->writeOut(
"%s\n",
pht('Examining commit %s...', $name));
- $ref = id(new DiffusionLowLevelCommitQuery())
- ->setRepository($repo)
- ->withIdentifier($commit->getCommitIdentifier())
- ->execute();
+ $refs_raw = DiffusionQuery::callConduitWithDiffusionRequest(
+ $this->getViewer(),
+ DiffusionRequest::newFromDictionary(
+ array(
+ 'repository' => $repo,
+ 'user' => $this->getViewer(),
+ )),
+ 'diffusion.querycommits',
+ array(
+ 'phids' => array($commit->getPHID()),
+ 'bypassCache' => true,
+ ));
+
+ if (empty($refs_raw['data'])) {
+ throw new Exception(
+ pht('Unable to retrieve details for commit "%s"!'));
+ }
+
+ $ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data']));
$author = $ref->getAuthor();
$console->writeOut(
"%s\n",
pht('Raw author string: %s', coalesce($author, 'null')));
if ($author !== null) {
$handle = $this->resolveUser($commit, $author);
if ($handle) {
$console->writeOut(
"%s\n",
pht('Phabricator user: %s', $handle->getFullName()));
} else {
$console->writeOut(
"%s\n",
pht('Unable to resolve a corresponding Phabricator user.'));
}
}
$committer = $ref->getCommitter();
$console->writeOut(
"%s\n",
pht('Raw committer string: %s', coalesce($committer, 'null')));
if ($committer !== null) {
$handle = $this->resolveUser($commit, $committer);
if ($handle) {
$console->writeOut(
"%s\n",
pht('Phabricator user: %s', $handle->getFullName()));
} else {
$console->writeOut(
"%s\n",
pht('Unable to resolve a corresponding Phabricator user.'));
}
}
}
return 0;
}
private function resolveUser(PhabricatorRepositoryCommit $commit, $name) {
$phid = id(new DiffusionResolveUserQuery())
->withCommit($commit)
->withName($name)
->execute();
if (!$phid) {
return null;
}
return id(new PhabricatorHandleQuery())
->setViewer($this->getViewer())
->withPHIDs(array($phid))
->executeOne();
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 17:54 (5 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127169
Default Alt Text
(6 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment