i just added the https://github.com/github/platform-samples/blob/master/pre-receive-hooks/require-jira-issue.sh
script to one of my github remote repos and was able to successfully configure a pre-receive hook at the org level and enabled it for one of my sample repos. Now when i push to that sample repo from local, it always results in the below error :-
remote: jira-commit-hook.sh: failed with exit status 1
remote: grep: Invalid range end
remote: ERROR
remote: ERROR: Your push was rejected because the commit
remote: ERROR: e9b0dd4695a51beb51e6fc1a8d16f01fa7dd13b8 in master
remote: ERROR: is missing the JIRA Issue
remote: ERROR:
remote: ERROR: Please fix the commit message and push again.
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://************'
The commit regex I'm using is msg_regex='[DST\\-[0-9]+\\]'
since DST is the project key in our jira for one of the projects. All the commits i am pushing has the string DST-***
in their message where ***
is a number and DST-***
is some actual issue key for the jira project here. Any idea why the remote server hook is rejecting the push. Looks like its not validating the regex. Any idea why?
-
is a special character in regex when you use inside character class []
, it stands for range when it appears anywhere else except
[^]
so your regex should be
DST-[0-9]+
My guess based on your original expression,
[DST\-[0-9]+\]
is that maybe the desired expression would be
\[DST-[0-9]+\]
or maybe just,
DST-[0-9]+
not sure though. I'm positive that you may not need to escape the -
in this case, since it is not in a char class, -
is only a metachar inside a char class []
.
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.