PHP Class VersionPress\Git\CommitMessage

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
Show file Open project: versionpress/versionpress Class Usage Examples

Public Methods

Method Description
__construct ( string $subject, string $body = null )
getBody ( ) : string Rest of the commit message (all text except the subject). Usually just the VP tags but body might also contain some other information.
getSubject ( ) : string The first line of the commit message. Short description of the change
getUnprefixedSubject ( ) : string Returns commit message subject without prefix set in constant VERSIONPRESS_COMMIT_MESSAGE_PREFIX
getVersionPressTag ( $tagName ) : string Returns VP tag with given name, or an empty string if no tag of given name is found.
getVersionPressTags ( ) : array Returns all VP tags in an associative array. VP tags are identified as separate lines in the commit body that start with the "VP-" prefix.

Method Details

__construct() public method

public __construct ( string $subject, string $body = null )
$subject string First line of the commit message
$body string Optional, lines 3..n

getBody() public method

Rest of the commit message (all text except the subject). Usually just the VP tags but body might also contain some other information.
public getBody ( ) : string
return string

getSubject() public method

The first line of the commit message. Short description of the change
public getSubject ( ) : string
return string

getUnprefixedSubject() public method

Returns commit message subject without prefix set in constant VERSIONPRESS_COMMIT_MESSAGE_PREFIX
public getUnprefixedSubject ( ) : string
return string

getVersionPressTag() public method

Returns VP tag with given name, or an empty string if no tag of given name is found.
public getVersionPressTag ( $tagName ) : string
$tagName
return string

getVersionPressTags() public method

Returns all VP tags in an associative array. VP tags are identified as separate lines in the commit body that start with the "VP-" prefix.
public getVersionPressTags ( ) : array
return array Array of tagName => value (trimmed)