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

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

Open
dagood opened this issue Jul 13, 2020 · 7 comments

Comments

@dagood
Copy link
Member

dagood commented Jul 13, 2020

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)

@tmat
Copy link
Member

tmat commented Jul 13, 2020

Couldn't you set the origin remote to the original local repo?

@dagood
Copy link
Member Author

dagood commented Jul 13, 2020

Couldn't you set the origin remote to the original local repo?

The isolated repo's origin is already set up to point at the original repo in the repro case, unless you mean something different:

$ (cd dev; git remote -v)
dotnet  https://github.com/dotnet/sourcelink (fetch)
dotnet  https://github.com/dotnet/sourcelink (push)

$ (cd isolated; git remote -v)
origin  /work/dev (fetch)
origin  /work/dev (push)

@tmat
Copy link
Member

tmat commented Jul 13, 2020

Yes, that's what I mean. Keeping origin set to /work/dev should make SourceLink work. If the origin points to a local directory SourceLink looks into the target repo git data and extracts origin from there.

@dagood
Copy link
Member Author

dagood commented Jul 13, 2020

Cool, since it doesn't work in practice, is this a valid bug that you think will be fixed sometime soon?

@tmat
Copy link
Member

tmat commented Jul 13, 2020

The indirection actually works based on the reported warning.
Do you see the warning not reported if built from dev directory and reported from isolated?

@dagood
Copy link
Member Author

dagood commented Jul 13, 2020

Do you see the warning not reported if built from dev directory and reported from isolated?

Yep. This is the behavior described in dotnet/arcade#3236 (comment), which I suppose isn't working correctly after sourcelink hops over to the original local repo:

BTW, currently we first check for origin then for any other remote (the first one).

@tmat
Copy link
Member

tmat commented Jul 13, 2020

I see. OK.

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

No branches or pull requests

2 participants