From: Stephen Rothwell Date: Wed, 7 Dec 2022 01:13:07 +0000 (+1100) Subject: common.sh: restructure the get_ functions X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=f7948c807eba590b6621470eff2d1bd7d711ad5f;p=next-scripts common.sh: restructure the get_ functions add get_control_field and get_branches --- diff --git a/common.sh b/common.sh index 37b7511..5ed27b9 100644 --- a/common.sh +++ b/common.sh @@ -73,24 +73,39 @@ export NEXT_J_FACTOR="$j_factor" # Support functions _TAB=$(printf '\t') +get_control_field() +{ + awk -F "$_TAB" -v branch="$1" -v field="$2" '/^[^#]/ && $3==branch { print $field; }' "$CTRL_FILE" +} + +get_branches() +{ + awk -F "$_TAB" '/^[^#]/ && $2=="git"{ print $3; }' "$CTRL_FILE" +} + get_contacts() { - awk -F "$_TAB" -v branch="$1" '/^[^#]/ && $3==branch { print $1; }' "$CTRL_FILE" + get_control_field "$1" 1 +} + +get_type() +{ + get_control_field "$1" 2 } get_url() { - awk -F "$_TAB" -v branch="$1" '/^[^#]/ && $3==branch { print $4; }' "$CTRL_FILE" + get_control_field "$1" 4 } get_remote_branch() { - awk -F "$_TAB" -v branch="$1" '/^[^#]/ && $3==branch { print $5; }' "$CTRL_FILE" + get_control_field "$1" 5 } get_build_flag() { - awk -F "$_TAB" -v branch="$1" '/^[^#]/ && $3==branch { print $6; }' "$CTRL_FILE" + get_control_field "$1" 6 } check_unmerged_files()