【发布时间】:2014-10-11 13:20:19
【问题描述】:
我是 Shell 新手,我需要移植一个用 ruby 编写的简单 commit-msg 钩子,我的问题正是在正则表达式测试上,有人可以帮忙吗?
这是 ruby 中的代码:
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
$regex = /\[([A-Z]+)-\d+\](.)*/
if !$regex.match(message)
puts "[ERROR] Please use the following pattern: '[ABC-123] lorem ipsum'"
exit 1
end
【问题讨论】: