From 91e85a28f9760eb02c30339293af67a8dddfd682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 28 Mar 2022 17:17:16 +0200 Subject: [PATCH] scripts/update-status-go: support commit SHA1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some rare cases we might want to supply an exact commit rather than a branch name or a git tag. Signed-off-by: Jakub SokoĊ‚owski --- scripts/update-status-go.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/update-status-go.sh b/scripts/update-status-go.sh index aa5e055871..49a2008c87 100755 --- a/scripts/update-status-go.sh +++ b/scripts/update-status-go.sh @@ -50,6 +50,9 @@ Examples: # Using tag name ${SCRIPT_FILE} v2.1.1 + # Using commit SHA1 + ${SCRIPT_FILE} 1a2b3c4d + # Using PR number ${SCRIPT_FILE} PR-2134 END @@ -82,13 +85,12 @@ STATUS_GO_BRANCH_SHA1=$(echo "${STATUS_GO_MATCHING_REFS}" | grep 'refs/heads' | # Prefer tag over branch if both are found if [[ -n "${STATUS_GO_TAG_SHA1}" ]]; then STATUS_GO_COMMIT_SHA1="${STATUS_GO_TAG_SHA1}" -else +elif [[ -n "${STATUS_GO_BRANCH_SHA1}" ]]; then STATUS_GO_COMMIT_SHA1="${STATUS_GO_BRANCH_SHA1}" -fi - -if [[ -z "${STATUS_GO_COMMIT_SHA1}" ]]; then - echo "ERROR: Failed to find a SHA1 for rev '${STATUS_GO_VERSION}'." - echo "NOTE: To set SHA1 you can just edit ${VERSION_FILE} by hand." +elif [[ "${#STATUS_GO_VERSION}" -gt 4 ]]; then + STATUS_GO_COMMIT_SHA1="${STATUS_GO_VERSION}" +else + echo "ERROR: Input not a tag or branch, but too short to be a SHA1!" >&2 exit 1 fi