From 67b70315a282c689dcfdd184f32aab26dc9ffb10 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 20 May 2021 08:26:24 +0900 Subject: [PATCH] include/gitlab: Add method to query the current user This commit adds the gitlab_get_current_user() function, which allows the caller to retrieve a JSON object containing information about the current GitLab user. --- include/gitlab.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/gitlab.sh b/include/gitlab.sh index 7fa6ac0..00cac8e 100755 --- a/include/gitlab.sh +++ b/include/gitlab.sh @@ -139,6 +139,21 @@ gitlab_user_list() { return 0 } +gitlab_get_current_user() { + local host="$1" + local token="$2" + + local url + + url="$host/api/v4/user" + + if ! _gitlab_get "$token" "$url"; then + return 1 + fi + + return 0 +} + gitlab_get_user_id() { local host local token -- 2.47.3