revert() public method

Reverts a single commit. If there is a conflict, aborts the revert and returns false.
public revert ( $commitHash ) : boolean
$commitHash
return boolean True if it succeeded, false if there was a conflict
Exemplo n.º 1
0
 /**
  * @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();
 }
Exemplo n.º 2
0
 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;
 }