ParallelGitJava NIO 內(nèi)存文件系統(tǒng)
ParallelGit 是為 Git 應(yīng)用準(zhǔn)備的高性能 Java NIO 內(nèi)存文件系統(tǒng)。ParallelGit 是基于 JGit 構(gòu)建的, 可以幫助 Java 項(xiàng)目快速的訪問 Git 文件。
ParallelGit 可以幫助你操作本地 Git倉庫,允許你通過 Java 7 nio 文件系統(tǒng)接口來訪問 Git 倉庫,達(dá)到跟原生文件系統(tǒng)一樣的體驗(yàn)。
示例
Create Repository
public Repository createProjectRepository() {
File dir = new File("/home/project/repo");
return RepositoryUtils.createRepository(dir);
}
Create Branch
public void branchFromMaster(String newBranch, Repository repo) {
BranchUtils.createBranch(newBranch, "master", repo)
}
Read File
public void printFile(String filename, Repository repo) {
byte[] blob = GitFileUtils.readFile(filename, "master", repo);
String text = new String(blob);
System.out.println(text);
}評(píng)論
圖片
表情
