From 9fee0d52ae7327c3b781bf24cb595342cd8a6193 Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 22 Jul 2021 10:07:40 +0000 Subject: cpt-maintainer: add tool to display the maintainer of the given package FossilOrigin-Name: aa2c95809a8569425002c8e5a6993df7830ccfbf3ade159d5b9da829992a7a7f --- contrib/cpt-maintainer | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 contrib/cpt-maintainer (limited to 'contrib') diff --git a/contrib/cpt-maintainer b/contrib/cpt-maintainer new file mode 100755 index 0000000..34f212f --- /dev/null +++ b/contrib/cpt-maintainer @@ -0,0 +1,49 @@ +#!/bin/sh -e +# Find the maintainer of a package + +## SYNOPSIS: +## .Nm +## .Op Ar pkg... + +## DESCRIPTION: +## .Nm +## finds the maintainer of the given pacage. If no package name is given, +## .Nm +## will use the name of the current directory as the package. + +# shellcheck disable=1091 +. cpt-lib + +usage() { + out "usage: ${0##*/} [pkg...]" + exit +} + +case $1 in + --help|-h) usage ;; + '') set -- "${PWD##*/}" +esac + +for pkgname; do + cpt-search -d "$pkgname" | while read -r pkg; do + # Default to the 'meta' file of the package instead of jumping through + # VCS hoops to find out. + log "$pkg" " " + pkg_query_meta "$pkg" maintainer && continue + + cd "$pkg" + # Use pkg_vcs_info to find out the repository type, but don't save + # repository information to the repository cache file. + repo_type=$(CPT_REPO_CACHE=0 pkg_vcs_info) + repo_type=${repo_type##*:} + + # We use the latest author who made a change to the version file to + # identify the maintainer of a package. + case $repo_type in + git) git log -1 --format='%an <%ae>' version ;; + fossil) fossil time par cur -n 1 -p version -F "%a" | sed \$d ;; + hg) hg log -l1 -T '{user}\n' -- version ;; + *) out "Maintainer information not available" + esac + done +done -- cgit v1.2.3