I'm trying to write into git commit-msg hook to check for my format of commit text before commiting it. I want commit to be like "AJ-XX sometext". Where XX are nums then space and just some text. And my code not working and i'm 99% sure that i have wrong regex, can you help me to write the right one. It looks likt this:
export REGEX='(AJ'-'0-90-9 )'
export ERROR_MSG="Commit message format must match regex \"${REGEX}\""
It should accept sth like this - "AJ-54 this is commit"
You can try the following POSIX ERE compliant regex:
export REGEX='^AJ-[0-9]{2} .*'
If your regex flavor is POSIX BRE, you can use
export REGEX='^AJ-[0-9]\{2\} .*'
If you cannot use regex and can only use wildcards / glob patterns, you ca use
export REGEX='AJ-[0-9][0-9] *'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.