From 4b885912839c8fd2d55b42365647ec2f8ee7ab06 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 31 Jan 2024 09:12:51 +0000 Subject: [PATCH] Update build configuration files --- .githooks/prepare-commit-msg | 27 +++++++++++++++++++++++++++ run | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 .githooks/prepare-commit-msg diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg new file mode 100755 index 0000000..6ff8ea0 --- /dev/null +++ b/.githooks/prepare-commit-msg @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +# Load the issue ID from an `.issue-id` file within the project and replace the +# `ISSUE_ID` placeholder within a Git commit message. +# +# For example, running `echo "OD-123" > .issue-id` will add `Refs: OD-123` to +# the commit message. +# +# This also works with multiple issue IDs in the same string, e.g. +# "OD-123 OD-456", or IDs on multiple lines. + +set -o errexit +set -o nounset +set -o pipefail + +PROJECT_DIR=$(git rev-parse --show-toplevel) +ISSUE_FILE="$PROJECT_DIR/.issue-id" + +if [ -f "${ISSUE_FILE}" ]; then + ISSUE_IDS=$(cat "${ISSUE_FILE}" | tr '\n' ',' | tr ' ' ',' | sed 's/,$//' | sed 's/,/, /g') + + if [ -n "${ISSUE_IDS}" ]; then + sed -i.bak "s/# Refs:/Refs: $ISSUE_IDS/" "$1" + fi +fi diff --git a/run b/run index dfe82d3..e3f6103 100755 --- a/run +++ b/run @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + set -o errexit set -o nounset set -o pipefail @@ -16,7 +18,7 @@ function generate { args=(--server --watch) fi - sculpin generate "${args[@]}" + sculpin generate "${args[@]}" "${@}" } function help {