Skip to content
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

[Bug] ref '.....' doesn't match the destination #3465

Closed
DanieleSky opened this issue Apr 7, 2023 · 25 comments
Closed

[Bug] ref '.....' doesn't match the destination #3465

DanieleSky opened this issue Apr 7, 2023 · 25 comments

Comments

@DanieleSky
Copy link

Describe the bug
Hi, I'm using GitVersion 6.0.0-beta2 with Jenkins with Multibranch pipeline.
I'm using the standard configuration (I haven't GitVersion.yaml)
When I tag a commit and build it, GitVersion throw an error like this:

INFO [04/07/23 13:04:13:94] Applicable build agent found: 'Jenkins'.
INFO [04/07/23 13:04:14:09] Working directory: /var/lib/jenkins/workspace/4Retail_Dinamo.Extensions_v1.7.1
INFO [04/07/23 13:04:14:09] Project root is: /var/lib/jenkins/workspace/4Retail_Dinamo.Extensions_v1.7.1/
INFO [04/07/23 13:04:14:09] DotGit directory is: /var/lib/jenkins/workspace/4Retail_Dinamo.Extensions_v1.7.1/.git
INFO [04/07/23 13:04:14:10] Branch from build environment: v1.7.1
INFO [04/07/23 13:04:14:11] Begin: Normalizing git directory for branch 'v1.7.1'
  INFO [04/07/23 13:04:14:16] One remote found (origin -> 'http://gitea.dinamoretail.lan/Var4Retail/Dinamo.Extensions.git').
  INFO [04/07/23 13:04:14:16] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [04/07/23 13:04:14:17] Updating local branch v1.7.1 to match ref v1.7.1
  INFO [04/07/23 13:04:14:22] Skipping update of 'refs/remotes/origin/HashRefactorECrypting' as it already matches the remote ref.
  INFO [04/07/23 13:04:14:22] Skipping update of 'refs/remotes/origin/main' as it already matches the remote ref.
  INFO [04/07/23 13:04:14:22] Creating local branch from remote tracking 'refs/remotes/origin/staging'.
  INFO [04/07/23 13:04:14:24] End: Normalizing git directory for branch 'v1.7.1' (Took: 130.16ms)
  ERROR [04/07/23 13:04:14:26] An unexpected error occurred:
**LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/staging' doesn't match the destination**

If I rerun the build the error change based of the name of all branch I have in the repository.
Like this:
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/main' doesn't match the destination
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/staging' doesn't match the destination
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/features-1' doesn't match the destination

After last branch the build works as expected:

+ dotnet-gitversion /updateprojectfiles buildserver
{
  "AssemblySemFileVer": "1.7.1.0",
  "AssemblySemVer": "1.7.1.0",
  "BranchName": "v1.7.1",
  "BuildMetaData": null,
  "CommitDate": "2023-04-07",
  "CommitsSinceVersionSource": 0,
  "EscapedBranchName": "v1-7-1",
  "FullBuildMetaData": "Branch.v1.7.1.Sha.434206b3d7989e7106c234e1a5b06a611c078296",
  "FullSemVer": "1.7.1",
  "InformationalVersion": "1.7.1+Branch.v1.7.1.Sha.434206b3d7989e7106c234e1a5b06a611c078296",
  "Major": 1,
  "MajorMinorPatch": "1.7.1",
  "Minor": 7,
  "Patch": 1,
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "SemVer": "1.7.1",
  "Sha": "434206b3d7989e7106c234e1a5b06a611c078296",
  "ShortSha": "434206b",
  "UncommittedChanges": 0,
  "VersionSourceSha": "434206b3d7989e7106c234e1a5b06a611c078296",
  "WeightedPreReleaseNumber": 60000
}

Attach the configuration of Jenkins
image

Why the software have this behaviour?
There are some configurations that is wrong?

@DanieleSky DanieleSky added the bug label Apr 7, 2023
@DanieleSky DanieleSky changed the title [Bug] [Bug] ref '.....' doesn't match the destination Apr 7, 2023
@HHobeck
Copy link
Contributor

HHobeck commented Apr 7, 2023

Why the software have this behaviour?

I think you have found a bug. For me it's not clear why this error occurred and also I cannot try/reproduce it because I'm not using Jenkins. Thus I need your help finding the root cause. Could you give me the hole exception stack trace please? Maybe this change is a candidate: #3459

@DanieleSky
Copy link
Author

Hi,
this is the stack trace:

+ dotnet-gitversion /updateprojectfiles buildserver
INFO [04/07/23 14:13:49:30] Applicable build agent found: 'Jenkins'.
INFO [04/07/23 14:13:49:45] Working directory: /var/lib/jenkins/workspace/inamo.Store.Services.Core_v0.4.0
INFO [04/07/23 14:13:49:45] Project root is: /var/lib/jenkins/workspace/inamo.Store.Services.Core_v0.4.0/
INFO [04/07/23 14:13:49:45] DotGit directory is: /var/lib/jenkins/workspace/inamo.Store.Services.Core_v0.4.0/.git
INFO [04/07/23 14:13:49:45] Branch from build environment: v0.4.0
INFO [04/07/23 14:13:49:46] Begin: Normalizing git directory for branch 'v0.4.0'
  INFO [04/07/23 14:13:49:51] One remote found (origin -> 'http://gitea.dinamoretail.lan/Var4Retail/Dinamo.Store.Services.Core.git').
  INFO [04/07/23 14:13:49:52] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
  INFO [04/07/23 14:13:49:53] Updating local branch v0.4.0 to match ref v0.4.0
  INFO [04/07/23 14:13:49:58] Skipping update of 'refs/remotes/origin/Modifiche' as it already matches the remote ref.
  INFO [04/07/23 14:13:49:58] Skipping update of 'refs/remotes/origin/main' as it already matches the remote ref.
  INFO [04/07/23 14:13:49:58] Creating local branch from remote tracking 'refs/remotes/origin/staging'.
  INFO [04/07/23 14:13:49:59] End: Normalizing git directory for branch 'v0.4.0' (Took: 132.41ms)
  ERROR [04/07/23 14:13:49:62] An unexpected error occurred:
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/staging' doesn't match the destination
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
   at LibGit2Sharp.Core.Proxy.git_refspec_rtransform(IntPtr refSpecPtr, String name) in /_/LibGit2Sharp/Core/Proxy.cs:line 2088
   at LibGit2Sharp.Remote.FetchSpecTransformToSource(String reference) in /_/LibGit2Sharp/Remote.cs:line 138
   at LibGit2Sharp.BranchUpdater.GetUpstreamInformation(String canonicalName, String& remoteName, String& mergeBranchName) in /_/LibGit2Sharp/BranchUpdater.cs:line 188
   at LibGit2Sharp.BranchUpdater.SetUpstream(String upstreamBranchName) in /_/LibGit2Sharp/BranchUpdater.cs:line 116
   at LibGit2Sharp.BranchUpdater.set_TrackedBranch(String value) in /_/LibGit2Sharp/BranchUpdater.cs:line 53
   at GitVersion.BranchCollection.<>c__DisplayClass7_0.<UpdateTrackedBranch>g__Updater|0(BranchUpdater branchUpdater) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 43
   at LibGit2Sharp.BranchCollection.Update(Branch branch, Action`1[] actions) in /_/LibGit2Sharp/BranchCollection.cs:line 290
   at GitVersion.BranchCollection.UpdateTrackedBranch(IBranch branch, String remoteTrackingReferenceName) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 45
   at GitVersion.GitPreparer.CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(String remoteName) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 354
   at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 165
   at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
   at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
   at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 65
  INFO [04/07/23 14:13:49:62] Attempting to show the current git graph (please include in issue): 
  INFO [04/07/23 14:13:49:62] Showing max of 100 commits
  INFO [04/07/23 14:13:49:67] * a6cd221 4 minutes ago  (HEAD -> v0.4.0, tag: v0.4.0, tag: origin/v0.4.0, origin/staging, staging)
*   1c132d5 4 minutes ago 
|\  
| * f427260 65 minutes ago 
| *   bfa1456 5 hours ago 
| |\  
| * | c332e32 5 hours ago 
| | | * 4bbc808 2 hours ago  (origin/Modifiche, Modifiche)
| | | * b67060d 2 hours ago 
| |_|/  
|/| |   
* | | 1a11bfc 24 hours ago  (tag: v0.3.0)
* | |   537cba2 24 hours ago 
|\ \ \  
| | |/  
| |/|   
| * |   3abd3c2 24 hours ago 
| |\ \  
| |/ /  
|/| /   
| |/    
* |   2bfe0b4 4 days ago  (tag: v0.2.0)
|\ \  
| * \   0befcfc 4 days ago 
| |\ \  
| * \ \   28ca8fa 4 days ago 
| |\ \ \  
* | | | | dfabe02 4 days ago 
| | | | * 3e6e5b6 2 days ago 
| | | |/  
| | | *   a732a00 4 days ago 
| | | |\  
| | | |/  
| | |/|   
| | * |   687aaaf 4 days ago 
| | |\ \  
| | |/ /  
| |/| |   
| * | | 55ec0ee 7 days ago  (tag: v0.1.2)
|/| | | 
| | | * 3fa7fe1 4 days ago 
| | |/  
| | * ba06923 4 days ago 
| |/  
| *   a0bfc57 7 days ago 
| |\  
| | * 9583fc1 7 days ago 
| | * b67f648 7 days ago 
| |/  
|/|   
* | e5c4f3b 2 weeks ago  (tag: v0.1.1)
* | f4879f6 2 weeks ago 
* | 40fe658 2 weeks ago 
* | 0d64181 2 weeks ago  (tag: v0.1.0-2)
* | 3dcd7f6 2 weeks ago  (tag: v0.1.0-1)
* | 6d6ba30 2 weeks ago 
* |   c7df498 2 weeks ago 
|\ \  
| | * a152180 7 days ago 
| |/  
| *   4d88249 2 weeks ago 
| |\  
| |/  
|/|   
* | c0998a5 2 weeks ago 
* | 63dcc81 2 weeks ago 
* | 7fa6e3f 2 weeks ago 
* | 2c50079 2 weeks ago 
* | fdeae32 2 weeks ago 
* | 3b31ab8 2 weeks ago 
* | 64d42d5 2 weeks ago 
* | 5a80905 2 weeks ago 
| * 7cbd0a2 2 weeks ago 
|/  
| * 17a543c 7 days ago  (origin/main, main)
|/  
* 844e0c5 2 weeks ago  (tag: v0.1.0)
* 3442bb5 2 weeks ago 

Let me know if you need other logs!
Thanks

@HHobeck
Copy link
Contributor

HHobeck commented Apr 11, 2023

Is it possible to provide a git repository or any steps to reproduce the problem? What version have you used before GitVersion 6.0.0-beta2? Could you provide the logs for the succesfull run please? Does this problem happen with GitVersion 6.0.0-beta1?

@DanieleSky
Copy link
Author

Hi HHobek,
I started with the version 5.12 and then I upgraded to 6.0.0-beta2 to try to resolve..
With the version 5.12 there was the same issue.
I have jenkins installed in a linux machine, I could try to install the same enviroment on a shared machine.
Daniele

@DanieleSky
Copy link
Author

Hi @HHobeck
I send you an email. Let me know if is ok.
Thank you
Daniele

@DanieleSky
Copy link
Author

Hi @HHobeck
Have you try to reproduce the issue on test environment that I shared with you?
If not do you know when you can or if someone else can?

@HHobeck
Copy link
Contributor

HHobeck commented May 1, 2023

First of all thank you for creating the test environment. Actually I'm quite busy at this moment and have no time to take a look into your issue. It's also related to infrastructure which I'm not familiar with. @arturcic Do you have time to take a look?

@arturcic
Copy link
Member

arturcic commented May 1, 2023

I don't think the following month i will be able to spend time on this

@DanieleSky
Copy link
Author

Ok, don't worry. I'm going to shutdown the test enviroment due the costs of infrastructure. When you able to check this issue, if you need the enviroment let me know, so I can restart it again.
Thanks

@DanieleSky
Copy link
Author

Hi, any news about this issue?

@mwijns
Copy link

mwijns commented Jun 27, 2023

I'm having the same problem, tested on 5.10.0, 5.11.0. and 5.12.0. As described above every build the problem from the previous build is resolved and the error is on the next update, e.g.

12:30:16 WARNING: INFO [06/27/23 12:30:14:97] Updating local branch release/2.4.2 to match ref release/2.4.2
12:30:16 WARNING: INFO [06/27/23 12:30:15:42] Creating local branch from remote tracking 'refs/remotes/origin/develop'.
12:30:16 WARNING: INFO [06/27/23 12:30:15:43] End: Normalizing git directory for branch 'release/2.4.2' (Took: 682.58ms)
12:30:16 WARNING: ERROR [06/27/23 12:30:15:46] An unexpected error occurred:
12:30:16 WARNING: LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/develop' doesn't match the destination

16:33:39 WARNING: INFO [06/27/23 16:33:38:12] Updating local branch release/2.4.2 to match ref release/2.4.2
16:33:39 WARNING: INFO [06/27/23 16:33:38:56] Skipping update of 'refs/remotes/origin/develop' as it already matches the remote ref.
16:33:39 WARNING: INFO [06/27/23 16:33:38:57] Creating local branch from remote tracking 'refs/remotes/origin/feature/specific_feature_branch'.
16:33:39 WARNING: INFO [06/27/23 16:33:38:58] End: Normalizing git directory for branch 'release/2.4.2' (Took: 733.13ms)
16:33:39 WARNING: ERROR [06/27/23 16:33:38:61] An unexpected error occurred:
16:33:39 WARNING: LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/feature/specific_feature_branch' doesn't match the destination

16:46:55 WARNING: INFO [06/27/23 16:46:53:80] Updating local branch release/2.4.2 to match ref release/2.4.2
16:46:55 WARNING: INFO [06/27/23 16:46:54:42] Skipping update of 'refs/remotes/origin/develop' as it already matches the remote ref.
16:46:55 WARNING: INFO [06/27/23 16:46:54:43] Skipping update of 'refs/remotes/origin/feature/specific_feature_branch' as it already matches the remote ref.
16:46:55 WARNING: INFO [06/27/23 16:46:54:43] Creating local branch from remote tracking 'refs/remotes/origin/feature/another_feature_branch'.
16:46:55 WARNING: INFO [06/27/23 16:46:54:44] End: Normalizing git directory for branch 'release/2.4.2' (Took: 933.50ms)
16:46:55 WARNING: ERROR [06/27/23 16:46:54:47] An unexpected error occurred:
16:46:55 WARNING: LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/feature/another_feature_branch' doesn't match the destination

full stack trace of the first instance (this was running 5.10.0):
12:30:16 WARNING: ERROR [06/27/23 12:30:15:46] An unexpected error occurred:
12:30:16 WARNING: LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/develop' doesn't match the destination
12:30:16 WARNING: at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154
12:30:16 WARNING: at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /
/LibGit2Sharp/Core/Ensure.cs:line 172
12:30:16 WARNING: at LibGit2Sharp.Core.Proxy.git_refspec_rtransform(IntPtr refSpecPtr, String name) in //LibGit2Sharp/Core/Proxy.cs:line 2088
12:30:16 WARNING: at LibGit2Sharp.Remote.FetchSpecTransformToSource(String reference) in /
/LibGit2Sharp/Remote.cs:line 138
12:30:16 WARNING: at LibGit2Sharp.BranchUpdater.GetUpstreamInformation(String canonicalName, String& remoteName, String& mergeBranchName) in //LibGit2Sharp/BranchUpdater.cs:line 188
12:30:16 WARNING: at LibGit2Sharp.BranchUpdater.SetUpstream(String upstreamBranchName) in /
/LibGit2Sharp/BranchUpdater.cs:line 116
12:30:16 WARNING: at LibGit2Sharp.BranchUpdater.set_TrackedBranch(String value) in //LibGit2Sharp/BranchUpdater.cs:line 53
12:30:16 WARNING: at GitVersion.BranchCollection.<>c__DisplayClass7_0.g__Updater|0(BranchUpdater branchUpdater) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 43
12:30:16 WARNING: at LibGit2Sharp.BranchCollection.Update(Branch branch, Action`1[] actions) in /
/LibGit2Sharp/BranchCollection.cs:line 290
12:30:16 WARNING: at GitVersion.BranchCollection.UpdateTrackedBranch(IBranch branch, String remoteTrackingReferenceName) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 45
12:30:16 WARNING: at GitVersion.GitPreparer.CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(String remoteName) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 352
12:30:16 WARNING: at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 165
12:30:16 WARNING: at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
12:30:16 WARNING: at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
12:30:16 WARNING: at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
12:30:16 WARNING: at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
12:30:16 WARNING: at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

