Current setup
I have a repository which is git lfs is enabled. There is another level of authentication present for accessing the drive where lfs content is stored. When I run the below code from command prompt it asks for the username and password for accessing the lfs content, as shown below.
If we use another repository where there is no authentication for the lfs content, then everything works fine. Please let me know how could I suppress the authentication from JGIT or how can I skip the fetching of LFS content. Please let me know if I am doing anything wrong.
Details:
1) Using following JGit version 4.9.0.201710071750-r
2) git lfs is installed
Code Snippet
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);
}
}