小编gra*_*cey的帖子

使用JGIT,如何检索添加/删除行的行号

假设以下代码片段被提交到Git存储库:

int test(){
   int a = 3;
   int b = 4;
   int c = a + b;
   return c;
}
Run Code Online (Sandbox Code Playgroud)

并在以后更新为

int test(){
  return 7;
}
Run Code Online (Sandbox Code Playgroud)

我目前有一个方法,它使用JGit API来访问提交上述内容的Git存储库,并输出一个类似于以下内容的字符串:

int test(){
-int a = 3;
-int b = 4;
-int c = a + b;
-return c;
+return 7;
}
Run Code Online (Sandbox Code Playgroud)

现在,我的要求已经改变,并且只想知道更改行的行号.所以我想要以下内容:

2 -int a = 3;
3 -int b = 4;
4 -int c = a + b;
5 -return c;
2 +return 7;
Run Code Online (Sandbox Code Playgroud)

基本上,GitHub应用程序在进行更新时提供的信息相同.

任何帮助将不胜感激 :)

如何计算 - /+行的片段:

            String …
Run Code Online (Sandbox Code Playgroud)

java eclipse git jgit

9
推荐指数
2
解决办法
2388
查看次数

标签 统计

eclipse ×1

git ×1

java ×1

jgit ×1