File: 001-handle-missing-config.patch

package info (click to toggle)
python-gitlab 1%3A1.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 892 kB
  • sloc: python: 5,400; sh: 201; makefile: 164
file content (26 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From: Federico Ceratto <federico@debian.org>
Subject: Handle missing config file
Forwarded: no

--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -140,8 +140,17 @@
     # any subparser setup
     (options, args) = parser.parse_known_args(sys.argv)
 
-    config = gitlab.config.GitlabConfigParser(options.gitlab,
-                                              options.config_file)
+    try:
+        config = gitlab.config.GitlabConfigParser(options.gitlab,
+                                                options.config_file)
+    except gitlab.config.ConfigError as e:
+        if "Impossible to get the gitlab id" in str(e):
+            sys.exit("""
+Please create a configuration file at ~/.python-gitlab.cfg
+See /usr/share/doc/gitlab-cli/examples/python-gitlab.cfg
+""")
+        sys.exit(e)
+
     cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version)
 
     # Now we build the entire set of subcommands and do the complete parsing