/**
* 获取指定分支、指定文件的内容
* @param gitRoot git仓库目录
* @param branchName 分支名称
* @param fileName 文件名称
* @return
* @throws Exception
*/
public static String getContentWithFile(String gitRoot, final String branchName, String fileName)
throws Exception {
final Git git = Git.open(new File(gitRoot));
Repository repository = git.getRepository();
repository = git.getRepository();
RevWalk walk = new RevWalk(repository);
Ref ref = repository.getRef(branchName);
if (ref == null) {
//获取远程分支
ref = repository.getRef(REF_REMOTES + branchName);
}
//异步pull
ExecutorService executor = Executors.newCachedThreadPool();
FutureTask<Boolean> task = new FutureTask<Boolean&
使用JGit获取指定分支的文件内容
最新推荐文章于 2023-11-07 09:56:48 发布