Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F76087
D7424.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7424.diff
View Options
diff --git a/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php
--- a/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php
@@ -23,4 +23,12 @@
return head($args->getArg('dir'));
}
+ protected function executeRepositoryOperations(
+ PhabricatorRepository $repository) {
+
+ $future = new ExecFuture('git-upload-pack %s', $repository->getLocalPath());
+
+ return $this->passthruIO($future);
+ }
+
}
diff --git a/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
--- a/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
@@ -10,6 +10,9 @@
abstract protected function isReadOnly();
abstract protected function getRequestPath();
+ abstract protected function executeRepositoryOperations(
+ PhabricatorRepository $repository);
+
protected function writeError($message) {
$this->getErrorChannel()->write($message);
return $this;
@@ -20,15 +23,11 @@
try {
$repository = $this->loadRepository();
-
- throw new Exception("TODO: Implement serve over SSH.");
-
+ return $this->executeRepositoryOperations($repository);
} catch (Exception $ex) {
$this->writeError(get_class($ex).': '.$ex->getMessage());
return 1;
}
-
- return 0;
}
private function loadRepository() {
diff --git a/src/infrastructure/ssh/PhabricatorSSHWorkflow.php b/src/infrastructure/ssh/PhabricatorSSHWorkflow.php
--- a/src/infrastructure/ssh/PhabricatorSSHWorkflow.php
+++ b/src/infrastructure/ssh/PhabricatorSSHWorkflow.php
@@ -37,6 +37,50 @@
return $this->iochannel;
}
+ public function passthruIO(ExecFuture $future) {
+ $exec_channel = new PhutilExecChannel($future);
+ $exec_channel->setStderrHandler(array($this, 'writeErrorIOCallback'));
+
+ $io_channel = $this->getIOChannel();
+ $error_channel = $this->getErrorChannel();
+
+ $channels = array($exec_channel, $io_channel, $error_channel);
+
+ while (true) {
+ PhutilChannel::waitForAny($channels);
+
+ $io_channel->update();
+ $exec_channel->update();
+ $error_channel->update();
+
+ $done = !$exec_channel->isOpen();
+
+ $data = $io_channel->read();
+ if (strlen($data)) {
+ $exec_channel->write($data);
+ }
+
+ $data = $exec_channel->read();
+ if (strlen($data)) {
+ $io_channel->write($data);
+ }
+
+ // If we have nothing left on stdin, close stdin on the subprocess.
+ if (!$io_channel->isOpenForReading()) {
+ // TODO: This should probably be part of PhutilExecChannel?
+ $future->write('');
+ }
+
+ if ($done) {
+ break;
+ }
+ }
+
+ list($err) = $future->resolve();
+
+ return $err;
+ }
+
public function readAllInput() {
$channel = $this->getIOChannel();
while ($channel->update()) {
@@ -53,4 +97,13 @@
return $this;
}
+ public function writeErrorIO($data) {
+ $this->getErrorChannel()->write($data);
+ return $this;
+ }
+
+ public function writeErrorIOCallback(PhutilChannel $channel, $data) {
+ $this->writeErrorIO($data);
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/gs/i2/3r6jqkxlcuonerby
Default Alt Text
D7424.diff (3 KB)
Attached To
Mode
D7424: Serve Git reads over SSH
Attached
Detach File
Event Timeline
Log In to Comment