当遥控器在网络驱动器上托管时,我会使用文件传输克隆问题。
我下载了该项目,并尝试添加一些测试用例:
[Fact]
public void CanCloneALocalRepositoryFromANetworkDriveUri()
{
var networkPath = @"file:///192.168.1.1/Share/TestRepo.git";
var uri = new Uri(networkPath);
AssertLocalClone(uri.AbsoluteUri, BareTestRepoPath);
}
失败:
LibGit2Sharp.LibGit2SharpException : failed to resolve path 'file://192.168.1.1/Share/TestRepo.git': The filename, directory name, or volume label syntax is incorrect.
我尝试将驱动器(z :)映射到共享中,然后运行以下内容:
[Fact]
public void CanCloneALocalRepositoryFromAMappedNetworkDrive()
{
var networkPath = @"file:///Z:/TestRepo.git";
var uri = new Uri(networkPath);
AssertLocalClone(uri.AbsoluteUri, BareTestRepoPath);
}
失败:
LibGit2Sharp.LibGit2SharpException : failed to resolve path 'Z:/TestRepo.git': The system cannot find the path specified.
除非我设置:
HKLM Software Microsoft Windows CurrentVersion Policies System EnableLinkedConnections
按照这一技术文章,d字值为1-在这种情况下,克隆成功。但是,在我的情况下,这不是一个可行的解决方案,因为它在安全意识环境中提出了部署问题。
看来libgit2sharp无法从文件UNC克隆。我是否正确理解了,如果可以的话,有任何方法可以解决这个问题吗?
file:///
URL语法不适合UNC路径。只需使用UNC路径,例如:
\192.168.1.1ShareTestRepo.git
这也可以在libgit2sharp和git命令行客户端。