Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not return the tag as branch name for GitLab CI #4187

Closed

Conversation

AlphaYankee
Copy link
Contributor

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:

  • 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.
  • All new and existing tests passed.

In case of a tag pipeline, return null as branch name instead of the tag
@HHobeck
Copy link
Contributor

HHobeck commented Aug 30, 2024

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.

@arturcic arturcic force-pushed the main branch 3 times, most recently from f07f4e0 to c2946bc Compare August 30, 2024 11:24
@AlphaYankee
Copy link
Contributor Author

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)

@ITaluone
Copy link
Contributor

ITaluone commented Nov 8, 2024

Is there a plan for merge this fix?

@arturcic
Copy link
Member

arturcic commented Nov 8, 2024

@HHobeck do you think we should get this merged?

@HHobeck
Copy link
Contributor

HHobeck commented Nov 9, 2024

Yes, I think it can be merged.

@asbjornu
Copy link
Member

asbjornu commented Nov 9, 2024

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 arturcic requested a review from Copilot November 19, 2024 20:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.

@Bi0T1N
Copy link
Contributor

Bi0T1N commented Feb 1, 2025

@arturcic I assume you can close this since it was integrated in #4402 😃

@arturcic
Copy link
Member

arturcic commented Feb 1, 2025

Closing as it was integrated in #4402

@arturcic arturcic closed this Feb 1, 2025
@AlphaYankee
Copy link
Contributor Author

Thanks so much @Bi0T1N :)
I'm not sure if I would ever have found the time to learn how to create those tests.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ISSUE]: GitLab CI tag pipelines result in an incorrect version
6 participants