【问题标题】:How can I add --no-verify option to a commit using git gem?如何使用 git gem 向提交添加 --no-verify 选项?
【发布时间】:2016-04-19 03:35:51
【问题描述】:

我正在使用来自 ruby​​gems.org 的“git”gem 与 git 存储库进行交互。我们公司最近在提交时添加了 git 钩子,这些钩子会妨碍我们。我想至少暂时跳过 git 挂钩以允许自动化继续工作。在命令行上,我可以使用git commit --no-verify,但找不到使用 git gem 的方法。有没有办法使用 git gem 跳过提交检查?

【问题讨论】:

    标签: ruby git github githooks


    【解决方案1】:

    不幸的是,我们可以从它的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 的几个选项。

    不过,您可以对其进行猴子补丁,因为源代码似乎很容易阅读。

    【讨论】:

    • 我可以看到添加是多么容易。感谢您的建议。
    • 我在 github richmi/ruby-git 的这个 fork 中的 commit 和 push 方法中添加了 --no-verify 选项。已提交拉取请求。
    猜你喜欢
    • 1970-01-01
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    相关资源
    最近更新 更多