Arbit - project tracking

Arbit - project tracking

API documentation :: Docs For Class arbitCommitMessageParser

Core::arbitCommitMessageParser

Class arbitCommitMessageParser

Arbit parser for arbit commit messages defined by the following grammar:

  1.   Message       ::= Statement+ | Statement* Comment+
  2.   Statement     ::= Reference | Fixed | Implemented | Documented | Tested
  3.                   | Added | Translated
  4.  
  5.   Comment       ::= '# ' TextLine | '#\n'
  6.  
  7.   Reference     ::= '- Refs'         BugNr  ': ' TextLine Text?
  8.   Fixed         ::= '- ' FixedString BugNr  ': ' TextLine Text?
  9.   Implemented   ::= '- Implemented'  BugNr? ': ' TextLine Text?
  10.   Documented    ::= '- Documented'   BugNr? ': ' TextLine Text?
  11.   Tested        ::= '- Tested: '                 TextLine Text?
  12.   Added         ::= '- Added: '                  TextLine Text?
  13.   Translated    ::= '- Translated: '             TextLine Text?
  14.  
  15.   FixedString   ::= 'Fixed' | 'Closed'
  16.  
  17.   Text          ::= '  ' TextLine Text?
  18.   BugNr         ::= ' #' [1-9]+[0-9]*
  19.   TextLine      ::= [\x20-\x7E]+ "\n"
With one additional condition not mentioned in the grammar, that no line should ever exceed 79 characters per line.

Arbit parser for arbit commit messages defined by the following grammar:

  1.   Message       ::= Statement+ | Statement* Comment+
  2.   Statement     ::= Reference | Fixed | Implemented | Documented | Tested
  3.                   | Added | Translated
  4.  
  5.   Comment       ::= '# ' TextLine | '#\n'
  6.  
  7.   Reference     ::= '- Refs'         BugNr  ': ' TextLine Text?
  8.   Fixed         ::= '- ' FixedString BugNr  ': ' TextLine Text?
  9.   Implemented   ::= '- Implemented'  BugNr? ': ' TextLine Text?
  10.   Documented    ::= '- Documented'   BugNr? ': ' TextLine Text?
  11.   Tested        ::= '- Tested: '                 TextLine Text?
  12.   Added         ::= '- Added: '                  TextLine Text?
  13.   Translated    ::= '- Translated: '             TextLine Text?
  14.  
  15.   FixedString   ::= 'Fixed' | 'Closed'
  16.  
  17.   Text          ::= '  ' TextLine Text?
  18.   BugNr         ::= ' #' [1-9]+[0-9]*
  19.   TextLine      ::= [\x20-\x7E]+ "\n"
