resq-cli 0.3.0

Developer CLI for the ResQ autonomous drone platform
Documentation
#!/usr/bin/env bash
# Copyright 2026 ResQ Software
# SPDX-License-Identifier: Apache-2.0
#
# Canonical ResQ prepare-commit-msg shim — source: resq-software/dev.
# Prepends a ticket ref (e.g. PROJ-123) extracted from the branch name.

set -euo pipefail

COMMIT_MSG_FILE="${1:-}"
COMMIT_SOURCE="${2:-}"

case "$COMMIT_SOURCE" in
    merge|squash|message|commit) exit 0 ;;
esac

BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || echo "")
[ -z "$BRANCH" ] && exit 0

TICKET=$(grep -oE '[A-Z]{2,}-[0-9]+' <<<"$BRANCH" | head -1 || true)
if [ -n "$TICKET" ]; then
    COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
    if ! grep -qF -- "$TICKET" <<<"$COMMIT_MSG"; then
        printf '[%s] %s\n' "$TICKET" "$COMMIT_MSG" > "$COMMIT_MSG_FILE"
    fi
fi

LOCAL_HOOK="$(git rev-parse --show-toplevel)/.git-hooks/local-prepare-commit-msg"
if [ -x "$LOCAL_HOOK" ]; then
    exec "$LOCAL_HOOK" "$@"
fi