#!/bin/fish

set commit_msg_file $argv[1]
set commit_msg (cat $commit_msg_file)

set pattern '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|deps)(\(.+\))?!?: .+$'

if not string match -rq $pattern "$commit_msg"
    echo "Error: Commit message does not follow Conventional Commits 1.0 standard."
    echo "Format: <type>(<scope>)<optional !>: <description>"
    echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, deps"
    echo "Example: feat(auth): add login functionality"
    exit 1
end
