]> git.corax.cc Git - toolbox/commitdiff
include/gitlab: Add function for querying merge requests
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Tue, 8 Jun 2021 07:54:30 +0000 (16:54 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Tue, 8 Jun 2021 07:54:30 +0000 (16:54 +0900)
This commit adds the gitlab_project_get_merge_requests() function,
which fetches all open merge requests for a given project.

include/gitlab.sh

index e990dd9649f2b16b38738b08fd6ab89f28a572ed..f15cfa549adda54f0bf948c79f3481f9e8803554 100755 (executable)
@@ -302,6 +302,25 @@ gitlab_project_get_branches() {
        return 0
 }
 
+gitlab_project_get_merge_requests() {
+       local host="$1"
+       local token="$2"
+       local project="$3"
+
+       local url
+       local resp
+
+       project=$(_gitlab_urlencode "$project")
+       url="$host/api/v4/projects/$project/merge_requests?state=opened"
+
+       if ! resp=$(_gitlab_get "$token" "$url"); then
+               return 1
+       fi
+
+       echo "$resp"
+       return 0
+}
+
 gitlab_get_project_id() {
        local host
        local token