-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ade5d91
commit 884fcdb
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ type ParseState int | |
const ( | ||
Initial ParseState = iota | ||
CommitLine | ||
MergeLine | ||
AuthorLine | ||
DateLine | ||
MessageStartLine | ||
|
@@ -76,6 +77,7 @@ func (state ParseState) String() string { | |
return [...]string{ | ||
"Initial", | ||
"CommitLine", | ||
"MergeLine", | ||
"AuthorLine", | ||
"DateLine", | ||
"MessageStartLine", | ||
|
@@ -276,6 +278,8 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, commitChan ch | |
if len(line) >= 47 { | ||
currentCommit.Hash = string(line[7:47]) | ||
} | ||
case isMergeLine(isStaged, latestState, line): | ||
latestState = MergeLine | ||
case isAuthorLine(isStaged, latestState, line): | ||
latestState = AuthorLine | ||
|
||
|
@@ -428,6 +432,16 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, commitChan ch | |
ctx.Logger().V(2).Info("finished parsing git log.", "total_log_size", totalLogSize) | ||
} | ||
|
||
func isMergeLine(isStaged bool, latestState ParseState, line []byte) bool { | ||
if isStaged || latestState != CommitLine { | ||
return false | ||
} | ||
if len(line) > 6 && bytes.Equal(line[:6], []byte("Merge:")) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// commit 7a95bbf0199e280a0e42dbb1d1a3f56cdd0f6e05 | ||
func isCommitLine(isStaged bool, latestState ParseState, line []byte) bool { | ||
if isStaged || !(latestState == Initial || | ||
|
@@ -450,7 +464,7 @@ func isCommitLine(isStaged bool, latestState ParseState, line []byte) bool { | |
|
||
// Author: Bill Rich <[email protected]> | ||
func isAuthorLine(isStaged bool, latestState ParseState, line []byte) bool { | ||
if isStaged || !(latestState == CommitLine) { | ||
if isStaged || !(latestState == CommitLine || latestState == MergeLine) { | ||
return false | ||
} | ||
if len(line) > 8 && bytes.Equal(line[:7], []byte("Author:")) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters