Skip to content

Commit c96e658

Browse files
authored
fix: fixed merge commits detection (#136)
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.
1 parent 20104ac commit c96e658

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

git/commits.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ func GetConventionalCommitTypesSinceLastRelease(repository *git.Repository) (Con
2929
}
3030
return ConventionalCommmitTypesResult{}, err
3131
}
32-
commitIterator, err := repository.Log(&git.LogOptions{From: head.Hash()})
32+
commitIterator, err := repository.Log(&git.LogOptions{
33+
From: head.Hash(),
34+
Order: git.LogOrderCommitterTime,
35+
})
3336
if err != nil {
3437
return ConventionalCommmitTypesResult{}, err
3538
}

0 commit comments

Comments
 (0)