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.
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); }
public static function buildFromCommitMessage(CommitMessage $commitMessage) { $tags = $commitMessage->getVersionPressTags(); $actionTag = $tags[TrackedChangeInfo::ACTION_TAG]; list(, , $version) = explode("/", $actionTag, 3); return new self($version); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
/** * 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"); }
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); }
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); }
private static function extractTag($tag, $commitMessageBody) { $tmpMessage = new CommitMessage("", $commitMessageBody); return $tmpMessage->getVersionPressTag($tag); }
public function getChangeDescription() { return $this->commitMessage->getSubject(); }
private static function extractVersion($lastBody) { $tmpMessage = new CommitMessage("", $lastBody); $version = $tmpMessage->getVersionPressTag(self::VP_VERSION_TAG); return $version; }