/** * @test */ public function revertCannotTakeBackOverwrittenChanges() { $this->commitFile('some-file', 'Some commit', 'Some content'); $hash = self::$repository->getLastCommitHash(); $this->commitFile('some-file', 'Other commit', 'Other content'); $commitAsserter = $this->createCommitAsserter(); $revertResult = self::$repository->revert($hash); $this->commit('Revert'); $this->assertFalse($revertResult); $commitAsserter->assertNumCommits(0); $commitAsserter->assertCleanWorkingDirectory(); }
private function revertOneCommit($commitHash) { $commit = $this->repository->getCommit($commitHash); if ($commit->isMerge()) { return RevertStatus::REVERTING_MERGE_COMMIT; } if (!$this->repository->revert($commitHash)) { return RevertStatus::MERGE_CONFLICT; } $revertedCommit = $this->repository->getCommit($commitHash); $referencesOk = $this->checkReferencesForRevertedCommit($revertedCommit); if (!$referencesOk) { $this->repository->abortRevert(); return RevertStatus::VIOLATED_REFERENTIAL_INTEGRITY; } return RevertStatus::OK; }