Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php
12242 views
1
<?php
2
3
final class DiffusionGitUploadPackSSHWorkflow
4
extends DiffusionGitSSHWorkflow {
5
6
protected function didConstruct() {
7
$this->setName('git-upload-pack');
8
$this->setArguments(
9
array(
10
array(
11
'name' => 'dir',
12
'wildcard' => true,
13
),
14
));
15
}
16
17
protected function executeRepositoryOperations() {
18
$is_proxy = $this->shouldProxy();
19
if ($is_proxy) {
20
return $this->executeRepositoryProxyOperations($for_write = false);
21
}
22
23
$viewer = $this->getSSHUser();
24
$repository = $this->getRepository();
25
$device = AlmanacKeys::getLiveDevice();
26
27
$skip_sync = $this->shouldSkipReadSynchronization();
28
29
$command = csprintf('git-upload-pack -- %s', $repository->getLocalPath());
30
if (!$skip_sync) {
31
$cluster_engine = id(new DiffusionRepositoryClusterEngine())
32
->setViewer($viewer)
33
->setRepository($repository)
34
->setLog($this)
35
->synchronizeWorkingCopyBeforeRead();
36
37
if ($device) {
38
$this->writeClusterEngineLogMessage(
39
pht(
40
"# Cleared to fetch on cluster host \"%s\".\n",
41
$device->getName()));
42
}
43
}
44
45
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command);
46
47
$pull_event = $this->newPullEvent();
48
49
$future = id(new ExecFuture('%C', $command))
50
->setEnv($this->getEnvironment());
51
52
$log = $this->newProtocolLog($is_proxy);
53
if ($log) {
54
$this->setProtocolLog($log);
55
$log->didStartSession($command);
56
}
57
58
if (PhabricatorEnv::getEnvConfig('phabricator.show-prototypes')) {
59
$protocol = new DiffusionGitUploadPackWireProtocol();
60
if ($log) {
61
$protocol->setProtocolLog($log);
62
}
63
$this->setWireProtocol($protocol);
64
}
65
66
$err = $this->newPassthruCommand()
67
->setIOChannel($this->getIOChannel())
68
->setCommandChannelFromExecFuture($future)
69
->execute();
70
71
if ($log) {
72
$log->didEndSession();
73
}
74
75
if ($err) {
76
$pull_event
77
->setResultType(PhabricatorRepositoryPullEvent::RESULT_ERROR)
78
->setResultCode($err);
79
} else {
80
$pull_event
81
->setResultType(PhabricatorRepositoryPullEvent::RESULT_PULL)
82
->setResultCode(0);
83
}
84
85
$pull_event->save();
86
87
if (!$err) {
88
$this->waitForGitClient();
89
}
90
91
return $err;
92
}
93
94
}
95
96