From f6238f9d9bd38f3f7ade4a33e496b85352499df9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 12 Aug 2020 12:00:45 -0700 Subject: [PATCH] Remove "bin/repository lookup-users" workflow Summary: Ref T13552. This is one of two callsites to "diffusion.querycommits". It's an old debugging workflow which I haven't used in years and which is likely obsoleted by identities and other changes. I believe the root problem here was also ultimately user error (a user has misconfigured their local Git author email as another user). Test Plan: Grepped for "lookup-users", got no hits. Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21444 --- src/__phutil_library_map__.php | 2 - ...epositoryManagementLookupUsersWorkflow.php | 115 ------------------ 2 files changed, 117 deletions(-) delete mode 100644 src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3769b19f8d..c4f688ac23 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4588,7 +4588,6 @@ phutil_register_library_map(array( 'PhabricatorRepositoryManagementImportingWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementImportingWorkflow.php', 'PhabricatorRepositoryManagementListPathsWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementListPathsWorkflow.php', 'PhabricatorRepositoryManagementListWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementListWorkflow.php', - 'PhabricatorRepositoryManagementLookupUsersWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php', 'PhabricatorRepositoryManagementMaintenanceWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementMaintenanceWorkflow.php', 'PhabricatorRepositoryManagementMarkImportedWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementMarkImportedWorkflow.php', 'PhabricatorRepositoryManagementMarkReachableWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementMarkReachableWorkflow.php', @@ -11326,7 +11325,6 @@ phutil_register_library_map(array( 'PhabricatorRepositoryManagementImportingWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 'PhabricatorRepositoryManagementListPathsWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 'PhabricatorRepositoryManagementListWorkflow' => 'PhabricatorRepositoryManagementWorkflow', - 'PhabricatorRepositoryManagementLookupUsersWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 'PhabricatorRepositoryManagementMaintenanceWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 'PhabricatorRepositoryManagementMarkImportedWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 'PhabricatorRepositoryManagementMarkReachableWorkflow' => 'PhabricatorRepositoryManagementWorkflow', diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php deleted file mode 100644 index ec65a8bcfa..0000000000 --- a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php +++ /dev/null @@ -1,115 +0,0 @@ -setName('lookup-users') - ->setExamples('**lookup-users** __commit__ ...') - ->setSynopsis( - pht('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( - pht('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)); - - $refs_raw = DiffusionQuery::callConduitWithDiffusionRequest( - $this->getViewer(), - DiffusionRequest::newFromDictionary( - array( - 'repository' => $repo, - 'user' => $this->getViewer(), - )), - 'diffusion.querycommits', - array( - 'repositoryPHID' => $repo->getPHID(), - 'phids' => array($commit->getPHID()), - 'bypassCache' => 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'])); - - $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()) - ->withName($name) - ->execute(); - - if (!$phid) { - return null; - } - - return id(new PhabricatorHandleQuery()) - ->setViewer($this->getViewer()) - ->withPHIDs(array($phid)) - ->executeOne(); - } - -}