diff --git a/src/applications/diffusion/query/DiffusionResolveUserQuery.php b/src/applications/diffusion/query/DiffusionResolveUserQuery.php --- a/src/applications/diffusion/query/DiffusionResolveUserQuery.php +++ b/src/applications/diffusion/query/DiffusionResolveUserQuery.php @@ -8,25 +8,14 @@ final class DiffusionResolveUserQuery extends Phobject { private $name; - private $commit; public function withName($name) { $this->name = $name; return $this; } - public function withCommit($commit) { - $this->commit = $commit; - return $this; - } - public function execute() { - $user_name = $this->name; - - $phid = $this->findUserPHID($this->name); - $phid = $this->fireLookupEvent($phid); - - return $phid; + return $this->findUserPHID($this->name); } private function findUserPHID($user_name) { @@ -75,33 +64,15 @@ } - /** - * Emit an event so installs can do custom lookup of commit authors who may - * not be naturally resolvable. - */ - private function fireLookupEvent($guess) { - - $type = PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER; - $data = array( - 'commit' => $this->commit, - 'query' => $this->name, - 'result' => $guess, - ); - - $event = new PhabricatorEvent($type, $data); - PhutilEventEngine::dispatchEvent($event); - - return $event->getValue('result'); - } - - private function findUserByUserName($user_name) { $by_username = id(new PhabricatorUser())->loadOneWhere( 'userName = %s', $user_name); + if ($by_username) { return $by_username->getPHID(); } + return null; } @@ -112,18 +83,22 @@ $by_realname = id(new PhabricatorUser())->loadAllWhere( 'realName = %s', $real_name); + if (count($by_realname) == 1) { - return reset($by_realname)->getPHID(); + return head($by_realname)->getPHID(); } + return null; } private function findUserByEmailAddress($email_address) { $by_email = PhabricatorUser::loadOneWithEmailAddress($email_address); + if ($by_email) { return $by_email->getPHID(); } + return null; } diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php --- a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php @@ -99,7 +99,6 @@ private function resolveUser(PhabricatorRepositoryCommit $commit, $name) { $phid = id(new DiffusionResolveUserQuery()) - ->withCommit($commit) ->withName($name) ->execute(); diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php --- a/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php @@ -101,7 +101,6 @@ if (empty($seen[$identity_key])) { try { $user_phid = id(new DiffusionResolveUserQuery()) - ->withCommit($commit) ->withName($identity_name) ->execute(); diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -182,7 +182,6 @@ $user_name) { return id(new DiffusionResolveUserQuery()) - ->withCommit($commit) ->withName($user_name) ->execute(); } diff --git a/src/docs/user/userguide/events.diviner b/src/docs/user/userguide/events.diviner --- a/src/docs/user/userguide/events.diviner +++ b/src/docs/user/userguide/events.diviner @@ -159,35 +159,6 @@ - `repository` The @{class:PhabricatorRepository} the commit was discovered in. -== Diffusion: Lookup User == - -The constant for this event is -`PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER`. - -This event is dispatched when the daemons are trying to link a commit to a -Phabricator user account. You can listen for it to improve the accuracy of -associating users with their commits. - -By default, Phabricator will try to find matches based on usernames, real names, -or email addresses, but this can result in incorrect matches (e.g., if you have -several employees with the same name) or failures to match (e.g., if someone -changed their email address). Listening for this event allows you to intercept -the lookup and supplement the results from another datasource. - -Data available on this event: - - - `commit` The @{class:PhabricatorRepositoryCommit} that data is being looked - up for. - - `query` The author or committer string being looked up. This will usually - be something like "Abraham Lincoln ", but - comes from the commit metadata so it may not be well-formatted. - - `result` The current result from the lookup (Phabricator's best guess at - the user PHID of the user named in the "query"). To substitute the result - with a different result, replace this with the correct PHID in your event - listener. - -Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query. - == Test: Did Run Test == The constant for this event is diff --git a/src/infrastructure/events/constant/PhabricatorEventType.php b/src/infrastructure/events/constant/PhabricatorEventType.php --- a/src/infrastructure/events/constant/PhabricatorEventType.php +++ b/src/infrastructure/events/constant/PhabricatorEventType.php @@ -9,7 +9,6 @@ const TYPE_DIFFERENTIAL_WILLMARKGENERATED = 'differential.willMarkGenerated'; const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit'; - const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser'; const TYPE_TEST_DIDRUNTEST = 'test.didRunTest';