【问题标题】:LibGit2Sharp Cloning from a network file shareLibGit2Sharp 从网络文件共享克隆
【发布时间】:2017-10-02 22:42:22
【问题描述】:

当远程托管在网络驱动器上时,我在使用文件传输进行克隆时遇到问题。

我下载了项目并尝试添加一些测试用例:

[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

根据this TechNet article 将 DWORD 值设置为 1 - 在这种情况下克隆成功。但是,在我的情况下,这不是一个可行的解决方案,因为它会在注重安全的环境中引发部署问题。

LibGit2Sharp 似乎无法从文件 UNC 克隆。我是否理解正确,如果是,有什么办法可以解决这个问题?

【问题讨论】:

  • 1) 如果您与我们分享您的测试助手的勇气,这可能会有所帮助。 2)如果你使用反斜杠而不是正斜杠,有什么区别吗?
  • 很高兴发布它,但它只是来自 LibGit2Sharp 的现有套件。我尝试了许多正斜杠和反斜杠的组合,都给出了相同的结果。

标签: libgit2sharp


【解决方案1】:

file:/// URL 语法不适用于 UNC 路径。只需使用 UNC 路径,例如:

\\192.168.1.1\Share\TestRepo.git

这也适用于 LibGit2Sharp 和 git 命令行客户端。

【讨论】:

  • 谢谢。我确定我在做一些愚蠢的事情,但我仍然无法让它发挥作用。我将我的第一个测试用例更改为:\\192.168.1.1\Share\TestRepo.git,并得到LibGit2Sharp.LibGit2SharpException : failed to resolve path 'file://192.168.1.1/Share/TestRepo.git': The filename, directory name, or volume label syntax is incorrect.
  • 我查看了 CloneFixture 测试类并找到了文件系统克隆测试(CanCloneALocalRepositoryFromALocalUriCanCloneALocalRepositoryFromAStandardPath),但找不到任何用于从非本地驱动器克隆的测试。我找错地方了吗?
  • 嗯。让我看看,这里可能有什么退步了。
猜你喜欢
  • 1970-01-01
  • 2019-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多