]> git.ozlabs.org Git - next-scripts/commitdiff
common.sh: restructure the get_ functions
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2022 01:13:07 +0000 (12:13 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2022 01:13:07 +0000 (12:13 +1100)
add get_control_field and get_branches

common.sh

index 37b751197524c6658287fd6e22c28be30ee44da3..5ed27b92f9b4804e14989a3018c7036269ff1c17 100644 (file)
--- 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()