[英]Jira pre-receive hook on GitHub server not working for git commit pushes
i just added the https://github.com/github/platform-samples/blob/master/pre-receive-hooks/require-jira-issue.sh 我刚刚添加了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. 脚本发送到我的github远程存储库之一,并能够在组织级别成功配置预接收钩子,并为我的示例存储库之一启用了它。 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. 我使用的提交正则表达式为
msg_regex='[DST\\-[0-9]+\\]'
因为DST是我们jira中某个项目的项目密钥。 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. 我正在推送的所有提交在其消息中均包含字符串
DST-***
,其中***
是数字,而DST-***
是此处jira项目的一些实际问题密钥。 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 []
. 我很肯定您可能不需要转义
-
在这种情况下,因为它不在char类中,所以-
只是char类[]
一个metachar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.