From c6665b190731a9d4bbe21bfdb37003b85caaef14 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 26 Oct 2013 14:11:52 -0700 Subject: [PATCH] Serve git writes over SSH Summary: Looks like this is pretty straightforward; same as the reads except mark it as needing PUSH. Test Plan: Ran `git push`, pushed over SSH to a hosted repo. Reviewers: btrahan Reviewed By: btrahan CC: hach-que, aran Maniphest Tasks: T2230 Differential Revision: https://secure.phabricator.com/D7425 --- scripts/ssh/ssh-exec.php | 1 + src/__phutil_library_map__.php | 2 ++ .../DiffusionSSHGitReceivePackWorkflow.php | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php diff --git a/scripts/ssh/ssh-exec.php b/scripts/ssh/ssh-exec.php index 74d79ed632..cdc62d7a8d 100755 --- a/scripts/ssh/ssh-exec.php +++ b/scripts/ssh/ssh-exec.php @@ -63,6 +63,7 @@ try { new ConduitSSHWorkflow(), new DiffusionSSHGitUploadPackWorkflow(), + new DiffusionSSHGitReceivePackWorkflow(), ); $workflow_names = mpull($workflows, 'getName', 'getName'); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a4d008da0a..719fb748e8 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -527,6 +527,7 @@ phutil_register_library_map(array( 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php', 'DiffusionRequest' => 'applications/diffusion/request/DiffusionRequest.php', + 'DiffusionSSHGitReceivePackWorkflow' => 'applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php', 'DiffusionSSHGitUploadPackWorkflow' => 'applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php', 'DiffusionSSHGitWorkflow' => 'applications/diffusion/ssh/DiffusionSSHGitWorkflow.php', 'DiffusionSSHWorkflow' => 'applications/diffusion/ssh/DiffusionSSHWorkflow.php', @@ -2716,6 +2717,7 @@ phutil_register_library_map(array( 0 => 'DiffusionController', 1 => 'PhabricatorApplicationSearchResultsControllerInterface', ), + 'DiffusionSSHGitReceivePackWorkflow' => 'DiffusionSSHGitWorkflow', 'DiffusionSSHGitUploadPackWorkflow' => 'DiffusionSSHGitWorkflow', 'DiffusionSSHGitWorkflow' => 'DiffusionSSHWorkflow', 'DiffusionSSHWorkflow' => 'PhabricatorSSHWorkflow', diff --git a/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php new file mode 100644 index 0000000000..b617f22505 --- /dev/null +++ b/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php @@ -0,0 +1,34 @@ +setName('git-receive-pack'); + $this->setArguments( + array( + array( + 'name' => 'dir', + 'wildcard' => true, + ), + )); + } + + public function isReadOnly() { + return false; + } + + public function getRequestPath() { + $args = $this->getArgs(); + return head($args->getArg('dir')); + } + + protected function executeRepositoryOperations( + PhabricatorRepository $repository) { + $future = new ExecFuture( + 'git-receive-pack %s', + $repository->getLocalPath()); + return $this->passthruIO($future); + } + +}