diff options
author | merakor <cem@ckyln.com> | 2021-07-22 10:07:40 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-07-22 10:07:40 +0000 |
commit | 9fee0d52ae7327c3b781bf24cb595342cd8a6193 (patch) | |
tree | abc940347bd2eb5aefeb83f9351c88fb7c5cd12c | |
parent | 65ec949d495b5b85d73bbae025195ae0cb8e1c8b (diff) | |
download | cpt-9fee0d52ae7327c3b781bf24cb595342cd8a6193.tar.gz |
cpt-maintainer: add tool to display the maintainer of the given package
FossilOrigin-Name: aa2c95809a8569425002c8e5a6993df7830ccfbf3ade159d5b9da829992a7a7f
-rwxr-xr-x | contrib/cpt-maintainer | 49 |
1 files changed, 49 insertions, 0 deletions
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 |