2022-10-12 14:22:22 +00:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
# HELP: git adds and commits the entire BPMN models directory, including all process groups
|
|
|
|
|
|
|
|
bpmn_models_absolute_dir="$1"
|
|
|
|
git_commit_message="$2"
|
2022-12-15 17:52:53 +00:00
|
|
|
git_branch="$3"
|
|
|
|
git_commit_username="$4"
|
|
|
|
git_commit_email="$5"
|
2022-10-12 14:22:22 +00:00
|
|
|
|
2022-12-15 17:52:53 +00:00
|
|
|
if [[ -z "${5:-}" ]]; then
|
|
|
|
>&2 echo "usage: $(basename "$0") [bpmn_models_absolute_dir] [git_commit_message] [git_branch] [git_commit_username] [git_commit_email]"
|
2022-10-12 14:22:22 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$bpmn_models_absolute_dir"
|
|
|
|
git add .
|
|
|
|
|
|
|
|
# https://unix.stackexchange.com/a/155077/456630
|
|
|
|
if [ -z "$(git status --porcelain)" ]; then
|
|
|
|
echo "No changes to commit"
|
|
|
|
else
|
2022-12-15 17:52:53 +00:00
|
|
|
git config --local user.name "$git_commit_username"
|
|
|
|
git config --local user.email "$git_commit_email"
|
2022-10-12 14:22:22 +00:00
|
|
|
git commit -m "$git_commit_message"
|
2022-12-15 17:52:53 +00:00
|
|
|
git push --set-upstream origin "$git_branch"
|
2022-10-12 14:22:22 +00:00
|
|
|
fi
|