From 6def64c8e0b6d6d41b8768db6d8448f8bc320bbf Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 8 Jul 2017 09:25:13 -0400 Subject: add set-git-protocol command While we're at it, separate our help output into two sections, since we're accumulating a growing list of subcommands which operate not on packages, but on the meta level of the asp repo. Closes #15. --- asp.in | 54 +++++++++++++++++++++++++++++++++++---------------- man/asp.1.txt | 4 ++++ shell/bash-completion | 5 +++++ shell/zsh-completion | 25 ++++++++++++------------ 4 files changed, 59 insertions(+), 29 deletions(-) diff --git a/asp.in b/asp.in index e2dd60d..8d43055 100644 --- a/asp.in +++ b/asp.in @@ -25,23 +25,27 @@ Options: -h Show this help -V Show package version -Commands: - checkout NAME... Create a mutable git repository for packages - difflog NAME Show revision history with diffs - disk-usage Show amount of disk used by locally tracked packages - export NAME... Export packages - gc Cleanup and optimize the local repository - help Show this help - list-all List all known packages - list-arches NAME... List architectures for packages - list-local List tracked packages - list-repos NAME... List repos for packages - log NAME Show revision history - ls-files NAME List files for package - shortlog NAME Show revision history in short form - show NAME [FILE] Show the PKGBUILD or other FILE - untrack NAME... Remove a package from the local repository - update [NAME...] Update packages (update all tracked if none specified) +Package Commands: + checkout NAME... Create a mutable git repository for packages + difflog NAME Show revision history with diffs + export NAME... Export packages + list-all List all known packages + list-arches NAME... List architectures for packages + list-local List tracked packages + list-repos NAME... List repos for packages + log NAME Show revision history + ls-files NAME List files for package + shortlog NAME Show revision history in short form + show NAME [FILE] Show the PKGBUILD or other FILE + untrack NAME... Remove a package from the local repository + update [NAME...] Update packages (update all tracked if none specified) + +Meta Commands: + disk-usage Show amount of disk used by locally tracked packages + gc Cleanup and optimize the local repository + help Show this help + set-git-protocol PROTO Change git protocol (one of: git, http, https) + EOF } @@ -288,6 +292,22 @@ action__ls-files() { package_list_files "$1" } +action__set-git-protocol() { + __require_argc 1 $# + + case $1 in + git|http|https) + ;; + *) + log_fatal 'invalid protocol: %s' "$1" + ;; + esac + + for remote in "${ARCH_GIT_REPOS[@]}"; do + git remote set-url "$remote" "$1://git.archlinux.org/svntogit/$remote.git" + done +} + dispatch_action() { local candidates diff --git a/man/asp.1.txt b/man/asp.1.txt index e615183..7b984e3 100644 --- a/man/asp.1.txt +++ b/man/asp.1.txt @@ -69,6 +69,10 @@ The following commands are understood: *ls-files* 'TARGET':: List source files for the given target. +*set-git-protocol* 'PROTOCOL':: + Set the protocol used to communicate with the remote git repositories. Must + be one of 'git', 'http', or 'https'. + *shortlog* 'TARGET':: Show a condensed revision history of the target. diff --git a/shell/bash-completion b/shell/bash-completion index acff4c8..3c7fc06 100644 --- a/shell/bash-completion +++ b/shell/bash-completion @@ -17,6 +17,7 @@ _asp() { [ALL_PACKAGES]='checkout difflog export list-arches list-repos log shortlog show ls-files' [LOCAL_PACKAGES]='untrack update' [NONE]='disk-usage gc help list-all list-local' + [PROTO]='set-git-protocol' ) # flags @@ -45,6 +46,10 @@ _asp() { verb=$word comps=$(ASP_GIT_QUIET=1 \asp list-local | sed 's,.*/,,') break + elif in_array "$word" ${verbs[PROTO]}; then + verb=$word + comps='git http https' + break elif in_array "$word" ${verbs[NONE]}; then verb=$word break diff --git a/shell/zsh-completion b/shell/zsh-completion index bcf18e4..13ede7c 100644 --- a/shell/zsh-completion +++ b/shell/zsh-completion @@ -17,25 +17,26 @@ _asp_command() { 'log' 'shortlog' 'show' + 'set-git-protocol' 'update' 'untrack' ) -if (( CURRENT == 1 )); then - _describe -t commands 'asp command' _asp_cmds || compadd "$@" -else - local curcontext="$curcontext" - cmd="${${_asp_cmds[(r)$words[1]:*]%%:*}}" - if (( $#cmd )); then - if (( $+functions[_asp_$cmd] )); then - _asp_$cmd + if (( CURRENT == 1 )); then + _describe -t commands 'asp command' _asp_cmds || compadd "$@" + else + local curcontext="$curcontext" + cmd="${${_asp_cmds[(r)$words[1]:*]%%:*}}" + if (( $#cmd )); then + if (( $+functions[_asp_$cmd] )); then + _asp_$cmd + else + _message "no more options" + fi else - _message "no more options" + _message "unknown asp command: $words[1]" fi - else - _message "unknown asp command: $words[1]" fi -fi } _arguments \ -- cgit v1.2.3-70-g09d2