Sublime Forum

Answer a git hook question

#1

I have a pre-commit hook that ask for permission to continue.

It works fine in BASH, but I cannot find a way to answer the prompt in Sublime Merge.

The hook is like this:

if ! echo "$COMMIT_MSG" | grep -q "(GMDS-"; then
    echo "WARNING: Commit message does not contain a GMDS ticket reference '(GMDS-XXX)'."
    echo "  Example: 'Fix motor protection (GMDS-1234)'"
    echo ""
    # Read from terminal directly, even though stdout is redirected
    exec < /dev/tty
    read -p "  Do you want to continue without a GMDS reference? [y/N]: " answer
    case "$answer" in
        [yY][eE][sS]|[yY])
            echo "  Continuing without GMDS reference..."
            ;;
        *)
            echo "  Commit aborted. Please add a GMDS ticket reference to your commit message."
            echo "  Use: git commit -m 'Your message (GMDS-XXXX)'"
            exit 1
            ;;
    esac
fi

How do I fix the hook to be able to answer the hook message in Sublime Merge?

0 Likes