From 5e22e4f81e61f4ad2228366439be00b691284894 Mon Sep 17 00:00:00 2001 From: Christian Heusel Date: Mon, 13 Feb 2023 14:58:42 +0100 Subject: config: allow suppying the gitlab token via env var This would allow to supply the gitlab tokens via the env var DEVTOOLS_GITLAB_TOKEN and therefore allow users to choose whatever program they want to fill this env var. Closes #113 Signed-off-by: Christian Heusel Signed-off-by: Levente Polyak --- src/lib/config.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/lib/config.sh') diff --git a/src/lib/config.sh b/src/lib/config.sh index 5034c6e..ba6532e 100644 --- a/src/lib/config.sh +++ b/src/lib/config.sh @@ -14,11 +14,15 @@ readonly XDG_DEVTOOLS_GITLAB_CONFIG="${XDG_DEVTOOLS_DIR}/gitlab.conf" export GITLAB_TOKEN="" load_devtools_config() { - if [[ ! -f "${XDG_DEVTOOLS_GITLAB_CONFIG}" ]]; then - GITLAB_TOKEN="" + if [[ -n "${DEVTOOLS_GITLAB_TOKEN}" ]]; then + GITLAB_TOKEN="${DEVTOOLS_GITLAB_TOKEN}" return fi - GITLAB_TOKEN=$(grep GITLAB_TOKEN "${XDG_DEVTOOLS_GITLAB_CONFIG}"|cut -d= -f2|cut -d\" -f2) + if [[ -f "${XDG_DEVTOOLS_GITLAB_CONFIG}" ]]; then + GITLAB_TOKEN=$(grep GITLAB_TOKEN "${XDG_DEVTOOLS_GITLAB_CONFIG}"|cut -d= -f2|cut -d\" -f2) + return + fi + GITLAB_TOKEN="" } save_devtools_config() { -- cgit v1.2.3-70-g09d2