Skip to content

Commit

Permalink
fix: fixed merge commits detection (#136)
Browse files Browse the repository at this point in the history
When searching for commits, `go-git` uses depth-first search by default.
In cases where commits are brought in via a merge commit, the commits
other than the merge commit itself will be missed, as the DFS will go
down the commits directly from HEAD, and will exit upon finding the previous
tag, before then searching other paths. This is fixed by using the sort
orders `LogOrderCommitterTime` or `LogOrderBSF`. Here `LogOrderCommitterTime`
was used as the `go-git` documentation says it has the highest compatibility
with the `git log` CLI command.
  • Loading branch information
CallumKerson authored Aug 16, 2024
1 parent 20104ac commit c96e658
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion git/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func GetConventionalCommitTypesSinceLastRelease(repository *git.Repository) (Con
}
return ConventionalCommmitTypesResult{}, err
}
commitIterator, err := repository.Log(&git.LogOptions{From: head.Hash()})
commitIterator, err := repository.Log(&git.LogOptions{
From: head.Hash(),
Order: git.LogOrderCommitterTime,
})
if err != nil {
return ConventionalCommmitTypesResult{}, err
}
Expand Down

0 comments on commit c96e658

Please sign in to comment.