“git”的 JIRA 代码验证提交挂钩
有谁有我可以使用的 git commit hook 来确保 JIRA 问题号出现在签入消息中吗?我没有从 git commit hook 驱动 JIRA 的经验,所以任何帮助将不胜感激 - 工作源更是如此!
Does anyone have a git commit hook I can use that will ensure a JIRA issue number appears in the checkin message? I've got no experience driving JIRA from a git commit hook so any help would be appreciated -- working source even more so!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,使挂钩可执行:
附加以下行,用项目代码替换 PROJECT。
First, make the hook executable:
Append the following lines, substituting PROJECT with your project's code.
Ops,我仍然从未使用过 git,但一位朋友制作了 SVN-Hooks,一个用于创建 Subversion hook 的框架。它是用 Perl 编码的。也许这有任何帮助。看看那里:
http://code.google.com/p/svn-hooks/source/browse/trunk/t/02-jiraacceptance.t
如果您需要致电我们,我们会尽快很乐意提供帮助。
Ops, I never, still, used git but a friend made SVN-Hooks, a framework for creating Subversion hooks. It was coded in perl. Maybe this help in any way.Take a look on it there:
http://code.google.com/p/svn-hooks/source/browse/trunk/t/02-jiraacceptance.t
And if you need call us, ASAP we 'll be glad to help.
我会编写一个提交挂钩,以确保看起来像 JIRA 问题编号的内容出现在提交消息中的某处。为此,一个简单的正则表达式匹配就可以做到:
如果您愿意,为了额外的拼写错误保护,您可以确保第一部分与您在 JIRA 中设置的某些项目标识符匹配:
我发现尝试没有什么价值确保其中的数字部分引用有效的发行号。实际上没有任何方法可以确定用户是否输入了正确的问题编号(即使您设法将其限制为未解决的问题,用户仍然可以输入不相关的未解决的问题编号)。用户在提交代码时应谨慎行事。
I would write a commit hook that ensures that something that looks like a JIRA issue number appears somewhere in the commit message. To do that, a simple regular expression match would do it:
If you want, for extra typo-protection you can ensure that the first part matches with some project identifier that you have set up in JIRA:
I find there is little value in trying to make sure that the number part of that refers to a valid issue number. There isn't really any way to determine whether the user has entered the correct issue number (even if you manage to limit it to open issues, the user could still enter an unrelated open issue number). Users should be expected to take due care when committing code.