Compare commits

...

5 Commits

Author SHA1 Message Date
Ivan Shapovalov
10fe592862 Merge branch 'work/fix-pkgctl-version-upgrade' into 'master'
fix(pkgctl): handle pkgver values containing regex metacharacters

See merge request archlinux/devtools!311
2025-08-10 01:44:04 +00:00
Jakub Klinkovský
fc56ebedf3 fix(completion): fix bash completion for the license subcommand
Signed-off-by: Jakub Klinkovský <lahwaacz@archlinux.org>
2025-08-05 17:48:12 +02:00
Christian Heusel
01757e6904 fix(commitpkg): Quiet git ls-files output
So far all files in `needsversioning=(...)` have been printed to the
command line if they were found, which is not useful, especially now
that we have more files present there.

It makes sense however to keep the standard error output, as this gives
a actionable suggestion what one should to to fix the issue:

    > error: pathspec 'PKGBUILD' did not match any file(s) known to git
    > Did you forget to 'git add'?

Fixes #281

Signed-off-by: Christian Heusel <christian@heusel.eu>
2025-08-01 11:26:57 +02:00
Daniel M. Capella
c5fe8ff3e6 feat(license): Extend matches for sysusers/tmpfiles configs
Eg. to match:
- sysusers.conf
- $pkgname.sysusers
- $pkgname.sysusers.conf
2025-07-28 23:38:32 -04:00
Ivan Shapovalov
0f925322e5 fix(pkgctl): handle pkgver values containing regex metacharacters
`pkgbuild_set_pkgver()` used the value of `$pkgver` directly in regular
expressions, which breaks if said value happens to contain e.g. a `+`.
Fix this by escaping all possible regex metacharacters in `$pkgver`.
2025-04-11 20:25:18 +07:00
4 changed files with 11 additions and 1 deletions

View File

@@ -150,6 +150,7 @@ _pkgctl_cmds=(
db db
diff diff
issue issue
license
release release
repo repo
search search

View File

@@ -155,7 +155,7 @@ if (( ${#needsversioning[*]} )); then
if [[ ! -f "${file}" ]]; then if [[ ! -f "${file}" ]]; then
continue continue
fi fi
if ! git ls-files --error-unmatch "$file"; then if ! git ls-files --error-unmatch "$file" >/dev/null; then
die "%s is not under version control" "$file" die "%s is not under version control" "$file"
fi fi
done done

View File

@@ -191,7 +191,9 @@ path = [
".nvchecker.toml", ".nvchecker.toml",
"*.install", "*.install",
"*.sysusers", "*.sysusers",
"*sysusers.conf",
"*.tmpfiles", "*.tmpfiles",
"*tmpfiles.conf",
"*.logrotate", "*.logrotate",
"*.pam", "*.pam",
"*.service", "*.service",

View File

@@ -14,6 +14,11 @@ source /usr/share/makepkg/util/schema.sh
set -eo pipefail set -eo pipefail
# escapes regex metacharacters in a given string
_escape_pkgver() {
# shellcheck disable=SC2001
sed 's:[\^.\[$()|*+?{\\]:\\&:g' <<<"$1"
}
# set the pkgver variable in a PKGBUILD # set the pkgver variable in a PKGBUILD
# assumes that the pkgbuild is sourced to detect the presence of a pkgver function # assumes that the pkgbuild is sourced to detect the presence of a pkgver function
@@ -21,6 +26,8 @@ pkgbuild_set_pkgver() {
local new_pkgver=$1 local new_pkgver=$1
local pkgver=${pkgver} local pkgver=${pkgver}
pkgver="$(_escape_pkgver "${pkgver}")"
if [[ $(type -t pkgver) == function ]]; then if [[ $(type -t pkgver) == function ]]; then
# TODO: check if die or warn, if we provide _commit _gitcommit setter maybe? # TODO: check if die or warn, if we provide _commit _gitcommit setter maybe?
warning 'setting pkgver variable has no effect if the PKGBUILD has a pkgver() function' warning 'setting pkgver variable has no effect if the PKGBUILD has a pkgver() function'