8000 [AppVeyor] Pull Request Branches Not Generating Correct Version Number · Issue #260 · GitTools/GitVersion · GitHub
[go: up one dir, main page]

Skip to content
[AppVeyor] Pull Request Branches Not Generating Correct Version Number #260
Closed
@gep13

Description

@gep13

I have created the following repository to test out running GitVersion in AppVeyor:

https://github.com/gep13/AppVeyorTest

I have then created a Pull Request, which I am trying to run in AppVeyor, however, the build number version is not being generated correctly.

I would expect the generated version number to be #0.2.0-PullRequest.6+7 but instead I am getting 0.2.0-unstable.1+1

NOTE: In order to debug this, I have created a new version of GitVersion with some additional log statements, and deployed this to AppVeyor. If you want to test with this same version you can do:

choco install GitVersion.Portable -source https://www.myget.org/F/gep13/

On AppVeyor, the GitVersion output is the following:

Working directory: C:\projects\AppVeyorTest
Applicable build agent found: 'AppVeyor'.
One remote found (origin -> 'https://github.com/gep13/AppVeyorTest.git').
Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.
Creating local branch from remote tracking 'refs/remotes/origin/HEAD'.
Creating local branch from remote tracking 'refs/remotes/origin/LocalPullRequestUsingLocalGitVersion'.
Creating local branch from remote tracking 'refs/remotes/origin/develop'.
Creating local branch from remote tracking 'refs/remotes/origin/feature/Issue-1'.
Creating local branch from remote tracking 'refs/remotes/origin/feature/Issue-2'.
Skipping local branch creation since it already exists 'refs/remotes/origin/master'.
HEAD is detached and points at commit '05288c7a753e372d49f328dfb71be0a0f07362fd'.
Checking out local branch 'refs/heads/develop'.
Version not in cache. Calculating version.
Running against branch: develop
GitFlow version strategy will be used
**Current Branch Name: develop**
**Current Branch Canonical Name: refs/heads/develop**
**IsDevelop True**
Executing GenerateSetVersionMessage for 'AppVeyor'.
Set AppVeyor build number to '0.2.0-unstable.1+1 (Build 26)'.
Executing GenerateBuildLogOutput for 'AppVeyor'.
Updating assembly info files

Now to further test, I have configured my local TeamCity instance to point at the same repository, and I am running the same version of GitVersion there.

This is the output from GitVersion running in TeamCity:

Working directory: C:\TeamCity\buildAgent\work\e95a697b3e3cddf2
[10:49:45]Applicable build agent found: 'TeamCity'.
[10:49:45]One remote found (origin -> 'https://github.com/gep13/AppVeyorTest.git').
[10:49:45]Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.
[10:49:46]Skipping local branch creation since it already exists 'refs/remotes/origin/develop'.
[10:49:46]Skipping local branch creation since it already exists 'refs/remotes/origin/feature/Issue-1'.
[10:49:46]Skipping local branch creation since it already exists 'refs/remotes/origin/feature/Issue-2'.
[10:49:46]Skipping local branch creation since it already exists 'refs/remotes/origin/LocalPullRequestUsingLocalGitVersion'.
[10:49:46]Skipping local branch creation since it already exists 'refs/remotes/origin/master'.
[10:49:46]HEAD is detached and points at commit '05288c7a753e372d49f328dfb71be0a0f07362fd'.
[10:49:46]Found remote tip 'refs/pull/6/merge' pointing at the commit '05288c7a753e372d49f328dfb71be0a0f07362fd'.
[10:49:46]Creating fake local branch 'refs/heads/pull/6/merge'.
[10:49:46]Checking local branch 'refs/heads/pull/6/merge' out.
[10:49:46]Version not in cache. Calculating version.
[10:49:46]Running against branch: pull/6/merge
[10:49:47]GitFlow version strategy will be used
**[10:49:47]Current Branch Name: pull/6/merge**
**[10:49:47]Current Branch Canonical Name: refs/heads/pull/6/merge**
**[10:49:47]IsPullRequest True**
[10:49:47]Executing GenerateSetVersionMessage for 'TeamCity'.
[10:49:47]##teamcity[buildNumber '0.2.0-PullRequest.6+7']
[10:49:47]Executing GenerateBuildLogOutput for 'TeamCity'.
[10:49:47]##teamcity[setParameter name='GitVersion.Major' value='0']
[10:49:47]##teamcity[setParameter name='system.GitVersion.Major' value='0']
[10:49:47]##teamcity[setParameter name='GitVersion.Minor' value='2']
[10:49:47]##teamcity[setParameter name='system.GitVersion.Minor' value='2']
[10:49:47]##teamcity[setParameter name='GitVersion.Patch' value='0']
[10:49:47]##teamcity[setParameter name='system.GitVersion.Patch' value='0']
[10:49:47]##teamcity[setParameter name='GitVersion.PreReleaseTag' value='PullRequest.6']
[10:49:47]##teamcity[setParameter name='system.GitVersion.PreReleaseTag' value='PullRequest.6']
[10:49:47]##teamcity[setParameter name='GitVersion.PreReleaseTagWithDash' value='-PullRequest.6']
[10:49:47]##teamcity[setParameter name='system.GitVersion.PreReleaseTagWithDash' value='-PullRequest.6']
[10:49:47]##teamcity[setParameter name='GitVersion.BuildMetaData' value='7']
[10:49:47]##teamcity[setParameter name='system.GitVersion.BuildMetaData' value='7']
[10:49:47]##teamcity[setParameter name='GitVersion.FullBuildMetaData' value='7.Branch.pull/6/merge.Sha.05288c7a753e372d49f328dfb71be0a0f07362fd']
[10:49:47]##teamcity[setParameter name='system.GitVersion.FullBuildMetaData' value='7.Branch.pull/6/merge.Sha.05288c7a753e372d49f328dfb71be0a0f07362fd']
[10:49:47]##teamcity[setParameter name='GitVersion.MajorMinorPatch' value='0.2.0']
[10:49:47]##teamcity[setParameter name='system.GitVersion.MajorMinorPatch' value='0.2.0']
[10:49:47]##teamcity[setParameter name='GitVersion.SemVer' value='0.2.0-PullRequest.6']
[10:49:47]##teamcity[setParameter name='system.GitVersion.SemVer' value='0.2.0-PullRequest.6']
[10:49:47]##teamcity[setParameter name='GitVersion.LegacySemVer' value='0.2.0-PullRequest6']
[10:49:47]##teamcity[setParameter name='system.GitVersion.LegacySemVer' value='0.2.0-PullRequest6']
[10:49:47]##teamcity[setParameter name='GitVersion.LegacySemVerPadded' value='0.2.0-PullRequest0006']
[10:49:47]##teamcity[setParameter name='system.GitVersion.LegacySemVerPadded' value='0.2.0-PullRequest0006']
[10:49:47]##teamcity[setParameter name='GitVersion.AssemblySemVer' value='0.2.0.0']
[10:49:47]##teamcity[setParameter name='system.GitVersion.AssemblySemVer' value='0.2.0.0']
[10:49:47]##teamcity[setParameter name='GitVersion.FullSemVer' value='0.2.0-PullRequest.6+7']
[10:49:47]##teamcity[setParameter name='system.GitVersion.FullSemVer' value='0.2.0-PullRequest.6+7']
[10:49:47]##teamcity[setParameter name='GitVersion.InformationalVersion' value='0.2.0-PullRequest.6+7.Branch.pull/6/merge.Sha.05288c7a753e372d49f328dfb71be0a0f07362fd']
[10:49:47]##teamcity[setParameter name='system.GitVersion.InformationalVersion' value='0.2.0-PullRequest.6+7.Branch.pull/6/merge.Sha.05288c7a753e372d49f328dfb71be0a0f07362fd']
[10:49:47]##teamcity[setParameter name='GitVersion.ClassicVersion' value='0.2.0.7']
[10:49:47]##teamcity[setParameter name='system.GitVersion.ClassicVersion' value='0.2.0.7']
[10:49:47]##teamcity[setParameter name='GitVersion.ClassicVersionWithTag' value='0.2.0.7-PullRequest.6']
[10:49:47]##teamcity[setParameter name='system.GitVersion.ClassicVersionWithTag' value='0.2.0.7-PullRequest.6']
[10:49:47]##teamcity[setParameter name='GitVersion.BranchName' value='pull/6/merge']
[10:49:47]##teamcity[setParameter name='system.GitVersion.BranchName' value='pull/6/merge']
[10:49:47]##teamcity[setParameter name='GitVersion.Sha' value='05288c7a753e372d49f328dfb71be0a0f07362fd']
[10:49:47]##teamcity[setParameter name='system.GitVersion.Sha' value='05288c7a753e372d49f328dfb71be0a0f07362fd']
[10:49:47]##teamcity[setParameter name='GitVersion.OriginalRelease' value='05288c7a753e372d49f328dfb71be0a0f07362fd.2014-09-26 09:46:04Z']
[10:49:47]##teamcity[setParameter name='system.GitVersion.OriginalRelease' value='05288c7a753e372d4
5E61
9f328dfb71be0a0f07362fd.2014-09-26 09:46:04Z']
[10:49:47]##teamcity[setParameter name='GitVersion.NuGetVersionV2' value='0.2.0-pullrequest0006']
[10:49:47]##teamcity[setParameter name='system.GitVersion.NuGetVersionV2' value='0.2.0-pullrequest0006']
[10:49:47]##teamcity[setParameter name='GitVersion.NuGetVersion' value='0.2.0-pullrequest0006']
[10:49:47]##teamcity[setParameter name='system.GitVersion.NuGetVersion' value='0.2.0-pullrequest0006']
[10:49:47]Updating assembly info files
[10:49:47]Process exited with code 0

I have highlighed with *'s the things I think are important. The additional log statements come from the changes that I made to this file:

            if (context.CurrentBranch.IsDevelop())
            {
                **Logger.WriteInfo("IsDevelop True");**
                return new DevelopVersionFinder().FindVersion(context);
            }

            if (context.CurrentBranch.IsPullRequest())
            {
                **Logger.WriteInfo("IsPullRequest True");**
                return new PullVersionFinder().FindVersion(context);
            }

So, as far as I can see, when GitVersion is running on AppVeyor, even though the build is executed from a Pull Request branch, it can't figure that out, since the branch.Name is develop rather than the expected pull/6/merge

What I don't know if where the responsibility for this lies.

It would seem to me that they way TeamCity does the check out is different from the way AppVeyor does it, and as a result, the expected "format" of the repository, in order to discern the current state is wrong.

Does everyone agree?

I believe that this might be at the heart of the issue that I am also having here:

#254

But I wanted to keep them separate, as I am not sure if they are related.

Can anyone offer any guidance?

/cc @distantcam @nulltoken @SimonCropp @andreasohlund @JakeGinnivan @FeodorFitsner

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0