From ebdd9ec99f6e0d5c5da83db5e3dbae1d0f483914 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Sun, 4 Feb 2024 10:50:06 +0100 Subject: [PATCH] refactor: :recycle: enhance readability --- src/sync_common.sh | 10 +++++----- src/sync_template.sh | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sync_common.sh b/src/sync_common.sh index 36acaf43..8677a408 100755 --- a/src/sync_common.sh +++ b/src/sync_common.sh @@ -9,7 +9,7 @@ set -e # Arguments: # message to print. ####################################### -err() { +function err() { echo "::error::[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2; } @@ -18,7 +18,7 @@ err() { # Arguments: # message to print. ####################################### -debug() { +function debug() { echo "::debug::$*"; } @@ -27,7 +27,7 @@ debug() { # Arguments: # message to print. ####################################### -warn() { +function warn() { echo "::warn::$*"; } @@ -36,7 +36,7 @@ warn() { # Arguments: # message to print. ####################################### -info() { +function info() { echo "::info::$*"; } @@ -46,7 +46,7 @@ info() { # hook -> the hook to use # ####################################3# -cmd_from_yml_file() { +function cmd_from_yml_file() { local FILE_NAME="templatesync.yml" local HOOK=$1 local YML_PATH=".hooks.${HOOK}.commands" diff --git a/src/sync_template.sh b/src/sync_template.sh index 8ef96a91..7894a55c 100644 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -48,7 +48,7 @@ debug "new Git HASH ${NEW_TEMPLATE_GIT_HASH}" echo "::group::Check new changes" -check_branch_remote_existing() { +function check_branch_remote_existing() { git ls-remote --exit-code --heads origin "${NEW_BRANCH}" || BRANCH_DOES_NOT_EXIST=true if [[ "${BRANCH_DOES_NOT_EXIST}" != true ]]; then @@ -143,7 +143,7 @@ git commit -m "${PR_COMMIT_MSG}" echo "::endgroup::" -cleanup_older_prs () { +function cleanup_older_prs () { older_prs=$(gh pr list \ --base "${UPSTREAM_BRANCH}" \ --state open \ @@ -177,7 +177,7 @@ fi echo "::endgroup::" -maybe_create_labels () { +function maybe_create_labels () { all_labels=${PR_LABELS//,/$'\n'} for label in $all_labels do @@ -210,12 +210,12 @@ fi echo "::endgroup::" -push () { +function push () { debug "push changes" git push --set-upstream origin "${NEW_BRANCH}" } -create_pr () { +function create_pr () { gh pr create \ --title "${PR_TITLE}" \ --body "Merge ${SOURCE_REPO_PATH} ${NEW_TEMPLATE_GIT_HASH}" \