Skip to content

Commit 7fdaa4e

Browse files
committed
pkg-auto: Code style changes
Mostly to avoid repeating variable names when declaring them and initializing them. Signed-off-by: Krzesimir Nowak <[email protected]>
1 parent 59c632d commit 7fdaa4e

File tree

1 file changed

+63
-87
lines changed

1 file changed

+63
-87
lines changed

pkg_auto/impl/pkg_auto_lib.sh

Lines changed: 63 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,25 +2688,21 @@ function get_first_from_set() {
26882688
# 5 - old version
26892689
# 6 - new version
26902690
function handle_pkg_update() {
2691-
local pkg_to_tags_mvm_var_name old_pkg new_pkg old new
26922691
local -n package_output_paths_ref=${1}; shift
2693-
pkg_to_tags_mvm_var_name=${1}; shift
2694-
old_pkg=${1}; shift
2695-
new_pkg=${1}; shift
2696-
old=${1}; shift
2697-
new=${1}; shift
2692+
local pkg_to_tags_mvm_var_name=${1}; shift
2693+
local old_pkg=${1}; shift
2694+
local new_pkg=${1}; shift
2695+
local old=${1}; shift
2696+
local new=${1}; shift
26982697

26992698
# shellcheck source=for-shellcheck/globals
27002699
source "${WORKDIR}/globals"
27012700

2702-
local old_no_r new_no_r
2703-
old_no_r=${old%-r+([0-9])}
2704-
new_no_r=${new%-r+([0-9])}
2701+
local old_no_r=${old%-r+([0-9])}
2702+
local new_no_r=${new%-r+([0-9])}
27052703

2706-
local pkg_name
2707-
pkg_name=${new_pkg#*/}
2708-
local -a lines
2709-
lines=( "0:from ${old} to ${new}")
2704+
local pkg_name=${new_pkg#*/}
2705+
local -a lines=( "0:from ${old} to ${new}" )
27102706
if [[ ${old_pkg} != "${new_pkg}" ]]; then
27112707
lines+=( "0:renamed from ${old_pkg}" )
27122708
fi
@@ -2766,24 +2762,20 @@ function handle_pkg_update() {
27662762
# has changed (empty means nothing changed, non-empty means
27672763
# something has changed)
27682764
function handle_pkg_as_is() {
2769-
local pkg_to_tags_mvm_var_name old_pkg new_pkg v
27702765
local -n package_output_paths_ref=${1}; shift
2771-
pkg_to_tags_mvm_var_name=${1}; shift
2772-
old_pkg=${1}; shift
2773-
new_pkg=${1}; shift
2774-
v=${1}; shift
2766+
local pkg_to_tags_mvm_var_name=${1}; shift
2767+
local old_pkg=${1}; shift
2768+
local new_pkg=${1}; shift
2769+
local v=${1}; shift
27752770
local -n changed_ref=${1}; shift
27762771

27772772
# shellcheck source=for-shellcheck/globals
27782773
source "${WORKDIR}/globals"
27792774

2780-
local pkg_name
2781-
pkg_name=${new_pkg#/}
2782-
local -a lines
2783-
lines=( "0:still at ${v}" )
2775+
local pkg_name=${new_pkg#/}
2776+
local -a lines=( "0:still at ${v}" )
27842777

2785-
local renamed
2786-
renamed=
2778+
local renamed=''
27872779
if [[ ${old_pkg} != "${new_pkg}" ]]; then
27882780
lines+=( "0:renamed from ${old_pkg}" )
27892781
renamed=x
@@ -2792,8 +2784,7 @@ function handle_pkg_as_is() {
27922784
local out_dir=${package_output_paths_ref[POP_PKG_SLOT_OUT_DIR_IDX]}
27932785
generate_ebuild_diff "${out_dir}" "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_pkg}" "${new_pkg}" "${v}" "${v}"
27942786

2795-
local modified
2796-
modified=
2787+
local modified=''
27972788

27982789
local diff_report_name
27992790
gen_varname diff_report_name
@@ -2849,25 +2840,21 @@ function handle_pkg_as_is() {
28492840
# 5 - old version
28502841
# 6 - new version
28512842
function handle_pkg_downgrade() {
2852-
local pkg_to_tags_mvm_var_name old_pkg new_pkg old new
28532843
local -n package_output_paths_ref=${1}; shift
2854-
pkg_to_tags_mvm_var_name=${1}; shift
2855-
old_pkg=${1}; shift
2856-
new_pkg=${1}; shift
2857-
old=${1}; shift
2858-
new=${1}; shift
2844+
local pkg_to_tags_mvm_var_name=${1}; shift
2845+
local old_pkg=${1}; shift
2846+
local new_pkg=${1}; shift
2847+
local old=${1}; shift
2848+
local new=${1}; shift
28592849

28602850
# shellcheck source=for-shellcheck/globals
28612851
source "${WORKDIR}/globals"
28622852

2863-
local old_no_r new_no_r
2864-
old_no_r=${old%-r+([0-9])}
2865-
new_no_r=${new%-r+([0-9])}
2853+
local old_no_r=${old%-r+([0-9])}
2854+
local new_no_r=${new%-r+([0-9])}
28662855

2867-
local pkg_name
2868-
pkg_name=${new_pkg#*/}
2869-
local -a lines
2870-
lines=( "0:downgraded from ${old} to ${new}" )
2856+
local pkg_name=${new_pkg#*/}
2857+
local -a lines=( "0:downgraded from ${old} to ${new}" )
28712858
if [[ ${old_pkg} != "${new_pkg}" ]]; then
28722859
lines+=( "0:renamed from ${old_pkg}" )
28732860
fi
@@ -2950,10 +2937,9 @@ function tags_for_pkg() {
29502937
# 3 - version
29512938
# @ - package tags
29522939
function generate_changelog_entry_stub() {
2953-
local out_dir pkg_name v
2954-
out_dir=${1}; shift
2955-
pkg_name=${1}; shift
2956-
v=${1}; shift
2940+
local out_dir=${1}; shift
2941+
local pkg_name=${1}; shift
2942+
local v=${1}; shift
29572943
# rest are tags
29582944

29592945
local -a applied_tags=()
@@ -2987,13 +2973,11 @@ function generate_changelog_entry_stub() {
29872973
# @ - tags followed by double dash followed by lines to append to the
29882974
# file
29892975
function generate_summary_stub() {
2990-
local out_dir pkg
2991-
out_dir=${1}; shift
2992-
pkg=${1}; shift
2976+
local out_dir=${1}; shift
2977+
local pkg=${1}; shift
29932978
# rest are tags separated followed by double dash followed by lines
29942979

2995-
local -a tags
2996-
tags=()
2980+
local -a tags=()
29972981
while [[ ${#} -gt 0 ]]; do
29982982
if [[ ${1} = '--' ]]; then
29992983
shift
@@ -3034,16 +3018,14 @@ function generate_summary_stub() {
30343018
# 4 - old package name
30353019
# 5 - new package name
30363020
function generate_full_diffs() {
3037-
local out_dir old_ps new_ps old_pkg new_pkg
3038-
out_dir=${1}; shift
3039-
old_ps=${1}; shift
3040-
new_ps=${1}; shift
3041-
old_pkg=${1}; shift
3042-
new_pkg=${1}; shift
3021+
local out_dir=${1}; shift
3022+
local old_ps=${1}; shift
3023+
local new_ps=${1}; shift
3024+
local old_pkg=${1}; shift
3025+
local new_pkg=${1}; shift
30433026

3044-
local old_path new_path
3045-
old_path="${old_ps}/${old_pkg}"
3046-
new_path="${new_ps}/${new_pkg}"
3027+
local old_path="${old_ps}/${old_pkg}"
3028+
local new_path="${new_ps}/${new_pkg}"
30473029

30483030
local -a common_diff_opts=(
30493031
--recursive
@@ -3064,16 +3046,14 @@ function generate_full_diffs() {
30643046
# 4 - old package name
30653047
# 5 - new package name
30663048
function generate_non_ebuild_diffs() {
3067-
local out_dir old_ps new_ps old_pkg new_pkg
3068-
out_dir=${1}; shift
3069-
old_ps=${1}; shift
3070-
new_ps=${1}; shift
3071-
old_pkg=${1}; shift
3072-
new_pkg=${1}; shift
3049+
local out_dir=${1}; shift
3050+
local old_ps=${1}; shift
3051+
local new_ps=${1}; shift
3052+
local old_pkg=${1}; shift
3053+
local new_pkg=${1}; shift
30733054

3074-
local old_path new_path
3075-
old_path="${old_ps}/${old_pkg}"
3076-
new_path="${new_ps}/${new_pkg}"
3055+
local old_path="${old_ps}/${old_pkg}"
3056+
local new_path="${new_ps}/${new_pkg}"
30773057

30783058
local -a diff_opts=(
30793059
--recursive
@@ -3099,22 +3079,19 @@ function generate_non_ebuild_diffs() {
30993079
# 6 - old package version
31003080
# 7 - new package version
31013081
function generate_ebuild_diff() {
3102-
local out_dir old_ps new_ps old_pkg new_pkg old new
3103-
out_dir=${1}; shift
3104-
old_ps=${1}; shift
3105-
new_ps=${1}; shift
3106-
old_pkg=${1}; shift
3107-
new_pkg=${1}; shift
3108-
old=${1}; shift
3109-
new=${1}; shift
3110-
3111-
local old_pkg_name new_pkg_name
3112-
old_pkg_name=${old_pkg#*/}
3113-
new_pkg_name=${new_pkg#*/}
3114-
3115-
local old_path new_path
3116-
old_path="${old_ps}/${old_pkg}/${old_pkg_name}-${old}.ebuild"
3117-
new_path="${new_ps}/${new_pkg}/${new_pkg_name}-${new}.ebuild"
3082+
local out_dir=${1}; shift
3083+
local old_ps=${1}; shift
3084+
local new_ps=${1}; shift
3085+
local old_pkg=${1}; shift
3086+
local new_pkg=${1}; shift
3087+
local old=${1}; shift
3088+
local new=${1}; shift
3089+
3090+
local old_pkg_name=${old_pkg#*/}
3091+
local new_pkg_name=${new_pkg#*/}
3092+
3093+
local old_path="${old_ps}/${old_pkg}/${old_pkg_name}-${old}.ebuild"
3094+
local new_path="${new_ps}/${new_pkg}/${new_pkg_name}-${new}.ebuild"
31183095

31193096
xdiff --unified=3 "${old_path}" "${new_path}" >"${out_dir}/ebuild.diff"
31203097
}
@@ -3155,11 +3132,10 @@ function generate_cache_diff_report() {
31553132
# 3 - old package name
31563133
# 4 - new package name
31573134
function generate_package_mention_reports() {
3158-
local out_dir scripts old_pkg new_pkg
3159-
out_dir=${1}; shift
3160-
scripts=${1}; shift
3161-
old_pkg=${1}; shift
3162-
new_pkg=${1}; shift
3135+
local out_dir=${1}; shift
3136+
local scripts=${1}; shift
3137+
local old_pkg=${1}; shift
3138+
local new_pkg=${1}; shift
31633139

31643140
generate_mention_report_for_package "${scripts}" "${new_pkg}" >"${out_dir}/occurences"
31653141

0 commit comments

Comments
 (0)