如何使用git gem为提交添加--no-verify选项?

时间:2016-01-13 23:18:29

标签: ruby git github githooks

我正在使用rubygems.org中的'git'gem来与git存储库进行交互。我们公司最近在提交中添加了git hooks。我想至少暂时跳过git hooks以允许自动化继续工作。在命令行上,我可以使用git commit --no-verify,但无法使用git gem找到一种方法。有没有办法跳过使用git gem的提交检查?

1 个答案:

答案 0 :(得分:0)

不幸的是,正如我们从其source

中看到的那样
def commit(message, opts = {})
  arr_opts = []
  arr_opts << "--message=#{message}" if message
  arr_opts << '--amend' << '--no-edit' if opts[:amend]
  arr_opts << '--all' if opts[:add_all] || opts[:all] 
  arr_opts << '--allow-empty' if opts[:allow_empty]
  arr_opts << "--author=#{opts[:author]}" if opts[:author]

  command('commit', arr_opts)
end

宝石只允许commit的几个选项。

你可能会修补它,因为源代码似乎很容易阅读。