【发布时间】:2016-04-19 03:35:51
【问题描述】:
我正在使用来自 rubygems.org 的“git”gem 与 git 存储库进行交互。我们公司最近在提交时添加了 git 钩子,这些钩子会妨碍我们。我想至少暂时跳过 git 挂钩以允许自动化继续工作。在命令行上,我可以使用git commit --no-verify,但找不到使用 git gem 的方法。有没有办法使用 git gem 跳过提交检查?
【问题讨论】:
我正在使用来自 rubygems.org 的“git”gem 与 git 存储库进行交互。我们公司最近在提交时添加了 git 钩子,这些钩子会妨碍我们。我想至少暂时跳过 git 挂钩以允许自动化继续工作。在命令行上,我可以使用git commit --no-verify,但找不到使用 git gem 的方法。有没有办法使用 git gem 跳过提交检查?
【问题讨论】:
不幸的是,我们可以从它的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
gem 只允许commit 的几个选项。
不过,您可以对其进行猴子补丁,因为源代码似乎很容易阅读。
【讨论】: