Note about the "[VP]" prefix: this class just doesn't care. When the commit is first created, external code will typically put prefix-less subject into this object. Only when {@link VersionPress\Git\GitRepository::commit()} executes the commit itself will get the [VP] prefix. On the other hand, when the commit is read from the repository and parsed back into this object, it will typically have the [VP] prefix. It doesn't matter as VersionPress typically only works with the commit body and its VP tags.
See also: Commit Represents the whole commit
コード例 #1
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $actionTag = $commitMessage->getVersionPressTag(TrackedChangeInfo::ACTION_TAG);
     $themeName = $commitMessage->getVersionPressTag(self::THEME_NAME_TAG);
     list(, $action, $themeId) = explode("/", $actionTag, 3);
     return new self($themeId, $action, $themeName);
 }
コード例 #2
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     list(, , $version) = explode("/", $actionTag, 3);
     return new self($version);
 }
コード例 #3
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $actionTag = $commitMessage->getVersionPressTag(TrackedChangeInfo::ACTION_TAG);
     $pluginName = $commitMessage->getVersionPressTag(self::PLUGIN_NAME_TAG);
     list(, $action, $pluginFile) = explode("/", $actionTag, 3);
     return new self($pluginFile, $action, $pluginName);
 }
コード例 #4
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     $userLogin = $tags[self::USER_LOGIN];
     list(, $action, $entityId) = explode("/", $actionTag);
     return new self($action, $entityId, $userLogin);
 }
コード例 #5
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     $commentAuthor = $tags[self::AUTHOR_TAG];
     $commentedPost = $tags[self::POST_TITLE_TAG];
     list(, $action, $entityId) = explode("/", $actionTag, 3);
     return new self($action, $entityId, $commentAuthor, $commentedPost);
 }
コード例 #6
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     list(, $action, $entityId) = explode("/", $actionTag, 3);
     $termName = $tags[self::TERM_NAME_TAG];
     $taxonomy = $tags[self::TAXONOMY_TAG];
     return new self($action, $entityId, $taxonomy, $termName);
 }
コード例 #7
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     list(, $action, $entityId) = explode("/", $actionTag, 3);
     $termName = isset($tags[self::TERM_NAME_TAG]) ? $tags[self::TERM_NAME_TAG] : $entityId;
     $metaKey = $tags[self::TERM_META_KEY];
     $termVpid = $tags[self::TERM_VPID_TAG];
     return new self($action, $entityId, $termName, $termVpid, $metaKey);
 }
コード例 #8
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     list(, $action, $entityId) = explode("/", $actionTag, 3);
     $titleTag = isset($tags[self::POST_TITLE_TAG]) ? $tags[self::POST_TITLE_TAG] : $entityId;
     $type = isset($tags[self::POST_TYPE_TAG]) ? $tags[self::POST_TYPE_TAG] : "post";
     $updatedProperties = isset($tags[self::POST_UPDATED_PROPERTIES_TAG]) ? explode(",", $tags[self::POST_UPDATED_PROPERTIES_TAG]) : array();
     return new self($action, $entityId, $type, $titleTag, $updatedProperties);
 }
コード例 #9
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $tags = $commitMessage->getVersionPressTags();
     $actionTag = $tags[TrackedChangeInfo::ACTION_TAG];
     list(, $action, $entityId) = explode("/", $actionTag, 3);
     $titleTag = isset($tags[self::POST_TITLE_TAG]) ? $tags[self::POST_TITLE_TAG] : $entityId;
     $type = $tags[self::POST_TYPE_TAG];
     $metaKey = $tags[self::POST_META_KEY];
     $postVpId = $tags[self::POST_VPID_TAG];
     return new self($action, $entityId, $type, $titleTag, $postVpId, $metaKey);
 }
コード例 #10
0
 /**
  * Returns matching ChangeInfo type for a given commit message. Matching is done based on the value of the VP-Action tag.
  *
  * @param CommitMessage $commitMessage
  * @throws Exception When no matching ChangeInfo type is found (should never happen)
  * @return string "Class" of the matching ChangeInfo object
  */
 public static function findMatchingChangeInfo(CommitMessage $commitMessage)
 {
     if (substr_count($commitMessage->getBody(), TrackedChangeInfo::ACTION_TAG) > 1) {
         return "VersionPress\\ChangeInfos\\ChangeInfoEnvelope";
     }
     $actionTagValue = $commitMessage->getVersionPressTag(TrackedChangeInfo::ACTION_TAG);
     // can be empty string which is not a problem
     foreach (self::$changeInfoMap as $actionTagExpression => $changeInfoType) {
         $regex = "~^" . $actionTagExpression . "\$~";
         if (preg_match($regex, $actionTagValue)) {
             return $changeInfoType;
         }
     }
     // Code execution should never reach this point, at least the 'UntrackedChangeInfo' should match
     throw new Exception("Matching ChangeInfo type not found");
 }
コード例 #11
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $actionTag = $commitMessage->getVersionPressTag(TrackedChangeInfo::ACTION_TAG);
     $languageCode = $commitMessage->getVersionPressTag(self::LANGUAGE_CODE_TAG);
     $languageName = $commitMessage->getVersionPressTag(self::LANGUAGE_NAME_TAG);
     $type = $commitMessage->getVersionPressTag(self::TRANSLATION_TYPE_TAG);
     $name = $commitMessage->getVersionPressTag(self::TRANSLATION_NAME_TAG);
     list(, $action) = explode("/", $actionTag, 2);
     return new self($action, $languageCode, $languageName, $type, $name);
 }
コード例 #12
0
 public static function buildFromCommitMessage(CommitMessage $commitMessage)
 {
     $actionTag = $commitMessage->getVersionPressTag(TrackedChangeInfo::ACTION_TAG);
     list(, $action, $versionPressVersion) = array_pad(explode("/", $actionTag, 3), 3, "");
     return new self($action, $versionPressVersion);
 }
コード例 #13
0
 private static function extractTag($tag, $commitMessageBody)
 {
     $tmpMessage = new CommitMessage("", $commitMessageBody);
     return $tmpMessage->getVersionPressTag($tag);
 }
コード例 #14
0
 public function getChangeDescription()
 {
     return $this->commitMessage->getSubject();
 }
コード例 #15
0
 private static function extractVersion($lastBody)
 {
     $tmpMessage = new CommitMessage("", $lastBody);
     $version = $tmpMessage->getVersionPressTag(self::VP_VERSION_TAG);
     return $version;
 }