From: Matthias Kruk Date: Thu, 10 Jun 2021 00:47:56 +0000 (+0900) Subject: include/gitlab: Add function to retrieve all merge requests X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=7122d738b132dd8ceaec9c837df853ef9a09e26c;p=toolbox include/gitlab: Add function to retrieve all merge requests 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. --- diff --git a/include/gitlab.sh b/include/gitlab.sh index f15cfa5..a4cbb7d 100755 --- a/include/gitlab.sh +++ b/include/gitlab.sh @@ -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