Skip to content

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 #629

@dagood

Description

@dagood

The 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 dotnet/arcade#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 (f225c7a 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)

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