@github-actions github-actions bot added stale and removed stale labels Sep 26, 2023
@DanieleSky
Copy link
Author

Sad to see that this issue is still open :(
How I can to help you?

@asbjornu
Copy link
Member

asbjornu commented Nov 7, 2023

I'm having the same problem, tested on 5.10.0, 5.11.0. and 5.12.0.

@mwijns, can you please test with the latest v6 beta?

Sad to see that this issue is still open :( How I can to help you?

@DanieleSky, we need a way to reproduce this. Did you manage to create a stable reproduction of the problem that we can have a look at?

@DanieleSky
Copy link
Author

@asbjornu as I wrote above, I shared with @HHobeck an environment with Jenkins installed where you can try and see the issue.
Do you need somethings else?

@asbjornu
Copy link
Member

asbjornu commented Nov 7, 2023

@asbjornu as I wrote above, I shared with @HHobeck an environment with Jenkins installed where you can try and see the issue. Do you need somethings else?

Are you able to share it publicly, or with me at [email protected]?

@DanieleSky
Copy link
Author

@asbjornu I send you an email!
Thanks for you support

@JohnyBro
Copy link

Hi, do we have any information on this issue?

@DanieleSky
Copy link
Author

No new information..
I'm going to shutdown the test enviroment due the costs of infrastructure. @asbjornu, when you able to check this issue, if you need the enviroment let me know, so I can restart it again.
Thanks

@JohnyBro
Copy link

JohnyBro commented Dec 5, 2023

@DanieleSky Did you find a workaround ?

@DanieleSky
Copy link
Author

@JohnyBro no.. today I tried to debug the issue but without success.
It's an annoying problem, open from mote than six months. I'm thinking to switch to another tool.

@asbjornu
Copy link
Member

asbjornu commented Dec 6, 2023

Sorry for not finding time to debug this issue. All work on GitVersion is voluntary and unpaid, so we do it all on our free time. Finding the time and energy to debug a problem like this is therefore difficult. If anyone were able to reproduce the bug in an integration test, it would make the bug incredibly much simpler to fix.

@DanieleSky
Copy link
Author

At the end I switched from Jenkins to GitLab (on prem) and all is working more or less as expected!

Copy link

github-actions bot commented Apr 9, 2024

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Apr 9, 2024
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants