Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Refs already exist #567

Closed
MarcBruins opened this issue Nov 27, 2018 · 12 comments
Closed

Refs already exist #567

MarcBruins opened this issue Nov 27, 2018 · 12 comments

Comments

@MarcBruins
Copy link
Member

On the project i'm working on i get the following exception:

2018-11-27T14:53:25.4275277Z Updating'Microsoft.AspNetCore' from 2.1.0, 2.0.3, 2.1.2, 2.1.4 to 2.1.6 in 10 projects 2018-11-27T14:53:25.4300247Z Updates failed NameConflictException : failed to write reference 'refs/heads/nukeeper-update-Microsoft.AspNetCore-to-2.1.6': a reference with that name already exists.

Might be related to: GitTools/GitVersion#864 but i'm not sure yet.

@AnthonySteele
Copy link
Member

AnthonySteele commented Nov 27, 2018

The workaround is usually to find the existing branch with that name in git, and merge or delete it.
If there's a ref but not a branch then that's something new.

@MarcBruins
Copy link
Member Author

MarcBruins commented Nov 27, 2018

That's what I thought initially, only the branch is non existing. Maybe because of multiple project with the same package upgrade? So it creates the same branch x times? The naming is not unique, maybe we should change it to nukeeper-update-{solution}-{project}-{packageInfo}

@AnthonySteele
Copy link
Member

That's odd. I'm not a git expert, I don't know how a /refs/head/foo differs from a branch called foo.
I thought that they were the same

@MarcBruins
Copy link
Member Author

MarcBruins commented Nov 28, 2018

It works at: https://github.com/MarcBruins/nukeeperrefissue and at my private ado account. Not sure what is going on now. I'm certain the branch is deleted.

If i don't delete the branch i get the following error:
2018-11-28T19:33:52.1453532Z Updates failed NuKeeperException : Git Cannot checkout new branch: a branch named 'origin/nukeeper-update-Microsoft.AspNetCore-to-2.1.6' already exists

which makes sense and is different from the error above.

The difference is that our project is way more complicated. The Asp.Net.Core dependency is used in 10 projects instead of 2. Will investigate some more(next step is to run the local repo command on a specific project)

@MarcBruins
Copy link
Member Author

Issue is solved magically? Maybe ADO still had some reference to the branch somewhere after all. Closing it for now

@baterja
Copy link

baterja commented Nov 22, 2019

I'm getting similar error when using NuKeeper extension for Azure Devops.

Here's a bit censored tail of detailed logs:

Nuget restore on <my solution> complete
Updating 'Newtonsoft.Json' from from <...> to <correct version> in <...> projects
Git checkout 'origin/feature/NuKeeper'
Using branch name: 'nukeeper-update-Newtonsoft.Json-to-<correct version>'
Git checkout new branch 'nukeeper-update-Newtonsoft.Json-to-<correct version>'
Updates failed NameConflictException : failed to write reference 'refs/heads/nukeeper-update-Newtonsoft.Json-to-<correct version>': a reference with that name already exists.
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_branch_create_from_annotated(RepositoryHandle repo, String branch_name, String targetIdentifier, Boolean force)
   at LibGit2Sharp.BranchCollection.Add(String name, String committish, Boolean allowOverwrite)
   at NuKeeper.Git.LibGit2SharpDriver.<>c__DisplayClass13_0.<CheckoutNewBranch>b__0() in <...>/NuKeeper.Git/LibGit2SharpDriver.cs:line 123
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, NuGetSources sources, SettingsContainer settings, IReadOnlyCollection`1 updates) in <...>/NuKeeper/Engine/Packages/PackageUpdater.cs:line 75
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, IReadOnlyCollection`1 updates, NuGetSources sources, SettingsContainer settings) in <...>/NuKeeper/Engine/Packages/PackageUpdater.cs:line 46
Attempted 3 updates and did 0

I'm sure that branch doesn't currently exist on remote.
I thought it may be an issue with LibGit2Sharp, so I've ran it providing my own git cli path and then the result was (blank lines as originally printed in logs):

Nuget restore on <my solution> complete
Updating 'Newtonsoft.Json' from from <...> to <correct version> in <...> projects
In path <repo root path>\.git\, running command: <git path>\git.exe checkout -b origin/feature/NuKeeper origin/origin/feature/NuKeeper
Command <git path>\git.exe failed with exit code: 128



fatal: this operation must be run in a work tree

