1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 08:52:39 +01:00

Check for cleanWorkingCopy in sanityCheck, and execute sanityCheck first

Summary:
  - Renamed sanityCheckPatch to sanityCheck
  - Move check for clean working copy into sanityCheck
  - Execute sanityCheck before executing any other command

Test Plan:
  - Run ##arc patch <revision id>## from a dirty working copy
and verify that a usage exception is thrown before the new branch is
created.
  - Run ##arc patch <revision id> --force## and verify that it attempts
    to create a new branch, apply, and commit the patch.
  - Then clean your working copy and verify that ##arc patch <revision
    id> works as expected

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T830, T479

Differential Revision: https://secure.phabricator.com/D1546
This commit is contained in:
Kevin Deggelman 2012-02-03 14:04:41 -08:00 committed by epriestley
parent 85083db929
commit c44e8d57a2

View file

@ -232,7 +232,7 @@ EOTEXT
// no error means git rev-parse found a branch // no error means git rev-parse found a branch
if (!$err) { if (!$err) {
echo phutil_console_format( echo phutil_console_format(
"Branch name {$proposed_name} alread exists; trying a new name.\n" "Branch name {$proposed_name} already exists; trying a new name.\n"
); );
continue; continue;
} else { } else {
@ -354,6 +354,12 @@ EOTEXT
throw $ex; throw $ex;
} }
} }
$force = $this->getArgument('force', false);
if ($force) {
// force means don't do any sanity checks about the patch
} else {
$this->sanityCheck($bundle);
}
// we should update the working copy before we do ANYTHING else // we should update the working copy before we do ANYTHING else
if ($this->shouldUpdateWorkingCopy()) { if ($this->shouldUpdateWorkingCopy()) {
@ -364,13 +370,6 @@ EOTEXT
$this->createBranch($bundle); $this->createBranch($bundle);
} }
$force = $this->getArgument('force', false);
if ($force) {
// force means don't do any sanity checks about the patch
} else {
$this->sanityCheckPatch($bundle);
}
$repository_api = $this->getRepositoryAPI(); $repository_api = $this->getRepositoryAPI();
if ($repository_api instanceof ArcanistSubversionAPI) { if ($repository_api instanceof ArcanistSubversionAPI) {
$patch_err = 0; $patch_err = 0;
@ -570,12 +569,6 @@ EOTEXT
return $patch_err; return $patch_err;
} else if ($repository_api instanceof ArcanistGitAPI) { } else if ($repository_api instanceof ArcanistGitAPI) {
// if we're going to commit, we should make sure the working copy
// is clean
if ($this->shouldCommit()) {
$this->requireCleanWorkingCopy();
}
$future = new ExecFuture( $future = new ExecFuture(
'(cd %s; git apply --index --reject)', '(cd %s; git apply --index --reject)',
$repository_api->getPath()); $repository_api->getPath());
@ -663,7 +656,10 @@ EOTEXT
/** /**
* Do the best we can to prevent PEBKAC and id10t issues. * Do the best we can to prevent PEBKAC and id10t issues.
*/ */
private function sanityCheckPatch(ArcanistBundle $bundle) { private function sanityCheck(ArcanistBundle $bundle) {
// Require clean working copy
$this->requireCleanWorkingCopy();
// Check to see if the bundle's project id matches the working copy // Check to see if the bundle's project id matches the working copy
// project id // project id