Jgit无法克隆启用了Git LFS的代码库

3
当前设置

我有一个启用了git lfs的存储库。访问存储lfs内容的驱动器时,还存在另一级身份验证。在从命令提示符运行下面的代码时,它会要求输入用户名和密码以访问lfs内容,如下所示:

JGIT LFS issue

如果我们使用没有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);
    }
}
1个回答

0

这似乎与此错误相关:https://bugs.eclipse.org/bugs/show_bug.cgi?id=535814

从代码来看,SmudgeFilter.downloadLfsResource() 使用 getLfsConnection(),该函数处理 SSH 认证但不处理 HTTP 认证。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接