From 1fc01e08f0dc16b2fcb2ee750fac59e246626e9f Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Thu, 1 Nov 2018 09:32:43 -0500 Subject: [PATCH] Fixed rollback bug in GitPreparer Added a guard to GitPreparer::unsetVcsInProgress() to prevent doing a `git reset` when there are no test locks present. Otherwise, the uncommitted changes in the app will be removed by the shutdown feature introduced in 952c6e5890daa36236be675d8c4f21cecabc1fe7. --- lib/preparers/GitPreparer.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/preparers/GitPreparer.php b/lib/preparers/GitPreparer.php index cce2fb1a2..2282a797e 100644 --- a/lib/preparers/GitPreparer.php +++ b/lib/preparers/GitPreparer.php @@ -7,11 +7,13 @@ class GitPreparer implements Preparer public function snapshot() { + $this->debug('Snapshot requested'); return $this->setVcsInProgress(); } public function rollback() { + $this->debug('Rollback requested'); return $this->unsetVcsInProgress(); } @@ -88,6 +90,12 @@ class GitPreparer implements Preparer protected function unsetVcsInProgress() { + if (!$this->isVcsInProgress()) + { + $this->debug('No test locks found'); + return; + } + $this->debug('Rolling back Git repo to pre-test stateā€¦'); $this->runCommand('git reset --hard HEAD'); $this->runCommand('git clean -fdx');