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

Inconsistent error when two prefixed and annotated tags point to the same commit #643

Open
jfleck1 opened this issue May 23, 2022 · 1 comment

Comments

@jfleck1
Copy link

jfleck1 commented May 23, 2022

Setup:
Gradle with Kotlin DSL and multiple subprojects, each with independent versioning

Symptom:
When running a build, either in the command line or within IntelliJ, this error occurs:

Inconsistent git describe: native was library@0.0.14-3-g05e75f8 and jgit was 05e75f8.

This occurred when a single commit addresses issues in multiple gradle subprojects within the same git repository. This causes prefixed release tags for each subproject to be added to the same commit.

After stepping through the code, I found that the RefWithTagNameComparator wasn't comparing the tags correctly.

public int compare(RefWithTagName tag1, RefWithTagName tag2) {

The comparator then causes the incorrect ref to be added, or none at all, when trying to use updateCommitHashMap.

Because updateCommitHashMap fails to add the commit to the map, commitHashToTag doesn't contain the correct tag.

Map<String, RefWithTagName> commitHashToTag = mapCommitsToTags(git);

Solution Idea
Possibly refactor how the commit hash to tag loading works so that the full tag name is used instead. Because multiple tags can point to the same commit hash, it makes sense to use the full /ref/tags listing since that is the unique listing.

Workaround:
Avoid releasing and adding two tags to the same commit. In a multiple project structure, this makes sense... in a way. One subproject's fixes and commits should be independent of the other subproject's. Write more succinct and focused commits, one per subproject.

@apanloco
Copy link

apanloco commented Jun 8, 2023

I had this error and just tested the new 3.0.0 release, and can confirm that this issue is actually fixed now!

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

No branches or pull requests

2 participants