假设以下代码片段被提交到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)