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

GitLabMergeRequest#reviews sometimes finds the wrong commit HASH

XMLWordPrintable

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

      Please consider the following steps:

      - the author creates "commit 1" locally
      - the author pushes it and creates a merge request, the Gitlab creates "version 1" (its hash is the hash of "commit 1") which has "commit 1"
      - the author creates "commit 2" locally
      - a reviewer approves the MR with the "version 1"
      - the author create "commit 3" locally
      - the author pushes the commits and the gitlab create "version 2" (its hash is the hash of "commit 3") which has "commit 1-3"

      When we use the method `GitLabMergeRequest#reviews` to get the reviews list, we can see the review hash is the hash of the "commit 2". But actually, the reviewer only approved "version 1" with "commit 1".

      We should use the `versions` instead of the `commits` to search the hash of the approval.

      The wrong code is shown below for convenience.

      ```
      // GitLabMergeRequest#reviews
              var commits = request.get("commits").execute().stream()
                                   .map(JSONValue::asObject)
                                   .map(obj -> {
                                       var ret = new CommitDate();
                                       ret.hash = new Hash(obj.get("id").asString());
                                       ret.date = ZonedDateTime.parse(obj.get("created_at").asString());
                                       return ret;
                                   })
                                   .collect(Collectors.toCollection(ArrayList::new));
      ```

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

              Created:
              Updated:
              Resolved: