getCommit() 공개 메소드

Gets commit object based on its hash
public getCommit ( $commitHash ) : Commit
$commitHash
리턴 Commit
예제 #1
0
 private function convertChangeInfo($changeInfo)
 {
     if ($changeInfo instanceof UntrackedChangeInfo) {
         return null;
     }
     /** @var TrackedChangeInfo $changeInfo */
     $change = ['type' => $changeInfo->getScope(), 'action' => $changeInfo->getAction(), 'tags' => $changeInfo->getCustomTags()];
     if ($changeInfo instanceof EntityChangeInfo) {
         $change['name'] = $changeInfo->getId();
     }
     if ($changeInfo->getScope() === 'plugin') {
         $pluginTags = $changeInfo->getCustomTags();
         $pluginName = $pluginTags['VP-Plugin-Name'];
         $change['name'] = $pluginName;
     }
     if ($changeInfo->getScope() === 'theme') {
         $themeTags = $changeInfo->getCustomTags();
         $themeName = $themeTags['VP-Theme-Name'];
         $change['name'] = $themeName;
     }
     if ($changeInfo->getScope() === 'wordpress') {
         $change['name'] = $changeInfo->getId();
     }
     if ($changeInfo->getScope() === 'versionpress' && ($changeInfo->getAction() === 'undo' || $changeInfo->getAction() === 'rollback')) {
         $commit = $this->gitRepository->getCommit($changeInfo->getId());
         $change['tags']['VP-Commit-Details'] = ['message' => $commit->getMessage()->getUnprefixedSubject(), 'date' => $commit->getDate()->format(\DateTime::ISO8601)];
     }
     return $change;
 }
예제 #2
0
 private function convertChangeInfo($changeInfo)
 {
     $change = array();
     if ($changeInfo instanceof TrackedChangeInfo) {
         $change['type'] = $changeInfo->getEntityName();
         $change['action'] = $changeInfo->getAction();
         $change['tags'] = $changeInfo->getCustomTags();
     }
     if ($changeInfo instanceof EntityChangeInfo) {
         $change['name'] = $changeInfo->getEntityId();
     }
     if ($changeInfo instanceof PluginChangeInfo) {
         $pluginTags = $changeInfo->getCustomTags();
         $pluginName = $pluginTags[PluginChangeInfo::PLUGIN_NAME_TAG];
         $change['name'] = $pluginName;
     }
     if ($changeInfo instanceof ThemeChangeInfo) {
         $themeTags = $changeInfo->getCustomTags();
         $themeName = $themeTags[ThemeChangeInfo::THEME_NAME_TAG];
         $change['name'] = $themeName;
     }
     if ($changeInfo instanceof WordPressUpdateChangeInfo) {
         $change['name'] = $changeInfo->getNewVersion();
     }
     if ($changeInfo instanceof RevertChangeInfo) {
         $commit = $this->gitRepository->getCommit($changeInfo->getCommitHash());
         $change['tags']['VP-Commit-Details'] = array('message' => $commit->getMessage()->getSubject(), 'date' => $commit->getDate()->format(\DateTime::ISO8601));
     }
     return $change;
 }
예제 #3
0
 /**
  * Create CommitAsserter to start tracking the git repo for future asserts. Should generally
  * be called after a test setup (if there is any) and before all the actual work. Asserts follow
  * after it.
  *
  * @param \VersionPress\Git\GitRepository $gitRepository
  * @param DbSchemaInfo $dbSchema
  * @param ActionsInfoProvider $actionsInfoProvider
  * @param string[] $pathPlaceholders
  */
 public function __construct($gitRepository, DbSchemaInfo $dbSchema, ActionsInfoProvider $actionsInfoProvider, $pathPlaceholders = [])
 {
     $this->gitRepository = $gitRepository;
     $this->pathPlaceholders = $pathPlaceholders;
     $this->dbSchema = $dbSchema;
     $this->actionsInfoProvider = $actionsInfoProvider;
     if ($gitRepository->isVersioned()) {
         $this->startCommit = $gitRepository->getCommit($gitRepository->getLastCommitHash());
     }
 }
예제 #4
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;
 }