When the "origin" remote points to a local directory that itself doesn't have an "origin" remote, SourceLink emits warning/error even though it has a fallback
See original GitHub issueThe scenario is that I want to run a build on an isolated, clean new source tree, without throwing away work with git clean
on my dev repo. Thanks to git, git clone . <somewhere-else>
is inexpensive. But sourcelink makes the build fail if I don’t have an origin
remote on my dev repo.
This warning is a problem because there’s a strong standard in arcade-powered repos to have warning-as-error turned on.
I think that not having an origin
is considered valid as a sourcelink scenario, based on https://github.com/dotnet/arcade/issues/3236.
(For this specific scenario, a worktree might work better. However, in some cases it’s not good to have to manage .git/worktrees/*
in the originating repo, and there are still some Git versions on our build machines that doesn’t support worktree
. This is related to a source-build scenario I can get into more if desired, but that seems off topic for now.)
Here’s how to repro (f225c7a5 at the time):
git clone https://github.com/dotnet/sourcelink dev
git clone dev isolated
( cd dev; git remote rename origin dotnet )
( cd isolated; ./build.sh /bl )
Here’s the warning (as error): (RepositoryDoesNotHaveSpecifiedRemote
)
/work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/Microsoft.Build.Tasks.Git.targets(24,5): error : Repository ‘/work/dev’ does not have the specified remote ‘origin’; using ‘dotnet’ instead. [/work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj]
Microsoft.Build.Tasks.Git.LocateRepository
Assembly = /work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/../tools/netcoreapp2.0/Microsoft.Build.Tasks.Git.dll
Parameters
Path = /work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests
SourceLink: Reusing cached git repository information.
Errors
/work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/Microsoft.Build.Tasks.Git.targets(24,5): Repository '/work/dev' does not have the specified remote 'origin'; using 'dotnet' instead. [/work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj]
/work/.rhelhome/.nuget/packages/microsoft.build.tasks.git/1.1.0-beta-20206-02/build/Microsoft.Build.Tasks.Git.targets(24,5): Repository '/work/dev' does not have the specified remote 'origin'; using 'dotnet' instead. [/work/isolated/src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj]
OutputProperties
_GitRepositoryId = /work/isolated/.git
ScmRepositoryUrl = https://github.com/dotnet/sourcelink
SourceRevisionId = f225c7a58fb63c232505622642ad69c5b32523e2
OutputItems
SourceRoot
/work/isolated/
RevisionId = f225c7a58fb63c232505622642ad69c5b32523e2
ScmRepositoryUrl = https://github.com/dotnet/sourcelink
SourceControl = git
Binlog: sourcelink-no-origin-local.zip
Workaround: disable sourcelink when building this way. (/p:EnableSourceControlManagerQueries=false /p:EnableSourceLink=false
)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
I see. OK.
Yep. This is the behavior described in https://github.com/dotnet/arcade/issues/3236#issuecomment-508964579, which I suppose isn’t working correctly after sourcelink hops over to the original local repo: