]> git.corax.cc Git - toolbox/commitdiff
include/gitlab: Add method to query the current user
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Wed, 19 May 2021 23:26:24 +0000 (08:26 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Wed, 19 May 2021 23:26:24 +0000 (08:26 +0900)
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

index 7fa6ac0c7e069820a5f88a71fbd467a373d405c5..00cac8ef5e2b6dce9b87b409b1284d0565f24b2e 100755 (executable)
@@ -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