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
**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
- relates to
-
SKARA-1395 The "Review applies to <commit>" link is misleading
-
- Resolved
-
-
SKARA-1408 GitLabMergeRequest#reviews sometimes finds the wrong commit HASH
-
- Resolved
-