-
Notifications
You must be signed in to change notification settings - Fork 652
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
GitVersionTask fails when building from a tag #2301
Comments
How are you running GitVersion standalone? Locally or as a In any case, it may be that you have stumbled upon the bug #2074. We don't have a fix for it yet, but any new eyes on the problem is appreciated. |
I'm having the same problem. |
I was using the GitVersion GitHub action and doing a Running the standalone .exe locally also worked fine on the tag. To fix the issue, I have since changed the checkout step to the following:
|
In my case I can reproduce the error like this:
Now run GitVersion and it will fail:
|
@TrentScholl, that's interesting. It would be great if other people experiencing the same problem could try the same fix and report back whether it helps or not. |
@jogivanknobi, thanks for providing a reproduction! That should make this issue much easier to identify and fix. Can you please also verify that GitVersion < version 5.1.3 works with your reproduction repository? What's the log output from GitVersion i.e. version 5.1.2 from the same repository? |
Interesting, I know I could fix the problem in Azure Pipelines by switching back to 5.1.3, |
@jogivanknobi, then I suspect the reproduction just leads to the same problem, but from another code-path that has never and perhaps is even supposed to never work. Also, it seems like the |
@asbjornu, I wasn't aware of this environment variable. Is there any documentation about it? |
|
Turns out my fix was unrelated. This is my workflow:
At this point, the commit hash on master and release/v1.1 are the same and checking out the tag results in a detached head.
If I make a commit to release/v1.1, build 1.1.0-beta.1 is created. If I delete my v1.1.0 tag and then retag the new head commit of release/v1.1, the build works and creates build 1.1.0 fine. In every situation, GitVersion stand-alone works fine and creates the correct SemVer. The issue only occurs with GitVersionTask. |
I'm facing the same issue as @jogivanknobi. The smallest steps to reproduce I could find are:
Tested on 3.0.0, 3.6.2, 4.0.0, 5.0.1 and 5.3.7. They all result in an error. (Showing output of 5.3.7 here)
Note that I'm not using an upstream repo, nor a CI server. After setting the Git_Branch environment variable to (fake) value |
@asbjornu: can you reply to my above comment? |
@gerwinjansen, thanks for the provided information. Are you able to reproduce the problem in a |
@asbjornu: here is the failing testcase (remove the BranchTo to make it pass)
The result is:
|
Yeah, in the case of a missing branch, GitVersion doesn't know what to increment. But with the presence of a tag it shouldn't have to increment anything, so I think it should default to just using the tag in this case. A PR changing this behaviour is welcome. |
🎉 This issue has been resolved in version 5.5.0 🎉 Your GitReleaseManager bot 📦🚀 |
I have try to build a tag right now with the new version 5.5: |
That's interesting, @fedebn. Thanks for reporting. Are you able to reproduce the problem in a test and submit it as a pull request? |
|
I have created another repository and everithing work fine. Strage. |
Given your description, I would think the following tests should cover it, @fedebn: GitVersion/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs Lines 9 to 18 in ac47ed9
GitVersion/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs Lines 20 to 30 in ac47ed9
So something else seems to be going on here. Without a test that reproduces the issue, it is going to be really hard to fix. |
Some digging makes me think that it must be GitVersion/src/GitVersionCore/Core/RepositoryMetadataProvider.cs Lines 351 to 363 in ac47ed9
…leading to
…making the check for a tagged commit in
I don't have an idea why |
@asbjornu I think I found tests that reproduce the issue. This test passes: [Test]
public void GivenARepositoryWithNonVersionTagAndNoFollowingCommits()
{
using var fixture = new EmptyRepositoryFixture();
fixture.MakeACommit("init");
fixture.MakeATaggedCommit("0.2.0");
fixture.MakeATaggedCommit("foo-tag");
fixture.Checkout("foo-tag");
fixture.AssertFullSemver("0.2.1+1");
} This test fails with [Test]
public void GivenARepositoryWithNonVersionTagAndOneFollowingCommit()
{
using var fixture = new EmptyRepositoryFixture();
fixture.MakeACommit("init");
fixture.MakeATaggedCommit("0.2.0");
fixture.MakeATaggedCommit("foo-tag");
fixture.MakeACommit("new feature");
fixture.Checkout("foo-tag");
fixture.AssertFullSemver("0.2.1+1");
} This means that GitVersion fails on checkout of a non-version tag if there is a subsequent commit. The same error occurs if you create a branch instead of a commit. This test fails with the same message: [Test]
public void GivenARepositoryWithNonVersionTagAndBranch()
{
using var fixture = new EmptyRepositoryFixture();
fixture.MakeACommit("init");
fixture.MakeATaggedCommit("0.2.0");
fixture.MakeATaggedCommit("foo-tag");
fixture.BranchTo("develop");
fixture.Checkout("foo-tag");
fixture.AssertFullSemver("0.2.1+1");
} The checkout of non-version related tags might seem like a rare use case. However, the situation occurs frequently if you have a mono-repo with per-folder GitVersion configuration with different tag prefixes. |
I agree non-version tags should not cause GitVersion to fail, @dagophil. But from @fedebn's description in #2301 (comment), version tags seem to still cause problems as well. While the tests you provide shouldn't fail, we also need a way to reproduce the version tag problem that still seems to be existent too. |
@asbjornu Okay I missed that this is about version tags only. |
Got same issue as @fedebn on Azure DevOps: Steps to reproduce on Azure:
|
GitVersion 5.8.1 For some it picks the wrong source branch:
In others it just throws:
|
@ismaelhamed, the latter error is probably due to the local repository not being complete (i.e. |
@asbjornu this is the mode: ContinuousDelivery
assembly-file-versioning-format: '{MajorMinorPatch}.{CommitsSinceVersionSource}'
assembly-informational-format: '{FullSemVer}.SHA.{ShortSha}'
branches:
develop:
tag: develop
release:
tag: rc Not sure how to reproduce it out of this repo. And it's only happening for some |
Describe the bug
I'm using GitHub actions to create a new build of a project that is using GitVersionTask.
When the build runs on a branch, everything works fine. When it runs for a tag, the following error is outputted.
GitVersion standalone works fine when checking out the tag.
Expected Behavior
The build completes with the correct version as per the tag
Actual Behavior
GitVersionTask fails with the above error
Steps to Reproduce
Run a build of a .NET Core 2.2 project in Docker using GitVersionTask 3.3.5
Context
Unable to complete build
Your Environment
GitVersionTask 5.3.5
Build running in a Docker container using mcr.microsoft.com/dotnet/core/sdk:2.2
GitVersion.yml
The text was updated successfully, but these errors were encountered: