Uploaded image for project: 'Skara'
  1. Skara
  2. SKARA-1407

GitLabMergeRequest#filesUrl returns wrong result

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.0
    • None
    • bots
    • None

      When solving SKARA-1395 [1], I find the method `GitLabMergeRequest#filesUrl` returns wrong result.

      **GitHub** uses the following first url to get the changed files **from the first commit to the commit HASH** and uses the second url to get the changed files of **the current commit HASH**.

      https://github.com/ORG/REPO/pull/PR_NUM/files/HASH
      https://github.com/ORG/REPO/pull/PR_NUM/commits/HASH

      **GitLab** uses the following first url to get the changed files **from the first commit to the commit HASH** and uses the second url to get the changed files of **the current commit HASH**.

      https://gitlab.com/ORG/REPO/-/merge_requests/PR_NUM/diffs?diff_id=DIFF_ID
      https://gitlab.com/ORG/REPO/-/merge_requests/PR_NUM/diffs?commit_id=HASH

      The method `GitHubPullRequest#filesUrl` uses the first class url which is right. But in GitLabMergeRequest, it uses the second class url (diffs?commit_id=HASH) which only return the changed files of the current commit. The method `GitLabMergeRequest#filesUrl` needs to be adjusted to use `diff_id=DIFF_ID`. But we don't have the `DIFF_ID` now and need more investigation.

      The related code is listed below for convenience.
      ```
      // file GitHubPullRequest
          public URI filesUrl(Hash hash) {
              var endpoint = "/" + repository.name() + "/pull/" + id() + "/files/" + hash.hex();
              return host.getWebURI(endpoint);
          }

      // file GitLabMergeRequest
          public URI filesUrl(Hash hash) {
              var endpoint = "/" + repository.name() + "/-/merge_requests/" + id() + "/diffs?commit_id=" + hash.hex();
              return host.getWebUri(endpoint);
          }
      ```

      [1] https://bugs.openjdk.java.net/browse/SKARA-1395

            gli Guoxiong Li
            gli Guoxiong Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: