private function assertCommandEngineFormat($command, array $env, array $inputs) { $repository = id(new PhabricatorRepository())->setVersionControlSystem($inputs['vcs']); $future = DiffusionCommandEngine::newCommandEngine($repository)->setArgv((array) $inputs['argv'])->setProtocol(idx($inputs, 'protocol'))->newFuture(); $command_string = $future->getCommand(); $actual_command = $command_string->getUnmaskedString(); $this->assertEqual($command, $actual_command); $actual_environment = $future->getEnv(); $compare_environment = array_select_keys($actual_environment, array_keys($env)); $this->assertEqual($env, $compare_environment); }
public function newCommandEngine() { $repository = $this->getRepository(); return DiffusionCommandEngine::newCommandEngine($repository)->setCredentialPHID($this->getCredentialPHID())->setURI($this->getEffectiveURI()); }
private function newLocalCommandPassthru(array $argv) { $this->assertLocalExists(); $future = DiffusionCommandEngine::newCommandEngine($this)->setArgv($argv)->setPassthru(true)->newFuture(); if ($this->usesLocalWorkingCopy()) { $future->setCWD($this->getLocalPath()); } return $future; }
/** * @task internal */ private function synchronizeWorkingCopyFromBinding($binding) { $repository = $this->getRepository(); $device = AlmanacKeys::getLiveDevice(); $this->logLine(pht('Synchronizing this device ("%s") from cluster leader ("%s") before ' . 'read.', $device->getName(), $binding->getDevice()->getName())); $fetch_uri = $repository->getClusterRepositoryURIFromBinding($binding); $local_path = $repository->getLocalPath(); if ($repository->isGit()) { $this->requireWorkingCopy(); $argv = array('fetch --prune -- %s %s', $fetch_uri, '+refs/*:refs/*'); } else { throw new Exception(pht('Binding sync only supported for git!')); } $future = DiffusionCommandEngine::newCommandEngine($repository)->setArgv($argv)->setConnectAsDevice(true)->setSudoAsDaemon(true)->setURI($fetch_uri)->newFuture(); $future->setCWD($local_path); try { $future->resolvex(); } catch (Exception $ex) { $this->logLine(pht('Synchronization of "%s" from leader "%s" failed: %s', $device->getName(), $binding->getDevice()->getName(), $ex->getMessage())); throw $ex; } }