dotnet / sourcelink

Source Link enables a great source debugging experience for your users, by adding source control metadata to your built assets
MIT License
1.25k stars 122 forks source link

"Repository has no commit" error in case of worktree + packed-refs #1290

Open vikukush opened 1 day ago

vikukush commented 1 day ago

After git decided to pack my repo with several worktrees and a bunch of local branches, my builds started failing with following error:

D:\Corextroot\microsoft.build.tasks.git\8.0.0\build\Microsoft.Build.Tasks.Git.targets(25,5): Repository has no commit. [D:\Pl3\Test\UnitTests\Common\Tools.UnitTests.Common\Tools.UT.Common.csproj]

Sourcelink task is unable to handle this situation.

I have worked to add a unit test that covers my scenario: https://github.com/dotnet/sourcelink/pull/1289

vikukush commented 1 day ago

The issue went away after I created the very next commit, which created D:\Platform.git\refs\heads\user\vikukush\mstestv3 file, so the commit ID was no longer inside packed-refs. So the bug can be easily worked around, but this of course still needs to be fixed.