Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
Show All 24 Lines | abstract class DiffusionSSHWorkflow extends PhabricatorSSHWorkflow { | ||||
} | } | ||||
public function getEnvironment() { | public function getEnvironment() { | ||||
$env = array( | $env = array( | ||||
DiffusionCommitHookEngine::ENV_USER => $this->getUser()->getUsername(), | DiffusionCommitHookEngine::ENV_USER => $this->getUser()->getUsername(), | ||||
DiffusionCommitHookEngine::ENV_REMOTE_PROTOCOL => 'ssh', | DiffusionCommitHookEngine::ENV_REMOTE_PROTOCOL => 'ssh', | ||||
); | ); | ||||
$ssh_client = getenv('SSH_CLIENT'); | $remote_address = $this->getSSHRemoteAddress(); | ||||
if ($ssh_client) { | if ($remote_address !== null) { | ||||
// This has the format "<ip> <remote-port> <local-port>". Grab the IP. | |||||
$remote_address = head(explode(' ', $ssh_client)); | |||||
$env[DiffusionCommitHookEngine::ENV_REMOTE_ADDRESS] = $remote_address; | $env[DiffusionCommitHookEngine::ENV_REMOTE_ADDRESS] = $remote_address; | ||||
} | } | ||||
return $env; | return $env; | ||||
} | } | ||||
/** | /** | ||||
* Identify and load the affected repository. | * Identify and load the affected repository. | ||||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | protected function shouldSkipReadSynchronization() { | ||||
// synchronizing reads do not themselves need to be synchronized. | // synchronizing reads do not themselves need to be synchronized. | ||||
if ($viewer->isOmnipotent()) { | if ($viewer->isOmnipotent()) { | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
protected function newPullEvent() { | |||||
$viewer = $this->getViewer(); | |||||
$repository = $this->getRepository(); | |||||
$remote_address = $this->getSSHRemoteAddress(); | |||||
return id(new PhabricatorRepositoryPullEvent()) | |||||
->setEpoch(PhabricatorTime::getNow()) | |||||
->setRemoteAddress($remote_address) | |||||
->setRemoteProtocol('ssh') | |||||
->setPullerPHID($viewer->getPHID()) | |||||
->setRepositoryPHID($repository->getPHID()); | |||||
} | |||||
} | } |