Using branch name: 'nukeeper-update-Newtonsoft.Json-to-<correct version>'
In path <repo root path>\.git\, running command: <git path>\git.exe checkout -b nukeeper-update-Newtonsoft.Json-to-<correct version>
Command <git path>\git.exe failed with exit code: 128



fatal: this operation must be run in a work tree

Updates failed NuKeeperException : Command <git path>\git.exe failed with exit code: 128



fatal: this operation must be run in a work tree

   at NuKeeper.Update.ProcessRunner.ExternalProcess.Run(String workingDirectory, String command, String arguments, Boolean ensureSuccess) in <...>/NuKeeper.Update/ProcessRunner/ExternalProcess.cs:line 63
   at NuKeeper.Git.GitCmdDriver.StartGitProzess(String arguments, Boolean ensureSuccess) in <...>/NuKeeper.Git/GitCmdDriver.cs:line 92
   at NuKeeper.Git.GitCmdDriver.CheckoutNewBranch(String branchName) in <...>/NuKeeper.Git/GitCmdDriver.cs:line 52
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, NuGetSources sources, SettingsContainer settings, IReadOnlyCollection`1 updates) in <...>/NuKeeper/Engine/Packages/PackageUpdater.cs:line 75
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, IReadOnlyCollection`1 updates, NuGetSources sources, SettingsContainer settings) in <...>/NuKeeper/Engine/Packages/PackageUpdater.cs:line 46
Attempted 3 updates and did 0

where 2 things seems incorrect. First is running checkout in .git\ subdirectory and the second one is doubled origin in that checkout command.

In both situations I've run extension task with targetFolder = src because my project is structured like <repo_root>/src/, but NuGet restore and whole packages-to-update search process went well, so I don't think it's an issue.

Also I saw that in both situations logs are starting with:

<azure devops git path>\git.exe config --global user.name NuKeeper
<azure devops git path>\git.exe config --global user.email [email protected]

so it's not using both gitclipath and LibGit2Sharp there, but uses it in latter operations.

I can provide more info if needed.

@MarcBruins
Copy link
Member Author

Is there a branch in the branching tab on azure devops?

@baterja
Copy link

baterja commented Nov 22, 2019

There's a feature/NuKeeper branch for which this pipeline was run. Branch named nukeeper-update-Newtonsoft.Json-to-<correct version> doesn't exist on Azure Devops under feature/ or anywhere else.

@baterja
Copy link

baterja commented Nov 27, 2019

Should I create separate issue or maybe that one could be reopened?

@Bouke
Copy link
Contributor

Bouke commented Mar 25, 2020

I'm running into the same issue on Azure DevOps:

Updating 'EntityFramework6.Npgsql' from 6.4.0 to 6.4.1 in 5 projects
Updates failed NameConflictException : failed to write reference 'refs/heads/nukeeper/nukeeper-update-EntityFramework6.Npgsql-to-6.4.1': a reference with that name already exists.

There exists no such branch.

@greengumby
Copy link

I'm running into the same issue on Azure DevOps. Did this get solved?

@ykysel
Copy link

ykysel commented Sep 7, 2020

@AnthonySteele I'm running into the same issue too. Azure have no such branch, but issue still appear.
@greengumby @Bouke, have you fixed that somehow?

Using branch name: 'nukeeper-update-4-packages-01C74E6642BE3E6B46C76535EDDA791B'
Git checkout new branch 'nukeeper-update-4-packages-01C74E6642BE3E6B46C76535EDDA791B'
Updates failed NameConflictException : failed to write reference 'refs/heads/nukeeper-update-4-packages-01C74E6642BE3E6B46C76535EDDA791B': a reference with that name already exists.
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Proxy.git_branch_create_from_annotated(RepositoryHandle repo, String branch_name, String targetIdentifier, Boolean force)
at LibGit2Sharp.BranchCollection.Add(String name, String committish, Boolean allowOverwrite)
at NuKeeper.Git.LibGit2SharpDriver.<>c__DisplayClass13_0.b__0() in d:\a\r1\a_NuKeeper PR Build\drop\NuKeeper.Git\LibGit2SharpDriver.cs:line 123
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, NuGetSources sources, SettingsContainer settings, IReadOnlyCollection1 updates) in d:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 75 at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, IReadOnlyCollection1 updates, NuGetSources sources, SettingsContainer settings) in d:\a\r1\a_NuKeeper PR Build\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 46

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

6 participants