Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2024-01-13 15:27:34 +0100
committerChristian Heusel <christian@heusel.eu>2024-01-21 23:28:29 +0100
commit96f39525bf60a499aa840015159d9040b53be69a (patch)
tree7110dc2fad45fd38edf6444891dbb9ade5640ad2
parent03d5c928cf01e2aee56a4520ac5896c602fb1f75 (diff)
feat(version): support nvchecker keyfile from user config home
This adds support for global keyfile from the user config home XDG_CONFIG_HOME which allows to set tokens for GitHub and GitLab for certain nvchecker configuration. When ~/.config/nvchecker/keyfile.toml exists, it will automatically be appended as keyfile of the local .nvchecker.toml file. Component: pkgctl version check Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--doc/man/pkgctl-version-check.1.asciidoc8
-rw-r--r--src/lib/version/check.sh12
2 files changed, 18 insertions, 2 deletions
diff --git a/doc/man/pkgctl-version-check.1.asciidoc b/doc/man/pkgctl-version-check.1.asciidoc
index 97d8c47..ed9abdf 100644
--- a/doc/man/pkgctl-version-check.1.asciidoc
+++ b/doc/man/pkgctl-version-check.1.asciidoc
@@ -18,7 +18,13 @@ which this package could possibly be upgraded.
The current working directory is used if no PKGBASE is specified.
-See the section on configuration files in **nvchecker**(1) for possible options
+Configuration
+-------------
+
+To provide GitHub or GitLab tokens to nvchecker, a `keyfile.toml` will be
+supplied from `$XDG_CONFIG_HOME`/nvchecker.
+
+See the section on configuration files in linkman:nvchecker[1] for possible options
which can be utilized in .nvchecker.toml.
Options
diff --git a/src/lib/version/check.sh b/src/lib/version/check.sh
index c78e364..600a346 100644
--- a/src/lib/version/check.sh
+++ b/src/lib/version/check.sh
@@ -23,6 +23,9 @@ pkgctl_version_check_usage() {
The current working directory is used if no PKGBASE is specified.
+ To provide GitHub or GitLab tokens to nvchecker, a keyfile.toml
+ will be supplied from \${XDG_CONFIG_HOME}/nvchecker.
+
OPTIONS
-h, --help Show this help text
@@ -110,6 +113,8 @@ get_upstream_version() {
local config=.nvchecker.toml
local output errors upstream_version
local output
+ local opts=()
+ local keyfile="${XDG_CONFIG_HOME:-${HOME}/.config}/nvchecker/keyfile.toml"
# check nvchecker config file
if ! errors=$(nvchecker_check_config "${config}"); then
@@ -117,7 +122,12 @@ get_upstream_version() {
return 1
fi
- if ! output=$(nvchecker --file "${config}" --logger json 2>&1 | \
+ # populate keyfile to nvchecker opts
+ if [[ -f ${keyfile} ]]; then
+ opts+=(--keyfile "${keyfile}")
+ fi
+
+ if ! output=$(nvchecker --file "${config}" --logger json "${opts[@]}" 2>&1 | \
jq --raw-output 'select(.level != "debug")'); then
printf "failed to run nvchecker: %s" "${output}"
return 1