Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2022-09-13 00:24:31 +0200
committerLevente Polyak <anthraxx@archlinux.org>2023-05-19 22:27:12 +0200
commitd15bd29a9d411dedc0a0682ec54b55e079d4f00f (patch)
treef65c08932c8723804fa55f7a8c5c7291b08d7ccf
parent95424a88eb11e06b7290fcabd6e3a6cf2b9cc9b3 (diff)
pkgrepo: add subcommand to open the packaging repository's website
This can be quite handy if a packager quickly wants to check the GitLab page for merge requests or but reports. Quickly calling a cli command inside the current packaging clone or with the pkgname provided will open the remote location inside the browser. Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--contrib/completion/zsh/_devtools.in6
-rw-r--r--src/pkgrepo.in67
2 files changed, 73 insertions, 0 deletions
diff --git a/contrib/completion/zsh/_devtools.in b/contrib/completion/zsh/_devtools.in
index 06e05e1..d30648a 100644
--- a/contrib/completion/zsh/_devtools.in
+++ b/contrib/completion/zsh/_devtools.in
@@ -19,6 +19,7 @@ _pkgrepo_cmds=(
"pkgrepo command"
"clone[Clone a package repository]"
"configure[Configure a clone according to distro specs]"
+ "web[Open the packaging repository's website]"
)
_pkgrepo_clone_args=(
@@ -35,6 +36,11 @@ _pkgrepo_configure_args=(
'*:git_dir:_files -/'
)
+_pkgrepo_web_args=(
+ '(-h --help)'{-h,--help}'[Display usage]'
+ '*:git_dir:_files -/'
+)
+
_arch_nspawn_args=(
'-C[Location of a pacman config file]:pacman_config:_files -g "*.conf(.)"'
'-M[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
diff --git a/src/pkgrepo.in b/src/pkgrepo.in
index 13f8847..c6f5951 100644
--- a/src/pkgrepo.in
+++ b/src/pkgrepo.in
@@ -28,6 +28,7 @@ usage() {
COMMANDS
clone Clone a package repository
configure Configure a clone according to distro specs
+ web Opens the packaging repository's website
OPTIONS
-h, --help Show this help text
@@ -72,6 +73,18 @@ usage_configure() {
_EOF_
}
+usage_web() {
+ cat <<- _EOF_
+ Usage: ${COMMAND} web [PKGNAME...]
+
+ Opens the packaging repository's website via xdg-open. If called with
+ no arguments, open the package cloned in the current working directory.
+
+ OPTIONS
+ -h, --help Show this help text
+_EOF_
+}
+
if (( $# < 1 )); then
usage
exit 1
@@ -107,6 +120,11 @@ while (( $# )); do
shift
break
;;
+ web)
+ WEB=1
+ shift
+ break
+ ;;
*)
die "invalid argument: %s" "$1"
;;
@@ -184,6 +202,26 @@ elif (( CONFIGURE )); then
;;
esac
done
+elif (( WEB )); then
+ # option checking
+ while (( $# )); do
+ case $1 in
+ -h|--help)
+ usage_web
+ exit 0
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ die "invalid argument: %s" "$1"
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
fi
pkgbases=("$@")
@@ -231,6 +269,31 @@ if (( CLONE_ALL )); then
stat_done
fi
+# Check web mode requirements and current directory shorthand
+if (( WEB )); then
+ # Check if web mode has xdg-open
+ if ! command -v xdg-open &>/dev/null; then
+ die "The web command requires 'xdg-open'"
+ fi
+
+ # Check if used without pkgnames in a packaging directory
+ if (( ! $# )); then
+ path=${PWD}
+ if [[ ! -d "${path}/.git" ]]; then
+ die "Not a Git repository: ${path}"
+ fi
+
+ giturl=$(git -C "${path}" remote get-url origin)
+ if [[ ${giturl} != *${GIT_PACKAGING_NAMESPACE}* ]]; then
+ die "Not a packaging repository: ${path}"
+ fi
+
+ pkgbase=$(basename "${giturl}")
+ pkgbase=${pkgbase%.git}
+ pkgbases=("${pkgbase}")
+ fi
+fi
+
for pkgbase in "${pkgbases[@]}"; do
if (( CLONE )); then
if [[ ! -d ${pkgbase} ]]; then
@@ -274,4 +337,8 @@ for pkgbase in "${pkgbases[@]}"; do
fi
fi
fi
+
+ if (( WEB )); then
+ xdg-open "${GIT_PACKAGING_URL_HTTPS}/${pkgbase}"
+ fi
done