mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-28 12:08:14 +01:00
Summary: Ref T4292. Ref T10366. Depends on D15751. Today, generating repository commands is purely a function of the repository, so they use protocols and credentials based on the repository configuration. For example, a repository with an SSH "remote URI" always generate SSH "remote commands". This needs to change in the future: - After T10366, repositories won't necessarily just have one type of remote URI. They can only have one at a time still, but the repository itself won't change based on which one is currently active. - For T4292, I need to generate intracluster commands, regardless of repository configuration. These will have different protocols and credentials. Prepare for these cases by separating out command construction, so they'll be able to generate commands in a more flexible way. Test Plan: - Added unit tests. - Browsed diffusion. - Ran `bin/phd debug pull` to pull a bunch of repos. - Ran daemons. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4292, T10366 Differential Revision: https://secure.phabricator.com/D15752
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
final class DiffusionGitCommandEngine
|
|
extends DiffusionCommandEngine {
|
|
|
|
protected function canBuildForRepository(
|
|
PhabricatorRepository $repository) {
|
|
return $repository->isGit();
|
|
}
|
|
|
|
protected function newFormattedCommand($pattern, array $argv) {
|
|
$pattern = "git {$pattern}";
|
|
return array($pattern, $argv);
|
|
}
|
|
|
|
protected function newCustomEnvironment() {
|
|
$env = array();
|
|
|
|
// NOTE: See T2965. Some time after Git 1.7.5.4, Git started fataling if
|
|
// it can not read $HOME. For many users, $HOME points at /root (this
|
|
// seems to be a default result of Apache setup). Instead, explicitly
|
|
// point $HOME at a readable, empty directory so that Git looks for the
|
|
// config file it's after, fails to locate it, and moves on. This is
|
|
// really silly, but seems like the least damaging approach to
|
|
// mitigating the issue.
|
|
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
$env['HOME'] = $root.'/support/empty/';
|
|
|
|
if ($this->isAnySSHProtocol()) {
|
|
$env['GIT_SSH'] = $this->getSSHWrapper();
|
|
}
|
|
|
|
return $env;
|
|
}
|
|
|
|
}
|