Skip to content

Version prediction from git repository (commit count) broken after merge of branch. #6

@needleshaped

Description

@needleshaped

Symptom: version prediction always results in 0.1.0.dev0 for ALL commits past merge commit 835e59c Merge branch 'develop' of gitlab.......-service into develop

git log --oneline --all --graph --decorate

* 1af294c (origin/develop, origin/HEAD) TEST: commit to test version.py
* ad8ab2d ...
* bcacad2 ...
*   835e59c  Merge branch 'develop' of gitlab.......-service into develop
|\  
| *   637e04c Merge branch 'feature/...' into 'develop'
| |\  
| | * b0361e8 ...
| |/  
* / 70b3501 ...
|/  
* 2774dc1 ...
...
(commits both in develop and feature/... branch)
...
| * 5ab611f (feature/...) FIX: ...
| * 5809732 FIX: ...
| * 5403ba6 REFACTORING: ...
| * 130a286 REFACTORING: ...
|/  

There are no GIT tags in directory.
Versioning is used to generate version with commit number only for CI: print(predict_version_str().split('+')[0]), resulting in e.g. 0.1.0.dev88 (from 0.1.0.dev88+2774dc19)

Example of LOGGING_LEVEL=debug on problematic merge commit:

⚓ 835e59c
LOGGING_LEVEL=debug python -m version_query -p .
DEBUG:version_query.version:version_query parsed version string '0.1.0.dev0' into <class 're.Match'>: {'release': '0.1.0', 'prerelease': '.dev0', 'local': None} ('0.1.0', '.dev0', None, None)
DEBUG:version_query.version:parsed pre-release string '.dev0' into ['.dev0']
DEBUG:version_query.version:version_query parsed version string '0.1.0.dev0' into <class 're.Match'>: {'release': '0.1.0', 'prerelease': '.dev0', 'local': None} ('0.1.0', '.dev0', None, None)
DEBUG:version_query.version:parsed pre-release string '.dev0' into ['.dev0']
0.1.0.dev0

Workaround: add tag, e.g. git tag v.0.2.0 on ANY commit in history, before, after merge in develop, or within merged branch itself.

Observation: putting tag before merge results in a commits in branch (reached via git checkout ) having it's separate versioning (instead of 2.1)
In this case with simple loop over git up && python -m version_query -p . I can confirm, that counter within branch change

Need to look into code and GIT structure/behavior to understand, what went wrong. It seems version-query can't traverse history with a merge back, and always assumes commit 0.
Any additional information I can supply to help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions