GitVersion
GitVersion copied to clipboard
Do not return the tag as branch name for GitLab CI
In case of a tag pipeline, return null as branch name instead of the tag
Description
For tag pipelines (triggered by tagging a commit), do not return CI_COMMIT_REF_NAME as the current branch because in this case it contains the new tag instead of a branch.
Related Issue
Fixes #4186
Motivation and Context
Bugfix
How Has This Been Tested?
Manually tested the following scenarios on GitLab CI:
- Commit
- Tag
- Branches
- Merge requests
Also ran the tests in the solution.
Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.
Hi there.
What happens:
- when you trigger a tag (pre-release version) from lets say development branch?
- when the tag is on main and merged to development?
Would be good to have some integration tests to cover your scenario.
I think this should cover the Scenarios (label for main branches is "dev")...
Unfortunately at the moment I don't think I'll have the time to find out how to create those automated tests and implement them.
Tag branch master with v1.2.0
"FullSemVer": "1.2.0" "InformationalVersion": "1.2.0+Branch.master.Sha.f638f0ff709f763982676abd6698a678889302a1" (in 6.0.2 this would result in FullSemVer=1.2.1-v1-2-0.1+0)
Create branch development from master
"FullSemVer": "1.2.1-development.1+0" "InformationalVersion": "1.2.1-development.1+0.Branch.development.Sha.f638f0ff709f763982676abd6698a678889302a1" (same as in 6.0.2)
Commit on development
"FullSemVer": "1.2.1-development.1+1" "InformationalVersion": "1.2.1-development.1+1.Branch.development.Sha.c04e043529d8e0809d55e3b1d8b5ea70f4fb7b9a" (same as in 6.0.2)
Tag branch development with v1.3.0
"FullSemVer": "1.3.1-development.1+0" "InformationalVersion": "1.3.1-development.1+0.Branch.development.Sha.c04e043529d8e0809d55e3b1d8b5ea70f4fb7b9a" (in 6.0.2 this would result in FullSemVer=1.3.1-v1-3-0.1+0)
Merge branch development into master
FullSemVer": "1.3.1-dev.1" "InformationalVersion": "1.3.1-dev.1+Branch.master.Sha.ddfcf3381ca1dba1b4ad77f407d4ee1d560e8fc1" (same as in 6.0.2)
Commit on master
"FullSemVer": "1.3.1-dev.2" "InformationalVersion": "1.3.1-dev.2+Branch.master.Sha.c2e373ff0ff90010a835d158b53a9f9d524d4355" (same as in 6.0.2)
Tag branch master with v1.3.1
"FullSemVer": "1.3.1" "InformationalVersion": "1.3.1+Branch.master.Sha.c2e373ff0ff90010a835d158b53a9f9d524d4355" (in 6.0.2 this would result in FullSemVer=1.3.2-v1-3-1.1+0)
Merge branch master into development
"FullSemVer": "1.3.2-development.1+1" "InformationalVersion": "1.3.2-development.1+1.Branch.development.Sha.69092abd47e89cc20688853b0f0fa5523d6e58fa" (same as in 6.0.2)
Is there a plan for merge this fix?
@HHobeck do you think we should get this merged?
Yes, I think it can be merged.
I think it needs tests. I also think we should investigate whether we can implement the same solution for other CI environments as well.
@arturcic I assume you can close this since it was integrated in https://github.com/GitTools/GitVersion/pull/4402 :smiley:
Closing as it was integrated in https://github.com/GitTools/GitVersion/pull/4402
Thanks so much @Bi0T1N :) I'm not sure if I would ever have found the time to learn how to create those tests.