-
Notifications
You must be signed in to change notification settings - Fork 133
Description
I cloned a private Git repository to C:\REDACTED\http and ran a build. The LocateRepository task in Microsoft.Build.Tasks.Git 1.0.0 created a SourceRoot item with the correct directory path C:\REDACTED\http\:
Task "Microsoft.Build.Tasks.Git.LocateRepository"
Task Parameter:Path=C:\REDACTED\http\REDACTED
Output Property: _GitRepositoryId=C:\REDACTED\http\.git
Output Property: ScmRepositoryUrl=REDACTED
Output Item(s):
SourceRoot=
C:\REDACTED\http\
RevisionId=REDACTED
ScmRepositoryUrl=REDACTED
SourceControl=git
Output Property: SourceRevisionId=REDACTED
Done executing task "Microsoft.Build.Tasks.Git.LocateRepository".
Set Property: RepositoryType=git
Then, I created another worktree for the same repository: git worktree add ../apu
And ran a build in C:\REDACTED\apu. This time, the LocateRepository task created a SourceRoot item with the incorrect directory path C:\REDACTED\apu\.git\. The correct path would have been C:\REDACTED\apu\.
Task "Microsoft.Build.Tasks.Git.LocateRepository"
Task Parameter:Path=C:\REDACTED\apu\REDACTED
Output Property: _GitRepositoryId=C:\REDACTED\http\.git\worktrees\apu
Output Property: ScmRepositoryUrl=REDACTED
Output Item(s):
SourceRoot=
C:\REDACTED\apu\.git\
RevisionId=REDACTED
ScmRepositoryUrl=REDACTED
SourceControl=git
Output Property: SourceRevisionId=REDACTED
Done executing task "Microsoft.Build.Tasks.Git.LocateRepository".
Set Property: RepositoryType=git
C:\REDACTED\apu\.git is a file that contains gitdir: C:/REDACTED/http/.git/worktrees/apu.
C:\REDACTED\http\.git\worktrees\apu\gitdir is a file that contains C:/REDACTED/apu/.git.
The bug seems to be that GitRepository.GitWorkingDirectory expects the gitdir file to contain only the path of the worktree, without the trailing /.git:
| workingDirectory = File.ReadAllText(gitdirFilePath); |
According to the gitrepository-layout documentation though, .git is expected there.