From ee3fb126fd38fc1539814cb913f5f7420777affe Mon Sep 17 00:00:00 2001 From: "Kenneth J. Pronovici" Date: Thu, 2 Jan 2025 01:23:57 +0000 Subject: [PATCH] Pull in latest version of run-script-framework --- .run/commands/currentbranch.sh | 7 +++++++ .run/commands/defaultbranch.sh | 13 +++++++++++++ .run/commands/tagrelease.sh | 4 ++-- .run/util.sh | 14 -------------- 4 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 .run/commands/currentbranch.sh create mode 100644 .run/commands/defaultbranch.sh diff --git a/.run/commands/currentbranch.sh b/.run/commands/currentbranch.sh new file mode 100644 index 0000000..9b687e9 --- /dev/null +++ b/.run/commands/currentbranch.sh @@ -0,0 +1,7 @@ +# vim: set ft=bash ts=3 sw=3 expandtab: +# Return the current Git branch + +command_currentbranch() { + git branch -a | grep '^\*' | sed 's/^\* //' +} + diff --git a/.run/commands/defaultbranch.sh b/.run/commands/defaultbranch.sh new file mode 100644 index 0000000..8cc1c39 --- /dev/null +++ b/.run/commands/defaultbranch.sh @@ -0,0 +1,13 @@ +# vim: set ft=bash ts=3 sw=3 expandtab: +# Return the default Git branch + +# There is no canonical way to determine the default Git branch. This version +# is slow, but seems more reliable than most. At least by pulling it into a +# command (vs. setting a variable via util.sh), only the commands or tasks that +# need it will take the hit. +# +# See: https://stackoverflow.com/questions/28666357/how-to-get-default-git-branch + +command_defaultbranch() { + LC_ALL=C git remote show $(git remote) | grep 'HEAD branch' | cut -d' ' -f5 +} diff --git a/.run/commands/tagrelease.sh b/.run/commands/tagrelease.sh index 35c472c..5f71eed 100644 --- a/.run/commands/tagrelease.sh +++ b/.run/commands/tagrelease.sh @@ -25,8 +25,8 @@ command_tagrelease() { COPYRIGHT="${EARLIEST_YEAR}-${LATEST_YEAR}" fi - DEFAULT_BRANCH=$(default_branch) - CURRENT_BRANCH=$(current_branch) + DEFAULT_BRANCH=$(run_command defaultbranch) + CURRENT_BRANCH=$(run_command currentbranch) if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ]; then echo "*** You are not on $DEFAULT_BRANCH; you cannot release from this branch" exit 1 diff --git a/.run/util.sh b/.run/util.sh index b573829..ae33ece 100644 --- a/.run/util.sh +++ b/.run/util.sh @@ -106,20 +106,6 @@ task_help() { fi } -# Return the default Git branch -default_branch() { - # There is no canonical way to determine the default Git branch. This version is - # slow, but seems more reliable than most. At least by pulling it into a function - # (vs. a variable) only the commands or tasks that need it will take the hit. - # See: https://stackoverflow.com/questions/28666357/how-to-get-default-git-branch - LC_ALL=C git remote show $(git remote) | grep 'HEAD branch' | cut -d' ' -f5 -} - -# Return the current Git branch -current_branch() { - git branch -a | grep '^\*' | sed 's/^\* //' -} - # Setup the runtime environment setup_environment() { local EARLIEST_YEAR LATEST_YEAR