[英]Jira pre-receive hook on GitHub server not working for git commit pushes
我刚刚添加了https://github.com/github/platform-samples/blob/master/pre-receive-hooks/require-jira-issue.sh
脚本发送到我的github远程存储库之一,并能够在组织级别成功配置预接收钩子,并为我的示例存储库之一启用了它。 现在,当我从本地推送到该示例存储库时,始终会导致以下错误:-
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://************'
我使用的提交正则表达式为msg_regex='[DST\\-[0-9]+\\]'
因为DST是我们jira中某个项目的项目密钥。 我正在推送的所有提交在其消息中均包含字符串DST-***
,其中***
是数字,而DST-***
是此处jira项目的一些实际问题密钥。 知道为什么远程服务器挂钩拒绝推送。 看起来它没有验证正则表达式。 知道为什么吗?
-
在内部字符类[]
使用时,是正则表达式中的特殊字符,当它出现在除其他位置以外时,它表示范围
[^]
所以你的正则表达式应该是
DST-[0-9]+
我的猜测基于您的原始表情,
[DST\-[0-9]+\]
是也许所需的表达是
\[DST-[0-9]+\]
或者只是
DST-[0-9]+
虽然不确定。 我很肯定您可能不需要转义-
在这种情况下,因为它不在char类中,所以-
只是char类[]
一个metachar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.