]> git.corax.cc Git - toolbox/commitdiff
include/gitlab: Add function to retrieve all merge requests
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Thu, 10 Jun 2021 00:47:56 +0000 (09:47 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Thu, 10 Jun 2021 00:47:56 +0000 (09:47 +0900)
This commit adds the gitlab_list_merge_requests() function, which allows
the caller to retrieve a list of merge requests for a given scope. If no
scope is specified, all merge requests that the user is assigned to will
be returned.

include/gitlab.sh

index f15cfa549adda54f0bf948c79f3481f9e8803554..a4cbb7dc8a4fd2a194ea6d34e85a5209475c6868 100755 (executable)
@@ -321,6 +321,28 @@ gitlab_project_get_merge_requests() {
        return 0
 }
 
+gitlab_list_merge_requests() {
+       local host="$1"
+       local token="$2"
+       local scope="$3"
+
+       local url
+       local resp
+
+       if [[ -z "$scope" ]]; then
+               scope="assigned_to_me"
+       fi
+
+       url="$host/api/v4/merge_requests?scope=$scope"
+
+       if ! resp=$(_gitlab_get "$token" "$url"); then
+               return 1
+       fi
+
+       echo "$resp"
+       return 0
+}
+
 gitlab_get_project_id() {
        local host
        local token