Skip to content

Commit

Permalink
correctly set commit and diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Feb 9, 2024
1 parent 1475990 commit 3962c61
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/gitparse/gitparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, diffChan chan
latestState = CommitLine

// If there is a currentDiff, add it to currentCommit.
if currentDiff.Commit.Hash != "" || currentDiff.IsBinary {
if currentDiff.Commit != nil && currentDiff.Commit.Hash != "" || currentDiff.IsBinary {
if err := currentDiff.finalize(); err != nil {
ctx.Logger().Error(
err,
Expand Down Expand Up @@ -433,9 +433,6 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, diffChan chan
latestState = DiffLine

// This should never be nil, but check in case the stdin stream is messed up.
if currentCommit == nil {
currentCommit = &Commit{}
}
if currentDiff.Commit.Hash != "" || currentDiff.IsBinary {
if err := currentDiff.finalize(); err != nil {
ctx.Logger().Error(err,
Expand All @@ -448,6 +445,9 @@ func (c *Parser) FromReader(ctx context.Context, stdOut io.Reader, diffChan chan
}
diffChan <- currentDiff
}
if currentCommit == nil {
currentCommit = &Commit{}
}
currentDiff = diff(currentCommit)
case isModeLine(latestState, line):
latestState = ModeLine
Expand Down

0 comments on commit 3962c61

Please sign in to comment.