diff --git a/bin/get_subtree_prefixes b/bin/get_subtree_prefixes new file mode 100755 index 000000000..7eb835f5a --- /dev/null +++ b/bin/get_subtree_prefixes @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +function error_handler() { + >&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." + exit "$2" +} +trap 'error_handler ${LINENO} $?' ERR +set -o errtrace -o errexit -o nounset -o pipefail + +git log | grep git-subtree-dir | tr -d ' ' | cut -d ":" -f2 | sort | uniq | xargs -I {} bash -c 'if [ -d $(git rev-parse --show-toplevel)/{} ] ; then echo {}; fi' diff --git a/bin/pull-subtrees b/bin/pull-subtrees index a9e903caf..cc029ef90 100755 --- a/bin/pull-subtrees +++ b/bin/pull-subtrees @@ -1,4 +1,11 @@ -#!/bin/sh +#!/usr/bin/env bash + +function error_handler() { + >&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." + exit "$2" +} +trap 'error_handler ${LINENO} $?' ERR +set -o errtrace -o errexit -o nounset -o pipefail for subtree in "SpiffWorkflow" \ "spiffworkflow-backend" \ diff --git a/bin/push_subtree b/bin/push_subtree new file mode 100755 index 000000000..86ed68a7c --- /dev/null +++ b/bin/push_subtree @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +function error_handler() { + >&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." + exit "$2" +} +trap 'error_handler ${LINENO} $?' ERR +set -o errtrace -o errexit -o nounset -o pipefail + +script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +valid_subtree_prefixes=$("${script_dir}/get_subtree_prefixes") + +subtree="${1:-}" +if ! grep -qE "^${subtree}$" <<<"$valid_subtree_prefixes"; then + >&2 echo "usage: $(basename "$0") [subtree]" + >&2 echo + >&2 echo -e "\tvalid_subtrees:\n\t\t$(tr '\n' ' ' <<<"$valid_subtree_prefixes" | sed 's/ /\n\t\t/g')" + exit 1 +fi + +git subtree push --prefix="${subtree}" "git@github.com:sartography/${subtree}.git" main