aboutsummaryrefslogtreecommitdiff
path: root/contrib/cpt-maintainer
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-07-27 09:24:26 +0000
committermerakor <cem@ckyln.com>2021-07-27 09:24:26 +0000
commitab960e47945033bea128474a255ccf52ea1ddf6c (patch)
tree4ce7f857fcba417dbe709bf7a6ec1b61e8053f60 /contrib/cpt-maintainer
parentd8bb119df5965b154719958656032e38abc52ec3 (diff)
parent57093831d9c125b1ee872ecf21792324d2238354 (diff)
downloadcpt-ab960e47945033bea128474a255ccf52ea1ddf6c.tar.gz
blake3: merge trunk
FossilOrigin-Name: 8bba905c9082ee971fbe79d4be7eaa96072362689725add1f5341c0ec1d282fa
Diffstat (limited to 'contrib/cpt-maintainer')
-rwxr-xr-xcontrib/cpt-maintainer49
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