summaryrefslogtreecommitdiff
path: root/gitlab/cli.py
diff options
context:
space:
mode:
authorEmanuele Aina <emanuele.aina@collabora.com>2022-11-21 19:20:54 +0100
committerNejc Habjan <hab.nejc@gmail.com>2022-11-21 23:38:59 +0100
commit65abb85be7fc8ef57b295296111dac0a97ed1c49 (patch)
tree972b3b961a60e6dc69143a80904975a7befd0c8e /gitlab/cli.py
parentd8a657b2b391e9ba3c20d46af6ad342a9b9a2f93 (diff)
downloadgitlab-65abb85be7fc8ef57b295296111dac0a97ed1c49.tar.gz
fix(cli): Enable debug before doing auth
Authentication issues are currently hard to debug since `--debug` only has effect after `gl.auth()` has been called. For example, a 401 error is printed without any details about the actual HTTP request being sent: $ gitlab --debug --server-url https://gitlab.com current-user get 401: 401 Unauthorized By moving the call to `gl.enable_debug()` the usual debug logs get printed before the final error message. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r--gitlab/cli.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index 5cf8e2d..2495f0a 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -366,14 +366,13 @@ def main() -> None:
try:
gl = gitlab.Gitlab.merge_config(vars(options), gitlab_id, config_files)
+ if debug:
+ gl.enable_debug()
if gl.private_token or gl.oauth_token:
gl.auth()
except Exception as e:
die(str(e))
- if debug:
- gl.enable_debug()
-
gitlab.v4.cli.run(
gl, gitlab_resource, resource_action, args_dict, verbose, output, fields
)