3 final class DiffusionGitLFSAuthenticateWorkflow
4 extends DiffusionGitSSHWorkflow
{
6 protected function didConstruct() {
7 $this->setName('git-lfs-authenticate');
17 protected function identifyRepository() {
18 return $this->loadRepositoryWithPath(
19 $this->getLFSPathArgument(),
20 PhabricatorRepositoryType
::REPOSITORY_TYPE_GIT
);
23 private function getLFSPathArgument() {
24 return $this->getLFSArgument(0);
27 private function getLFSOperationArgument() {
28 return $this->getLFSArgument(1);
31 private function getLFSArgument($position) {
32 $args = $this->getArgs();
33 $argv = $args->getArg('argv');
35 if (!isset($argv[$position])) {
38 'Expected `git-lfs-authenticate <path> <operation>`, but received '.
39 'too few arguments.'));
42 return $argv[$position];
45 protected function executeRepositoryOperations() {
46 $operation = $this->getLFSOperationArgument();
48 // NOTE: We aren't checking write access here, even for "upload". The
49 // HTTP endpoint should be able to do that for us.
58 'Git LFS operation "%s" is not supported by this server.',
62 $repository = $this->getRepository();
64 if (!$repository->isGit()) {
67 'Repository "%s" is not a Git repository. Git LFS is only '.
68 'supported for Git repositories.',
69 $repository->getDisplayName()));
72 if (!$repository->canUseGitLFS()) {
74 pht('Git LFS is not enabled for this repository.'));
77 // NOTE: This is usually the same as the default URI (which does not
78 // need to be specified in the response), but the protocol or domain may
79 // differ in some situations.
81 $lfs_uri = $repository->getGitLFSURI('info/lfs');
83 // Generate a temporary token to allow the user to access LFS over HTTP.
84 // This works even if normal HTTP repository operations are not available
85 // on this host, and does not require the user to have a VCS password.
87 $user = $this->getSSHUser();
89 $authorization = DiffusionGitLFSTemporaryTokenType
::newHTTPAuthorization(
95 'authorization' => $authorization,
102 $result = phutil_json_encode($result);
104 $this->writeIO($result);
105 $this->waitForGitClient();