首页 > 解决方案 > 是否可以检查 git 提交以包含特定字符?

问题描述

Git爱好者

我必须在我的 git 提交中包含“#+story number”,但有时我忘记提及它。我正在寻找一种方法来防止我的错误提交!我找到了这个文件,正如它所说,用这个内容修改了 .git/hooks/commit-msg.sample 文件(仅用于测试):

#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)

$regex = /\[ref: (\d+)\]/

if !$regex.match(message)
  puts "[POLICY] Your message is not formatted correctly"
  exit 1
end

但它没有用!您对此有什么经验或想法吗?此致

标签: git

解决方案


推荐阅读