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

Conversation

CallumKerson
Copy link
Contributor

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.

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 CallumKerson requested a review from a team August 16, 2024 13:14
@CallumKerson
Copy link
Contributor Author

This can be demonstrated with this repo: https://github.com/CallumKerson/test-git-history.
When using the current version:

$ get-next-version --target json                                   
{"version": "0.1.0", "hasNextVersion": false}

With the changes in this branch, then the output changes to correctly bump the version:

$ get-next-version --target json                                   
{"version": "0.2.0", "hasNextVersion": true}

@goloroden
Copy link
Member

@CallumKerson Thanks for submitting this PR, we are going to merge this and release a new version.

@goloroden goloroden merged commit c96e658 into thenativeweb:main Aug 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants