Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

HEAD has moved #49

Closed
quasarea opened this issue Sep 10, 2018 · 9 comments
Closed

HEAD has moved #49

quasarea opened this issue Sep 10, 2018 · 9 comments

Comments

@quasarea
Copy link

quasarea commented Sep 10, 2018

IF BUG, INCLUDE THIS PART:

Steps to reproduce

  1. Create a pull request on repo
  2. Run gitversion in jenkins

Platform: windows
.NET version: 4.6.1

Expected behaviour

Produce version json output

Actual behaviour

Error happens, cannot reproduce this error using console (it only appears during jenkins build)

Jenkins log:
`
[3] Running batch script
INFO [09/10/18 10:10:45:57] Working directory: C:\Jenkins\Workspace\PlatformTools\nugetdeployer\PR-16\3
INFO [09/10/18 10:10:45:58] IsDynamicGitRepository: False
INFO [09/10/18 10:10:45:62] Returning Project Root from DotGitDirectory: C:\Jenkins\Workspace\PlatformTools\nugetdeployer\PR-16\3.git - C:\Jenkins\Workspace\PlatformTools\nugetdeployer\PR-16\3
INFO [09/10/18 10:10:45:62] Running on Windows.
INFO [09/10/18 10:10:45:63] Applicable build agent found: 'Jenkins'.
INFO [09/10/18 10:10:45:63] Branch from build environment: PR-16
INFO [09/10/18 10:10:45:63] Begin: Normalizing git directory for branch 'PR-16'
INFO [09/10/18 10:10:45:73] One remote found (origin -> 'https://stash.company.com/scm/EPT/nugetdeployer.git').
INFO [09/10/18 10:10:45:74] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
INFO [09/10/18 10:10:45:75] Updating local branch refs/heads/PR-16 to match ref PR-16
INFO [09/10/18 10:10:45:81] Creating local branch from remote tracking 'refs/remotes/origin/bugfix/retryCopy'.
INFO [09/10/18 10:10:45:86] Creating local branch from remote tracking 'refs/remotes/origin/bugfix/xunitRef'.
INFO [09/10/18 10:10:45:87] Creating local branch from remote tracking 'refs/remotes/origin/develop'.
INFO [09/10/18 10:10:45:88] Creating local branch from remote tracking 'refs/remotes/origin/feature/usesettings'.
INFO [09/10/18 10:10:45:90] Creating local branch from remote tracking 'refs/remotes/origin/master'.
INFO [09/10/18 10:10:45:90] HEAD points at branch 'refs/heads/PR-16'.
INFO [09/10/18 10:10:45:91] End: Normalizing git directory for branch 'PR-16' (Took: 278.01ms)
ERROR [09/10/18 10:10:45:91] An unexpected error occurred:
GitTools.Git.BugException: GitTools.Core has a bug, your HEAD has moved after repo normalisation.

To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1

Please run git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100 and submit it along with your build log (with personal info removed) in a new issue at https://github.com/GitTools/GitTools.Core
at GitTools.Git.GitRepositoryHelper.NormalizeGitDirectory(String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch)
at GitVersion.GitPreparer.Initialise(Boolean normaliseGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()
INFO [09/10/18 10:10:45:91]
INFO [09/10/18 10:10:45:91] Attempting to show the current git graph (please include in issue):
INFO [09/10/18 10:10:45:91] Showing max of 100 commits
INFO [09/10/18 10:10:46:03] * fab5138 53 minutes ago (HEAD -> PR-16, origin/bugfix/xunitRef, origin/PR-16, bugfix/xunitRef)
| * f637db2 5 days ago (origin/develop, develop)
| |\
| | * 24ae8ba 3 weeks ago
| | * 85a9c18 3 weeks ago
| | * 72ba9d3 3 weeks ago
| | * 8020d3f 3 weeks ago
| | * 01bd38c 3 weeks ago
| | |\
| | |/
| |/|
| * | 30226e2 3 weeks ago
| |\ \
|/ / /
| | * 2d47a0a 5 weeks ago
| | | * b7efd95 3 weeks ago (tag: V1.1.2, upstream/master, origin/master, master)
| | | |\
| | ||/
| |/| |
| * | | 23d4661 3 weeks ago (origin/bugfix/retryCopy, bugfix/retryCopy)
| * | | efc76f7 3 weeks ago
|/ / /
| | * 7dd0f09 4 weeks ago (tag: V1.1.1)
| | |\
| |
|/
|/| |

  • | | afac335 4 weeks ago
    |\ \ \
    | |/ /
    |/| |
    | * | fad19b8 4 weeks ago
    | * | ffa5dcd 4 weeks ago
    | * | ba34408 4 weeks ago
    |/ /
    | * 4e42786 6 weeks ago (tag: V1.1.0)
    | |\
    | |/
    |/|
  • | 713c2eb 6 weeks ago
    |\ \
    | * | 60751c0 6 weeks ago
    | * | 8bf9e74 6 weeks ago
    | * | 0f4c270 6 weeks ago
    | * | 3533de3 6 weeks ago
    | * | 3b53c94 6 weeks ago
    | * | b2ba178 6 weeks ago
    | * | c04ceaa 6 weeks ago
    | * | 5d75019 6 weeks ago
    | * | 518a3a5 6 weeks ago
    | * | 1915ccb 7 weeks ago
    | * | 14c5bad 7 weeks ago
    |/ /
    | * d8c4a87 7 weeks ago (tag: V1.0.3)
    | |\
    | |/
    |/|
  • | 1a93dac 8 weeks ago
    |\ \
    | * | 2d65605 8 weeks ago
    | * | f97a379 8 weeks ago
    | * | eea1e0e 8 weeks ago
    | * | d9fd6fa 8 weeks ago
    | * | 434473e 8 weeks ago
    | * | 880060d 8 weeks ago
    | |/
    | * bd20d52 10 weeks ago (tag: V1.0.2)
    | |\
  • | \ 404e6d7 10 weeks ago
    |\ \ \
    | | |/
    | |/|
    | * | 2516173 10 weeks ago
    | * | 61eb849 10 weeks ago
    | |/
    | * a7f471b 2 months ago (tag: V1.0.1)
    | |\
    | |/
    |/|
  • | a5e2691 2 months ago
    |\ \
    | |/
    |/|
    | * 9a6fe0e 2 months ago
    | * 49672f0 2 months ago
    | * 0c182a9 2 months ago
    | * a471c92 2 months ago
    | * 9c2b01e 2 months ago
    | * 3cdaf5e 2 months ago
    | * 315cc0d 2 months ago
    | * 859a133 2 months ago
    | * 75bc849 2 months ago
    | * 2bc031a 2 months ago
    | * 94aad45 2 months ago
    |/
    | * ba6cc8f 2 months ago (origin/feature/usesettings, feature/usesettings)
    | * cf52fda 2 months ago
    | * 9844932 2 months ago
    |/
  • b38d621 2 months ago
  • 56a9519 3 months ago
  • 274905f 3 months ago (tag: V1.0.0)
  • 795178e 3 months ago

script returned exit code 1
`

logging onto node and running same command in same place yields:

C:\jenkins\workspace\PlatformTools\nugetdeployer\PR-16 -> origin\3 (PR-16 -> origin)
λ packages\GitVersion.CommandLine\tools\GitVersion.exe /nofetch /verbosity debug
{
"Major":1,
"Minor":2,
"Patch":0,
"PreReleaseTag":"PullRequest.5",
"PreReleaseTagWithDash":"-PullRequest.5",
"PreReleaseLabel":"PullRequest",
"PreReleaseNumber":5,
"BuildMetaData":"",
"BuildMetaDataPadded":"",
"FullBuildMetaData":"Branch.PR-16.Sha.fab51381529b3963d9e187250686e4fb2e6db5cd",
"MajorMinorPatch":"1.2.0",
"SemVer":"1.2.0-PullRequest.5",
"LegacySemVer":"1.2.0-PullRequest5",
"LegacySemVerPadded":"1.2.0-PullRequest0005",
"AssemblySemVer":"1.0.0.0",
"AssemblySemFileVer":"1.2.0.0",
"FullSemVer":"1.2.0-PullRequest.5",
"InformationalVersion":"1.2.0-PullRequest.5+Branch.PR-16.Sha.fab51381529b3963d9e187250686e4fb2e6db5cd",
"BranchName":"PR-16",
"Sha":"fab51381529b3963d9e187250686e4fb2e6db5cd",
"NuGetVersionV2":"1.2.0-pullrequest0005",
"NuGetVersion":"1.2.0-pullrequest0005",
"NuGetPreReleaseTagV2":"pullrequest0005",
"NuGetPreReleaseTag":"pullrequest0005",
"CommitsSinceVersionSource":5,
"CommitsSinceVersionSourcePadded":"0005",
"CommitDate":"2018-09-10"
}

@r24mille
Copy link

r24mille commented Dec 13, 2018

We're getting a similar error on AppVeyor pulling GitVersion.Portable from chocolatey since 4.0.0-beta0014. We're also getting the same error using the recently-released 4.0 stable version on AppVeyor (without using chocolatey).

We're trying to determine if it's an issue with our workflow, pretty vanilla Github Flow. AppVeyor builds the PRs before they're merged to master. The command run is:

gitversion $env:APPVEYOR_BUILD_FOLDER /l console /output buildserver /updateAssemblyInfo /nofetch /b $env:APPVEYOR_REPO_BRANCH

Here's the build log with (slightly) personal info removed:

INFO [12/13/18 16:50:26:85] Running on Windows.
INFO [12/13/18 16:50:26:87] Applicable build agent found: 'AppVeyor'.
INFO [12/13/18 16:50:26:87] Branch from build environment: master
INFO [12/13/18 16:50:26:87] Begin: Normalizing git directory for branch 'master'
  INFO [12/13/18 16:50:26:99] One remote found (origin -> '[email protected]:Redacted/redacted.git').
  INFO [12/13/18 16:50:27:01] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [12/13/18 16:50:27:01] Updating local branch refs/heads/master to match ref master
  INFO [12/13/18 16:50:27:09] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-1'.
  INFO [12/13/18 16:50:27:17] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-2'.
  INFO [12/13/18 16:50:27:17] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-3'.
  INFO [12/13/18 16:50:27:18] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-4'.
  INFO [12/13/18 16:50:27:18] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-5'.
  INFO [12/13/18 16:50:27:20] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-6'.
  INFO [12/13/18 16:50:27:21] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-7'.
  INFO [12/13/18 16:50:27:21] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-8'.
  INFO [12/13/18 16:50:27:23] Creating local branch from remote tracking 'refs/remotes/origin/REDACTED-9'.
  INFO [12/13/18 16:50:27:23] HEAD points at branch 'refs/heads/master'.
INFO [12/13/18 16:50:27:23] End: Normalizing git directory for branch 'master' (Took: 359.34ms)
ERROR [12/13/18 16:50:27:24] An unexpected error occurred:
GitTools.Git.BugException: GitTools.Core has a bug, your HEAD has moved after repo normalisation.
To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1
Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100` and submit it along with your build log (with personal info removed) in a new issue at https://github.com/GitTools/GitTools.Core
   at GitTools.Git.GitRepositoryHelper.NormalizeGitDirectory(String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch)
   at GitVersion.GitPreparer.Initialise(Boolean normaliseGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
   at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
   at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
   at GitVersion.Program.VerifyArgumentsAndRun()
INFO [12/13/18 16:50:27:24] 
INFO [12/13/18 16:50:27:24] Attempting to show the current git graph (please include in issue): 
INFO [12/13/18 16:50:27:24] Showing max of 100 commits
INFO [12/13/18 16:50:27:34] * 58e5a14 44 seconds ago  (origin/REDACTED-4, REDACTED-4)
* d31975e 19 hours ago 
*   451abc4 5 weeks ago  (HEAD -> master, tag: v2.9.2, tag: v2.9.0, tag: v2.8.0, tag: v2.10.0, origin/master, origin/HEAD)
|\  
| * 3257d95 5 weeks ago 
|/  
*   e71f02f 5 weeks ago 
|\  
| * b1bd28b 5 weeks ago 
| * ba32d9f 5 weeks ago 
| * 8e5ac98 5 weeks ago 
| * b17c6a7 5 weeks ago 
| * ac18a0b 5 weeks ago 
|/  
*   3b625e5 8 weeks ago  (tag: v2.7.0)
|\  
| * bc02f14 8 weeks ago 
| * aaa6755 8 weeks ago 
|/  
*   627e846 8 weeks ago 
|\  
| * d179a78 8 weeks ago  (origin/REDACTED-6, REDACTED-6)
|/  
*   1eeee74 8 weeks ago 
|\  
| * 8eab828 8 weeks ago  (origin/REDACTED-2, REDACTED-2)
* |   995eac3 8 weeks ago 
|\ \  
| |/  
| * b49c86f 8 weeks ago 
|/  
*   087d90f 8 weeks ago 
|\  
| * 4f1300c 8 weeks ago 
| * 1fbb05a 8 weeks ago 
| * b6b431a 8 weeks ago 
* |   6d15724 8 weeks ago 
|\ \  
| * | 7b2114f 9 weeks ago 
| |/  
* |   e0dbf79 8 weeks ago 
|\ \  
| |/  
|/|   
| * fdab97b 8 weeks ago 
| * b49d3e9 8 weeks ago 
| * 4c1a68f 8 weeks ago 
|/  
*   34d2acc 2 months ago 
|\  
| * 29b188c 2 months ago 
| *   415174b 2 months ago 
| |\  
| |/  
|/|   
* |   35b6b9d 2 months ago 
|\ \  
| * | 0ea35ce 2 months ago 
| * | ec71a30 2 months ago 
| * | 851fb63 2 months ago 
| * | c117e20 2 months ago 
|/ /  
| * 1d551e6 2 months ago 
| * 492f425 2 months ago 
|/  
*   b090ee1 2 months ago  (tag: v2.6.0)
|\  
| * 218fad9 2 months ago 
| * a2a478e 2 months ago 
| * 3785d49 3 months ago 
| * 0941973 3 months ago 
|/  
*   2de4dde 3 months ago  (tag: 2.5.0)
|\  
| * 9b12b8f 3 months ago 
|/  
*   a0a4b71 3 months ago 
|\  
| * f5aee51 3 months ago 
* |   faf3cab 3 months ago 
|\ \  
| * | e714cab 3 months ago 
* | |   f0b4b19 3 months ago 
|\ \ \  
| |/ /  
|/| /   
| |/    
| * dfd4bbf 3 months ago 
| * 0c4df7b 3 months ago 
| * 2884b69 3 months ago 
| * 7bd9f0f 3 months ago 
|/  
*   89e563e 3 months ago  (tag: v2.4.0)
|\  
| * 851cefc 3 months ago 
| * e9eb07d 3 months ago 
| * aff139c 3 months ago 
* |   c93695c 3 months ago 
|\ \  
| |/  
| * 52ff37d 3 months ago 
|/  
*   6207770 3 months ago 
|\  
| * 87bc1d1 3 months ago 
| * 28063ba 3 months ago 
| * ae6f5fc 3 months ago 
| * c87a14f 3 months ago 
| * 5893595 3 months ago 
| * 30fcefe 3 months ago 
| *   d7f4e3d 3 months ago 
| |\  
| * | 97505b3 3 months ago 
| * | 09796be 3 months ago 
| * | 1e3c72d 3 months ago 
* | |   35ab6ce 3 months ago 
|\ \ \  
| |_|/  
|/| |   
| * | b318e3f 3 months ago 
| * | 23bd4a6 3 months ago 
| * | be476b6 3 months ago 
| * | d574ec3 3 months ago 
| * | 4a62b25 3 months ago 
| * | daa7f01 3 months ago 
|/ /  
* |   3258f65 3 months ago 
|\ \  
| * | b469634 3 months ago 
| * | deabc13 3 months ago 
| * | eacc617 3 months ago 
| * | 078c88b 3 months ago 
| * | e019e5b 3 months ago 
| * | 8d05194 3 months ago 
| * | 0aa52cc 3 months ago 
| * | 59ac1bb 3 months ago 
| * | f7db326 3 months ago 
| * |   d8dd1a8 3 months ago 
| |\ \  
| |/ /  
|/| |   
* | |   d18a10c 3 months ago 
|\ \ \  
| * | | 5b608ff 3 months ago 
|/ / /  
* | |   3f2b18c 3 months ago 
|\ \ \  
| |_|/  
|/| |   
| | * 21a825c 3 months ago 
| | * 0b19cc2 3 months ago 
| | * 37f6bb1 3 months ago 
| | * d8377bd 3 months ago 
| | * ddc45d2 3 months ago 
| | * b649649 3 months ago 
| | * 3965ad3 3 months ago

My bug may be related to appveyor/ci#2740

@ThetaSinner
Copy link

Seeing the same issue. Any update on this?

@medianick
Copy link

This just occurred for us today with GitVersionTask 4.0.0 and a Multibranch Pipeline job in Jenkins. The master build (triggered by a push) got versioned properly, but then the automatic rebuilds of outstanding PRs (as merged with master by Jenkins, per default behavior) all failed with this error.

@tknerr
Copy link

tknerr commented Mar 13, 2019

I just had this on Jenkins after interactively rebasing + squashing commits on a feature branch. Can't tell though whether it is 100% reproducible yet...

@dweggemans
Copy link

We're seeing this behavior as well after upgrading from 4.0.0-beta12 to 4.0.0. When building a pipeline job that builds a merge request to merge a feature into develop.

Settings the environment variabele works, but produces the wrong version number.
Develop is currently on 0.1.0
We have a release branch open for version 1.0
De merge is versioned 1.1.0 while I'd expect this to be 0.1.0

@nikhilagrawaldotnet
Copy link

Any update on this?

@JoshSchreuder
Copy link

JoshSchreuder commented Jun 11, 2019

I found this issue was because Jenkins was checking out a branch named origin/master locally because by default it sets the local branch name to match the remote branch name.

This trips up gitversion in a few ways (eg. branch config resolution which does not remove origin), but can be resolved by adding Check out to a specific local branch in Jenkins git options, and supplying the value **. This checks out to local branch master (or whatever the branch is called, without origin/).

Following this, you need to delete the local branch origin/master on the server, by running git branch -d origin/master to remove the local branch.

That resolved my problem. Hopefully this helps someone else.

@mycroes
Copy link

mycroes commented Jun 11, 2019

@JoshSchreuder I use Jenkins to build Gerrit changes where it is set to checkout $GERRIT_BRANCH, which normally is either develop or master (without origin/). In that case it still doesn't work, because local develop or master is ahead of origin/develop or origin/master, so the normalization still breaks. I guess your suggestion works for changes that are already merged, but I think it doesn't change much about the issue at hand.

@asbjornu
Copy link
Member

asbjornu commented Jun 27, 2019

As GitVersion stopped using GitTools.Core in GitTools/GitVersion#1581, this issue is unfortunately not relevant anymore and the whole repository will be archived. Please try the latest build of GitVersion and see if it solves whatever problem you had when you submitted this issue. If the problem persists, please submit a new issue or PR against the GitVersion repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants