mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
Improve compatibility of "arc patch" on Windows
Summary: Can't use (cd ...) on windows. Test Plan: Ran "arc patch" successfully. Reviewers: Makinde, btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T124, T1034 Differential Revision: https://secure.phabricator.com/D1987
This commit is contained in:
parent
1acbe76cbf
commit
4ca58d1129
2 changed files with 26 additions and 25 deletions
|
@ -97,9 +97,10 @@ abstract class ArcanistRepositoryAPI {
|
|||
|
||||
public function getPath($to_file = null) {
|
||||
if ($to_file !== null) {
|
||||
return $this->path.'/'.ltrim($to_file, '/');
|
||||
return $this->path.DIRECTORY_SEPARATOR.
|
||||
ltrim($to_file, DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
return $this->path.'/';
|
||||
return $this->path.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +202,11 @@ abstract class ArcanistRepositoryAPI {
|
|||
return $this->buildLocalFuture($args)->resolve();
|
||||
}
|
||||
|
||||
public function execFutureLocal($pattern /*, ... */) {
|
||||
$args = func_get_args();
|
||||
return $this->buildLocalFuture($args);
|
||||
}
|
||||
|
||||
abstract protected function buildLocalFuture(array $argv);
|
||||
|
||||
}
|
||||
|
|
|
@ -233,11 +233,9 @@ EOTEXT
|
|||
foreach ($suffixes as $suffix) {
|
||||
$proposed_name = $base_name.$suffix;
|
||||
|
||||
list($err) = exec_manual(
|
||||
'(cd %s; git rev-parse --verify %s)',
|
||||
$repository_api->getPath(),
|
||||
$proposed_name
|
||||
);
|
||||
list($err) = $repository_api->execManualLocal(
|
||||
'rev-parse --verify %s',
|
||||
$proposed_name);
|
||||
|
||||
// no error means git rev-parse found a branch
|
||||
if (!$err) {
|
||||
|
@ -273,21 +271,18 @@ EOTEXT
|
|||
// NOTE: Use 'cat-file', not 'rev-parse --verify', because 'rev-parse'
|
||||
// always "verifies" any properly-formatted commit even if it does not
|
||||
// exist.
|
||||
list($err) = exec_manual(
|
||||
'(cd %s; git cat-file -t %s)',
|
||||
$repository_api->getPath(),
|
||||
list($err) = $repository_api->execManualLocal(
|
||||
'cat-file -t %s',
|
||||
$base_revision);
|
||||
|
||||
if ($base_revision && !$err) {
|
||||
execx(
|
||||
'(cd %s; git checkout -b %s %s)',
|
||||
$repository_api->getPath(),
|
||||
$repository_api->execxLocal(
|
||||
'checkout -b %s %s',
|
||||
$branch_name,
|
||||
$base_revision);
|
||||
} else {
|
||||
execx(
|
||||
'(cd %s; git checkout -b %s)',
|
||||
$repository_api->getPath(),
|
||||
$repository_api->execxLocal(
|
||||
'checkout -b %s',
|
||||
$branch_name);
|
||||
}
|
||||
|
||||
|
@ -481,6 +476,9 @@ EOTEXT
|
|||
$this->createParentDirectoryOf($add);
|
||||
}
|
||||
|
||||
// TODO: The SVN patch workflow likely does not work on windows because
|
||||
// of the (cd ...) stuff.
|
||||
|
||||
foreach ($copies as $copy) {
|
||||
list($src, $dst) = $copy;
|
||||
passthru(
|
||||
|
@ -580,17 +578,15 @@ EOTEXT
|
|||
|
||||
return $patch_err;
|
||||
} else if ($repository_api instanceof ArcanistGitAPI) {
|
||||
$future = new ExecFuture(
|
||||
'(cd %s; git apply --index --reject)',
|
||||
$repository_api->getPath());
|
||||
$future = $repository_api->execFutureLocal(
|
||||
'apply --index --reject');
|
||||
$future->write($bundle->toGitPatch());
|
||||
$future->resolvex();
|
||||
|
||||
if ($this->shouldCommit()) {
|
||||
$commit_message = $this->getCommitMessage($bundle);
|
||||
$future = new ExecFuture(
|
||||
'(cd %s; git commit -a -F -)',
|
||||
$repository_api->getPath());
|
||||
$future = $repository_api->execFutureLocal(
|
||||
'commit -a -F -');
|
||||
$future->write($commit_message);
|
||||
$future->resolvex();
|
||||
$verb = 'committed';
|
||||
|
@ -600,9 +596,8 @@ EOTEXT
|
|||
echo phutil_console_format(
|
||||
"<bg:green>** OKAY **</bg> Successfully {$verb} patch.\n");
|
||||
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
||||
$future = new ExecFuture(
|
||||
'(cd %s; hg import --no-commit -)',
|
||||
$repository_api->getPath());
|
||||
$future = $repository_api->execFutureLocal(
|
||||
'import --no-commit -');
|
||||
$future->write($bundle->toGitPatch());
|
||||
$future->resolvex();
|
||||
|
||||
|
|
Loading…
Reference in a new issue