From: Matthias Kruk Date: Tue, 8 Jun 2021 07:54:30 +0000 (+0900) Subject: include/gitlab: Add function for querying merge requests X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=bb3bc62f8b03c4325dfa17bbee4a68a3617aaf50;p=toolbox include/gitlab: Add function for querying merge requests This commit adds the gitlab_project_get_merge_requests() function, which fetches all open merge requests for a given project. --- diff --git a/include/gitlab.sh b/include/gitlab.sh index e990dd9..f15cfa5 100755 --- a/include/gitlab.sh +++ b/include/gitlab.sh @@ -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