private CommitMessage Parse() { // Reset parser Reset(); // Parse Header var header = HeaderParser.Parse(MatchToken(LineTokenKind.Line)); // Parse Body IReadOnlyList <string> body = Array.Empty <string>(); if (!TestToken(LineTokenKind.Eof)) { body = ParseBody(); } // Parse Footer(s) IReadOnlyList <CommitMessageFooter> footers = Array.Empty <CommitMessageFooter>(); if (!TestToken(LineTokenKind.Eof)) { footers = ParseFooters(); } // Consume all trailing blank lines (ignored unless in strict mode) if (m_Mode.HasFlag(ParserMode.IgnoreTrailingBlankLines)) { MatchTokens(LineTokenKind.Blank, 0); } // a single trailing blank line is always allowed (message typically ends with line break) TestAndMatchToken(LineTokenKind.Blank, out _); // Ensure all tokens were parsed MatchToken(LineTokenKind.Eof); return(new CommitMessage(header, body, footers)); }
public static CommitMessageHeader Parse(LineToken input) { var parser = new HeaderParser(input); return(parser.Parse()); }