From 7122d738b132dd8ceaec9c837df853ef9a09e26c Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 10 Jun 2021 09:47:56 +0900 Subject: [PATCH] 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. --- include/gitlab.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 -- 2.47.3