Hi,
I’m looking for a way to find the line numbers in the source branch for the line numbers I get in the unified diff when using pullRequestService.streamDiff
Maybe an example helps to show my problem. Here’s how the unified diff looks like for a pull request in Bitbucket Server:
Here’s the file in the source branch of this pull request:
1 package com.mycompany.gui;
2
3 /**
4 * Hello world!
5 *
6 */
7 public class App
8 {
9 double d = Double.longBitsToDouble(42); // Noncompliant
10 public static void main( String[] args )
11 {
and here’s the file in the target branch of this pull request:
1 package com.mycompany.gui;
2
3 class Bar {
4 void foo() {
5 //FIXME
6 int i = 42;
7 int j = 43;
8 }
9 }
10
11 /**
12 * Hello world!
13 *
14 */
15 public class App
16 {
17 public static void main( String[] args )
18 {
19
20 }
Now as you can see, in the unified diff the line
double d = Double.longBitsToDouble(42); // Noncompliant
is shown on line 17. I need to map where this line comes in the pull request unified diff (17) back to the line number of the file in the source branch (9). Is there a way to accomplish this with the Bitbucket Server API?
Thanks in advance,
Michael