revert() 공개 메소드

Reverts a single commit. If there is a conflict, aborts the revert and returns false.
public revert ( $commitHash ) : boolean
$commitHash
리턴 boolean True if it succeeded, false if there was a conflict
예제 #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();
 }
예제 #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;
 }