With one additional condition not mentioned in the grammar, that no line should ever exceed 79 characters per line. A textual description of the rules above:
  1.   All messages should wrap at 79 characters per line. This means, if you are
  2.   writing multiple lines after a message starting with a "- " each following
  3.   line should be indented by exactly two spaces.
  4.  
  5.   Including descriptive text in your commit messages is generally important to
  6.   offer a good overview on the commit when the issue tracker is not available
  7.   (commit mails, history).
  8.  
  9.   All messages may include references to existing issues to add status updates
  10.   to the issue, which should look like::
  11.  
  12.       - Refs #<number>: <text>
  13.  
  14.   Where <number> references the ticket and the <text> describes what you did.
  15.  
  16.   Comments
  17.   --------
  18.  
  19.   You may always append arbitrary comments in your commit messages, where each
  20.   line should start with a number sign (#). Text in these lines won't be
  21.   checked.
  22.  
  23.   Bug fix
  24.   -------
  25.  
  26.   A bug fix commit message should follow the following scheme::
  27.  
  28.       - Fixed #<number>: <text>
  29.  
  30.   Where <number> references the closed bug and <text> is a description of the
  31.   bug and the fix. Keep in mind that the texts will be used for the changelog,
  32.   so please check the spelling before committing.
  33.  
  34.   The bug number is not optional, which means that there should be an open bug
  35.   in the issue tracker for *each* bug you fix.
  36.  
  37.   For compatibility with other issue tracker you may also use "Closed" instead
  38.   of "Fixed" in your message, but "Fixed" is highly preferred.
  39.  
  40.   New features
  41.   ------------
  42.  
  43.   If you implemented a new feature, your commit message should look like::
  44.  
  45.       - Implemented[ #<number>]: <text>
  46.  
  47.   Where <text> is a short description of the feature you implemented, and
  48.   <number> may optionally reference a feature request in the bug tracker. Keep
  49.   in mind that the texts will be used for the changelog, so please check the
  50.   spelling before committing.
  51.  
  52.   Documentation
  53.   -------------
  54.  
  55.   If you extended your documentation, your commit message should look like::
  56.  
  57.       - Documented[ #<number>]: <text>
  58.  
  59.   Where <number> optionally specifies a documentation request, and the text
  60.   describes what you documented.
  61.  
  62.   Additional tests
  63.   ----------------
  64.  
  65.   If you added tests for some feature, your commit message should look like::
  66.  
  67.       - Tested: <text>
  68.  
  69.   Where <text> describes the feature(s) you are testing.
  70.  
  71.   Other commits
  72.   -------------
  73.  
  74.   If your commit does not match any of the above rules you should only include a
  75.   comment in your commit message or extend this document with your commit
  76.   message of desire.
Even we have a contextfree grammar for the language, we implement the trivial parser using regular expressions.

Author(s):
Version:   $Revision: 1236 $
License:   GPL

Method Summary

public void __construct( )
Construct parser
protected string normalizeWhitespaces( $string )
Normalizes whitespaces in commit message Even not defined in the grammar we do not care about additional newlines or empty lines anywhere.
public array parse( $string )
Parse a commit message Parses a commit messages defined by the grammar documented in the class header. the error message.
protected array parseStatements( $string )
Parse all statements Parse the statemets like defined in the grammar in the class level docblock.
protected string removeComments( $string )
Removes comments from a commit message Removes all valid comments from a commit messages, as they are not of interest for the content extraction.

Methods

__construct

void __construct( )

Construct parser

Construct parser

normalizeWhitespaces

string normalizeWhitespaces( string $string )

Normalizes whitespaces in commit message Even not defined in the grammar we do not care about additional newlines or empty lines anywhere.

Normalizes whitespaces in commit message Even not defined in the grammar we do not care about additional newlines or empty lines anywhere.

Parameters:
Name Type Description
$string string

parse

array parse( string $string )

Parse a commit message Parses a commit messages defined by the grammar documented in the class header. the error message.

Parse a commit message Parses a commit messages defined by the grammar documented in the class header. If a parse error occures an exception will be thrown containing the error message. On a successfull parsing process a struct containing a list with all relevant data will be returned, which looks like:

  1.   array(
  2.       array(
  3.           'type' => <type>,
  4.           'bug'  => <number> | null,
  5.           'text' => <text>,
  6.       ),
  7.       ...
  8.   )

Parameters:
Name Type Description
$string string

parseStatements

array parseStatements( string $string )

Parse all statements Parse the statemets like defined in the grammar in the class level docblock.

Parse all statements Parse the statemets like defined in the grammar in the class level docblock. As a result an array is returned with the following structure:

  1.   array(
  2.       array(
  3.           'type' => <type>,
  4.           'bug'  => <number> | null,
  5.           'text' => <text>,
  6.       ),
  7.       ...
  8.   )
If the commit message could not be parsed a arbitCommitParserException will be thrown.

Parameters:
Name Type Description
$string string

removeComments

string removeComments( string $string )

Removes comments from a commit message Removes all valid comments from a commit messages, as they are not of interest for the content extraction.

Removes comments from a commit message Removes all valid comments from a commit messages, as they are not of interest for the content extraction.

Parameters:
Name Type Description
$string string
Documentation generated on Mon, 05 Apr 2010 14:02:21 +0200 by phpDocumentor 1.4.3