#!/bin/sh
# .git/hooks/prepare-commit-msg

BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if echo "$BRANCH_NAME" | grep -E '^[a-z]+/[0-9]+-' > /dev/null; then
  ISSUE_ID=$(echo "$BRANCH_NAME" | grep -oE '[0-9]+')
  sed -i.bak "1s/^/refs #$ISSUE_ID\n/" "$1"
fi