Skip to content

Commit

Permalink
Default script to not generate prototypes in #19
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aj-stein-nist committed Sep 22, 2023
1 parent 43412ac commit 3c82302
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions support/list_revisions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3c82302

Please sign in to comment.