当我们这样做时,git log --shortstat我们得到插入,删除和更改的行数.就像是:
1 file changed, 9 insertions(+), 3 deletions(-)
Run Code Online (Sandbox Code Playgroud)
请帮助我获取插入,删除和更改的行数.
我正在做一个存储库克隆来获取本地机器上的git项目.这是相同的代码:
RepoClone repoClone=new RepoClone();
repoClone.repoCloner();
repository = builder.setGitDir(repoClone.repoDir).setMustExist(true).build();
Run Code Online (Sandbox Code Playgroud)我甚至能得到一个TreeWalk:
TreeWalk treeWalk=getCommitsTreeWalk();
Run Code Online (Sandbox Code Playgroud)我能够检索文件名,每个文件的提交次数,LOC以及处理每个xml/java文件的开发人员数量.
while (treeWalk.next()) {
if (treeWalk.getPathString().endsWith(".xml") || treeWalk.getPathString().endsWith(".java")) {
jsonDataset = new JSONObject();
countDevelopers = new HashSet < String > ();
count = 0;
logs = new Git(repository).log().addPath(treeWalk.getPathString()).call();
for (RevCommit rev: logs) {
countDevelopers.add(rev.getAuthorIdent().getEmailAddress());
count++;
}
jsonDataset.put("FileName", treeWalk.getPathString());
jsonDataset.put("CountDevelopers", countDevelopers.size());
jsonDataset.put("CountCommits", count);
jsonDataset.put("LOC", countLines(treeWalk.getPathString()));
commitDetails.put(jsonDataset);
}
}
Run Code Online (Sandbox Code Playgroud)现在,我想检索每个文件插入和删除的行数.
请帮忙.提前感谢.