RFR: 1407: GitLabMergeRequest#filesUrl returns wrong result
Guoxiong Li
gli at openjdk.java.net
Mon Apr 25 13:25:54 UTC 2022
On Mon, 25 Apr 2022 13:13:11 GMT, Erik Joelsson <erikj at openjdk.org> wrote:
>> Hi all,
>>
>> The SKARA-744 [1][2] solved a problem about the link to the changes for just one commit. But it didn't solve the issue completely in GitLab. Please see the current issue [3] for more information.
>>
>> This patch revises `GitLabMergeRequest#filesUrl` to return a `version url` if it exists which can represent the changed files **from the first commit to the provided commit HASH**. A corresponding test is added and a previous test is polished.
>>
>> You can use the following config to run the new test `GitLabRestApiTest#testFilesUrl`:
>>
>>
>> gitlab.user=<your username in https://gitlab.com>
>> gitlab.pat=<your token in https://gitlab.com>
>>
>> gitlab.uri=https://gitlab.com
>> gitlab.repository=35596381
>> gitlab.merge.request.id=1
>>
>> gitlab.version.hash=60f39eb698e73cc2660f870667a54e7a53ee7018
>> gitlab.version.url=https://gitlab.com/lgxbslgx/test/-/merge_requests/1/diffs?diff_id=379601911
>> gitlab.nonversion.hash=c9b5a70790b13c3e7e182c9b83015f9f10d53df7
>> gitlab.nonversion.url=https://gitlab.com/lgxbslgx/test/-/merge_requests/1/diffs?commit_id=c9b5a70790b13c3e7e182c9b83015f9f10d53df7
>>
>> Thanks for taking the time to review.
>>
>> Best Regards,
>> -- Guoxiong
>>
>> [1] https://bugs.openjdk.java.net/browse/SKARA-744
>> [2] https://git.openjdk.java.net/skara/commit/f16663b7
>> [3] https://bugs.openjdk.java.net/browse/SKARA-1407
>
> forge/src/main/java/org/openjdk/skara/forge/gitlab/GitLabMergeRequest.java line 846:
>
>> 844: var versionId = request.get("versions").execute().stream()
>> 845: .filter(version -> hash.hex().equals(version.get("head_commit_sha").asString()))
>> 846: .map(version -> String.valueOf(version.get("id").asInt()))
>
> I don't think we need to convert this to an int to then just create a string again.
The `id` field of a `version` is a int type in the json so that `version.get("id").asString()` will throw a exception.
-------------
PR: https://git.openjdk.java.net/skara/pull/1304
More information about the skara-dev
mailing list