Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed merge commits detection #136

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: fixed merge commits detection
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.
CallumKerson committed Aug 16, 2024
commit f73adf77b5c1ae525705ebb66e24f251fcc8445b
5 changes: 4 additions & 1 deletion git/commits.go
Original file line number Diff line number Diff line change
@@ -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
}