From: Matthias Kruk Date: Wed, 19 May 2021 23:26:24 +0000 (+0900) Subject: include/gitlab: Add method to query the current user X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=67b70315a282c689dcfdd184f32aab26dc9ffb10;p=toolbox 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. --- 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