From 0669315821ea0af00fcc2c6271eb474174173e0a Mon Sep 17 00:00:00 2001 From: Christian Heusel Date: Fri, 21 Jul 2023 11:04:13 +0200 Subject: chore: refactor variable names in valid-{tags,repos}.sh Even though the variables in these files are globablly used they have a weirdly local sounding name. This commit fixes this by refactoring all usages throughout our codebase. Signed-off-by: Christian Heusel --- contrib/completion/bash/devtools.in | 8 ++++---- contrib/completion/zsh/_devtools.in | 20 ++++++++++---------- src/archrelease.in | 2 +- src/lib/build/build.sh | 2 +- src/lib/release.sh | 2 +- src/lib/valid-repos.sh | 4 ++-- src/lib/valid-tags.sh | 4 ++-- src/sogrep.in | 8 ++++---- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/contrib/completion/bash/devtools.in b/contrib/completion/bash/devtools.in index 3faad27..b28258f 100644 --- a/contrib/completion/bash/devtools.in +++ b/contrib/completion/bash/devtools.in @@ -8,7 +8,7 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh # shellcheck source=src/lib/valid-repos.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh -_binary_arch=${_arch[*]:0:-1} +_binary_arch=${DEVTOOLS_VALID_ARCHES[*]:0:-1} _colors=(never always auto) @@ -355,14 +355,14 @@ _devtools_completions_color() { mapfile -t COMPREPLY < <(compgen -W "${_colors[*]}" -- "$cur") } _devtools_completions_arch() { - mapfile -t COMPREPLY < <(compgen -W "${_arch[*]}" -- "$cur") + mapfile -t COMPREPLY < <(compgen -W "${DEVTOOLS_VALID_ARCHES[*]}" -- "$cur") } _devtools_completions_repo() { local optional=${1:-} - mapfile -t COMPREPLY < <(compgen -W "${optional} ${_repos[*]}" -- "$cur") + mapfile -t COMPREPLY < <(compgen -W "${optional} ${DEVTOOLS_VALID_REPOS[*]}" -- "$cur") } _devtools_completions_build_repo() { - mapfile -t COMPREPLY < <(compgen -W "${_build_repos[*]}" -- "$cur") + mapfile -t COMPREPLY < <(compgen -W "${DEVTOOLS_VALID_BUILDREPOS[*]}" -- "$cur") } _devtools_completions_all_packages() { mapfile -t COMPREPLY < <(compgen -W "$(pacman -Sql)" -- "$cur") diff --git a/contrib/completion/zsh/_devtools.in b/contrib/completion/zsh/_devtools.in index bd17466..49c4113 100644 --- a/contrib/completion/zsh/_devtools.in +++ b/contrib/completion/zsh/_devtools.in @@ -8,7 +8,7 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh # shellcheck source=src/lib/valid-repos.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh -_binary_arch=${_arch[*]:0:-1} +_binary_arch=${DEVTOOLS_VALID_ARCHES[*]:0:-1} _colors=(never always auto) _archbuild_args=( @@ -36,7 +36,7 @@ _pkgctl_auth_status_args=( _pkgctl_build_args=( "--arch=[Specify architectures to build for (disables auto-detection)]:arch:($_arch[*])" - "--repo=[Specify a target repository (disables auto-detection)]:repo:($_repos[*])" + "--repo=[Specify a target repository (disables auto-detection)]:repo:($DEVTOOLS_VALID_REPOS[*])" '(-s --staging)'{-s,--staging}'[Build against the staging counterpart of the auto-detected repo]' '(-t --testing)'{-t,--testing}'[Build against the testing counterpart of the auto-detected repo]' '(-o --offload)'{-o,--offload}'[Build on a remote server and transfer artifacts afterwards]' @@ -64,15 +64,15 @@ _pkgctl_db_cmds=( _pkgctl_db_move_args=( '(-h --help)'{-h,--help}'[Display usage]' - "1:src-repo:($_repos[*])" - "2:target-repo:($_repos[*])" + "1:src-repo:($DEVTOOLS_VALID_REPOS[*])" + "2:target-repo:($DEVTOOLS_VALID_REPOS[*])" '*:pkgbase:_devtools_completions_all_packages' ) _pkgctl_db_remove_args=( '(-a --arch=)'{-a,--arch=}"[Override the architecture (disables auto-detection)]:arch:($_arch[*])" '(-h --help)'{-h,--help}'[Display usage]' - "1:repo:($_repos[*])" + "1:repo:($DEVTOOLS_VALID_REPOS[*])" '*:pkgbase:_devtools_completions_all_packages' ) @@ -82,7 +82,7 @@ _pkgctl_db_update_args=( _pkgctl_release_args=( '(-m --message=)'{-m,--message=}"[Use the given as the commit message]:message:" - '(-r --repo=)'{-r,--repo=}"[Specify a target repository (disables auto-detection)]:repo:($_repos[*])" + '(-r --repo=)'{-r,--repo=}"[Specify a target repository (disables auto-detection)]:repo:($DEVTOOLS_VALID_REPOS[*])" '(-s --staging)'{-s,--staging}'[Release to the staging counterpart of the auto-detected repo]' '(-t --testing)'{-t,--testing}'[Release to the testing counterpart of the auto-detected repo]' '(-u --db-update)'{-u,--db-update}'[Automatically update the pacman database after uploading]' @@ -146,14 +146,14 @@ _arch_nspawn_args=( _archrelease_args=( '-f[Force release without checks]' - "*:arch:($_tags[*])" + "*:arch:($DEVTOOLS_VALID_TAGS[*])" ) _commitpkg_args=( '-f[Force release without checks]' '-s[Target repo server]' '-l[Set bandwidth limit]:limit' - "-a[Release to a specific architecture only]:arch:($_arch[*])" + "-a[Release to a specific architecture only]:arch:($DEVTOOLS_VALID_ARCHES[*])" '1:commit_msg' ) @@ -212,12 +212,12 @@ _sogrep_args=( '(-v --verbose)'{-v,--verbose}'[Show matched links in addition to pkgname]' '(-r --refresh)'{-r,--refresh}'[Refresh the links databases]' '(-h --help)'{-h,--help}'[Display usage]' - '1:repo:(all $_repos[*])' + '1:repo:(all $DEVTOOLS_VALID_REPOS[*])' '2:libname' ) _offload_build_args=( - '(-r --repo)'{-r,--repo}'[Build against a specific repository]:repo:($_build_repos[*])' + '(-r --repo)'{-r,--repo}'[Build against a specific repository]:repo:($DEVTOOLS_VALID_BUILDREPOS[*])' '(-a --arch)'{-a,--arch}'[Build against a specific architecture]:arch:(${_binary_arch[*]})' '(-s --server)'{-s,--server}'[Offload to a specific Build server]:server:' '(-h --help)'{-h,--help}'[Display usage]' diff --git a/src/archrelease.in b/src/archrelease.in index 818b0ca..84aed28 100644 --- a/src/archrelease.in +++ b/src/archrelease.in @@ -35,7 +35,7 @@ fi # validate repo is really repo-arch if [[ -z $FORCE ]]; then for tag in "$@"; do - if ! in_array "$tag" "${_tags[@]}"; then + if ! in_array "$tag" "${DEVTOOLS_VALID_TAGS[@]}"; then die "archrelease: Invalid tag: '%s' (use -f to force release)" "$tag" fi done diff --git a/src/lib/build/build.sh b/src/lib/build/build.sh index a5a272d..f2549f2 100644 --- a/src/lib/build/build.sh +++ b/src/lib/build/build.sh @@ -274,7 +274,7 @@ pkgctl_build() { if [[ -z ${REPO} ]]; then update_pacman_repo_cache # Check valid repos if not resolved dynamically - elif ! in_array "${REPO}" "${_repos[@]}"; then + elif ! in_array "${REPO}" "${DEVTOOLS_VALID_REPOS[@]}"; then die "Invalid repository target: %s" "${REPO}" fi diff --git a/src/lib/release.sh b/src/lib/release.sh index aabbd35..028d92e 100644 --- a/src/lib/release.sh +++ b/src/lib/release.sh @@ -126,7 +126,7 @@ pkgctl_release() { if [[ -z ${REPO} ]]; then update_pacman_repo_cache # Check valid repos if not resolved dynamically - elif ! in_array "${REPO}" "${_repos[@]}"; then + elif ! in_array "${REPO}" "${DEVTOOLS_VALID_REPOS[@]}"; then die "Invalid repository target: %s" "${REPO}" fi diff --git a/src/lib/valid-repos.sh b/src/lib/valid-repos.sh index 14f90ce..af8a552 100644 --- a/src/lib/valid-repos.sh +++ b/src/lib/valid-repos.sh @@ -4,7 +4,7 @@ : # shellcheck disable=2034 -_repos=( +DEVTOOLS_VALID_REPOS=( core core-staging core-testing extra extra-staging extra-testing multilib multilib-staging multilib-testing @@ -13,7 +13,7 @@ _repos=( ) # shellcheck disable=2034 -_build_repos=( +DEVTOOLS_VALID_BUILDREPOS=( core-staging core-testing extra extra-staging extra-testing multilib multilib-staging multilib-testing diff --git a/src/lib/valid-tags.sh b/src/lib/valid-tags.sh index ca8d7d7..cef0cc6 100644 --- a/src/lib/valid-tags.sh +++ b/src/lib/valid-tags.sh @@ -4,13 +4,13 @@ : # shellcheck disable=2034 -_arch=( +DEVTOOLS_VALID_ARCHES=( x86_64 any ) # shellcheck disable=2034 -_tags=( +DEVTOOLS_VALID_TAGS=( core-x86_64 core-any core-staging-x86_64 core-staging-any core-testing-x86_64 core-testing-any diff --git a/src/sogrep.in b/src/sogrep.in index 0ee05cc..9f51e53 100644 --- a/src/sogrep.in +++ b/src/sogrep.in @@ -31,7 +31,7 @@ recache() { (( VERBOSE )) && verbosity=--progress-bar - for repo in "${_repos[@]}"; do + for repo in "${DEVTOOLS_VALID_REPOS[@]}"; do if [[ -n "$SOLINKS_MIRROR" ]]; then mirror="$SOLINKS_MIRROR" elif ! mirror="$(set -o pipefail; pacman-conf --repo "$repo" Server 2>/dev/null | head -n1)"; then @@ -72,7 +72,7 @@ is_outdated_cache() { # links databases are generated at about the same time every day; we should # attempt to check for new database files if any of them are over a day old - for repo in "${_repos[@]}"; do + for repo in "${DEVTOOLS_VALID_REPOS[@]}"; do for arch in "${arches[@]}"; do local dbpath=${SOCACHE_DIR}/${arch}/${repo}.links.tar.gz if [[ ! -f ${dbpath} ]] || [[ $(find "${dbpath}" -mtime +0) ]]; then @@ -85,10 +85,10 @@ is_outdated_cache() { } search() { - local repo=$1 arch lib=$2 srepos=("${_repos[@]}") + local repo=$1 arch lib=$2 srepos=("${DEVTOOLS_VALID_REPOS[@]}") if [[ $repo != all ]]; then - if ! in_array "${repo}" "${_repos[@]}"; then + if ! in_array "${repo}" "${DEVTOOLS_VALID_REPOS[@]}"; then echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'" echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." exit 1 -- cgit v1.2.3-70-g09d2