Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 启用git lfs的Jgit克隆存储库不工作_Java_Git Clone_Jgit_Git Lfs - Fatal编程技术网

Java 启用git lfs的Jgit克隆存储库不工作

Java 启用git lfs的Jgit克隆存储库不工作,java,git-clone,jgit,git-lfs,Java,Git Clone,Jgit,Git Lfs,当前设置 我有一个存储库,它是git lfs启用的。访问存储lfs内容的驱动器时,存在另一级别的身份验证。当我在命令提示符下运行下面的代码时,它会询问访问lfs内容的用户名和密码,如下所示 如果我们使用另一个没有对lfs内容进行身份验证的存储库,那么一切正常。 请告诉我如何禁止JGIT的身份验证,或者如何跳过LFS内容的获取。 如果我做错了什么,请告诉我 详情: 1) 使用以下JGit版本4.9.0.201710071750-r 2) 已安装git lfs 代码片段 public static

当前设置

我有一个存储库,它是git lfs启用的。访问存储lfs内容的驱动器时,存在另一级别的身份验证。当我在命令提示符下运行下面的代码时,它会询问访问lfs内容的用户名和密码,如下所示

如果我们使用另一个没有对lfs内容进行身份验证的存储库,那么一切正常。 请告诉我如何禁止JGIT的身份验证,或者如何跳过LFS内容的获取。 如果我做错了什么,请告诉我

详情:
1) 使用以下JGit版本4.9.0.201710071750-r
2) 已安装git lfs

代码片段

public static void syncRepository(String uname, String pwd, String url, String destDir) throws Exception{
    String branch =  "refs/heads/master";
    System.out.println("Cloning from ["+url+"] branch ["+branch+"] to ["+destDir.toString()+"]");
    String workingDirPath = null;
    try {
        if (StringUtils.isNotEmpty(destDir)) {
            workingDirPath = FilenameUtils.normalize(destDir);
        } else {
            throw new Exception("Working directory for code sync not found : " + destDir);
        }
        Path path = Paths.get(workingDirPath);
        System.out.println("Deleting '" +workingDirPath+ "' and re-creating empty destination dir" );
        recursivelyDelete(path.toFile());
        Files.createDirectories(Paths.get(workingDirPath));
        Path targetPath = path.resolve("");

        // clone repository
        Git git = cloneRepository(url, uname, pwd, branch, targetPath);
        System.out.println("Git revision # " + getLastHash(git));
        System.out.println("SYNC Repository completed");
    } catch (GitAPIException e) {
        // if the import fails then we should try to remove the created directory
        System.out.println("Failed to clone git repository."+ e);
        throw new Exception("Failed to clone git repository", e);
    }
}
private static Git cloneRepository(String url, String username, String password, String branch, Path targetPath)
        throws Exception {
    Git result;
    try {
        CloneCommand cloneCommand = Git.cloneRepository()
                .setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
                .setURI(url).setBranch(branch)
                .setDirectory(targetPath.toFile())
                .setTimeout(300)
                .setTransportConfigCallback(new TransportConfigCallback() {
                    public void configure(Transport transport) {
                        transport.setTimeout(300);
                    }
                });
        setCredentials(cloneCommand, username, password);
        result = cloneCommand.call();
        return result;
    } catch (GitAPIException e) {
        // if the import fails then we should try to remove the created directory
        throw new Exception("Failed to clone git repository", e);
    }
}

这似乎与此错误有关:

查看代码,SmudgeFilter.downloadLfsResource()使用getLfsConnection(),它处理SSH身份验证,但不处理HTTP身份验证

至少在我的测试中,下载失败,出现401异常(未授权),而不是提示输入凭据