无法在过量使用中添加自定义脚本 gem

can't add custom script in overcommit gem

我不确定这是否是我应该在官方存储库问题中 post 的东西(我有时会在那里看到 'question' 标签)。但是,如果您认为这是问这个问题的合适地方,那么如果有人可以帮助我,那就太好了。


我一直在尝试在过量使用 gem 中添加自定义脚本,但没有成功。 官方文档中说的是在.overcommit.yml:

中添加行
 PostCheckout:
  CustomScript:
    enabled: true
    required_executable: './bin/custom-script'

(所以我这样做了:)

PrePush:      
    customHook:
      enabled: true
      required_executable: 'custom-hook'

并将脚本放在项目根目录的 .git-hooks 目录中。所以我把这个脚本放在 .git-hook 目录中进行测试:

#custom-hook.sh    
echo hey

这是温馨的错误消息:

Hook must specify a `required_executable` or `command` that is tracked by git (i.e. is a path relative to the root of the repository) so that it can be signed
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:39:in `hook_path'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:92:in `hook_contents'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:88:in `signature'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:61:in `signature_changed?'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:51:in `select'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:51:in `modified_plugins'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:55:in `check_for_modified_plugins'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:8:in `load_hooks'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_runner.rb:195:in `load_hooks'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_runner.rb:32:in `block in run'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/interrupt_handler.rb:84:in `isolate_from_interrupts'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_runner.rb:28:in `run'
.git/hooks/pre-push:79:in `<main>'

显然,它抱怨找不到可执行文件,所以我猜格式不对,但那里的信息很少,我被卡住了。

从错误消息来看,custom-hook 似乎必须相对于您的 git 存储库的根目录。也许尝试将那个放入 ./bin/custom-hook?