From 3c823023f691b37e1fabb54a6eebd59f9152a397 Mon Sep 17 00:00:00 2001 From: "A.J. Stein" Date: Fri, 22 Sep 2023 13:26:57 -0400 Subject: [PATCH] Default script to not generate prototypes in #19 The intent is to set the remote and branch prefix filter to empty as a default to current behavior locally. In the Makefile, it will default to the correct remote and empty branch to skip. The GHA workflow argument should override and run that. --- support/list_revisions.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/support/list_revisions.sh b/support/list_revisions.sh index de86080f8..136c846c8 100755 --- a/support/list_revisions.sh +++ b/support/list_revisions.sh @@ -17,12 +17,18 @@ TAGGED_REVISIONS=$(echo "${TAGGED_REVISIONS}" | sort -t "." -k1,1n -k2,2n -k3,3n # retrieve prefix for branches of prototypes to be listed and published and if # it is empty, it can be ignored. -PROTOTYPE_BRANCHES_REMOTE=${PROTOTYPE_BRANCHES_REMOTE:-"origin"} -PROTOTYPE_BRANCHES_PREFIX=${PROTOTYPE_BRANCHES_PREFIX:-"prototype"} -# the output of ls-remote is the best for this but doesn't have ready-made -# format or pretty-print options. We need to use sed to filter the output -# output is the following format: -# sha1-hash refs/heads/branch-name -# 012345abcd012345abcd012345abcd012345abcd refs/heads/branch-name -PROTOTYPE_BRANCHES=$(cd "${OSCAL_DIR}"; git ls-remote "${PROTOTYPE_BRANCHES_REMOTE}" "${PROTOTYPE_BRANCHES_PREFIX}*" | sed -n -e "s|^.*\(refs/heads/\)\(${PROTOTYPE_BRANCHES_PREFIX}\)|\2|p") -echo "${TAGGED_REVISIONS}" "${PROTOTYPE_BRANCHES}" +PROTOTYPE_BRANCHES_REMOTE=${PROTOTYPE_BRANCHES_REMOTE:-""} +PROTOTYPE_BRANCHES_PREFIX=${PROTOTYPE_BRANCHES_PREFIX:-""} + +if [[ -z "${PROTOTYPE_BRANCHES_PREFIX}" || -z "${PROTOTYPE_BRANCHES_REMOTE}" ]]; then + # the default values are empty, do nothing + echo "${TAGGED_REVISIONS}" +else + # the output of ls-remote is the best for this but doesn't have ready-made + # format or pretty-print options. We need to use sed to filter the output + # output is the following format: + # sha1-hash refs/heads/branch-name + # 012345abcd012345abcd012345abcd012345abcd refs/heads/branch-name + PROTOTYPE_BRANCHES=$(cd "${OSCAL_DIR}"; git ls-remote "${PROTOTYPE_BRANCHES_REMOTE}" "${PROTOTYPE_BRANCHES_PREFIX}*" | sed -n -e "s|^.*\(refs/heads/\)\(${PROTOTYPE_BRANCHES_PREFIX}\)|\2|p") + echo "${TAGGED_REVISIONS}" "${PROTOTYPE_BRANCHES}" +fi