1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-07-02 14:02:26 +00:00
kiss/contrib/kiss-maintainer
aabacchus 800d3ac854 kiss-maintainer: fix CRUX-style usage
Commit d94c811 changed `sort -u` to `uniq -u`; these are not equivalent.
`uniq -u` suppresses all duplicate lines, but `sort -u` removes all but
one. In the case of there being no command-line args, PWD is taken as
the package, and if that package is in a repo already in KISS_PATH, the
repo will be in KISS_PATH twice. This will cause the `kiss search`
command to give two entries for PWD, and `uniq -u` removes both.
Revert to `sort -u` to keep one of those entries.

If the package in PWD is not installed, there will be not entries left;
if it is installed, kiss-maintainer will try to get the history from
/var/db/kiss/installed/pkg, which is not a git repo.

Example of the incorrect behaviour:
    KISS_PATH=/home/me/repo/core
    PWD=/home/me/repo/core/musl
    $ sh -x /usr/bin/kiss-maintainer
    + '['  ]
    + export 'KISS_PATH=/home/me/repo/core::/home/me/repo/core'
    + set -- musl
    + kiss search musl
    + uniq -u
    + read -r repo
    + read -r repo
    + cd /var/db/kiss/installed/musl
    + git log -1 version
    + m=
    + :
    + m=
    + m=
    + '['  ]
    + continue
    + read -r repo

    (no output)
2022-08-05 21:24:43 +05:30

19 lines
419 B
Bash
Executable File

#!/bin/sh -ef
# Find the maintainer of a package
# Use the current directory as the package name if no package is given.
[ "$1" ] || {
export KISS_PATH=${PWD%/*}:$KISS_PATH
set -- "${PWD##*/}"
}
kiss search "$@" | sort -u | while read -r repo; do cd "$repo"
m=$(git log -1 version 2>/dev/null) ||:
m=${m##*Author: }
m=${m%%>*}
[ "$m" ] || continue
printf '=> %s\n%s>\n' "$PWD" "$m"
done