From f7948c807eba590b6621470eff2d1bd7d711ad5f Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Wed, 7 Dec 2022 12:13:07 +1100 Subject: [PATCH] common.sh: restructure the get_ functions add get_control_field and get_branches --- common.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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() -- 2.39.5