无法在overcommit gem

时间:2016-08-23 12:36:43

标签: ruby-on-rails ruby shell rubygems ruby-overcommit

我不确定这是否应该在官方存储库问题中发布(我有时会看到'问题'标记在那里)。但是如果你认为这是一个适当的地方可以问这个,如果有人可以帮助我,那就太好了。

我一直试图在overcommit gem中添加自定义脚本而没有运气。 官方文档中的内容是在.overcommit.yml中添加行:

 PostCheckout:
  CustomScript:
    enabled: true
    required_executable: './bin/custom-script'

(所以我已经这样做了:)

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

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

#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>'

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

1 个答案:

答案 0 :(得分:1)

从错误消息中,似乎custom-hook必须相对于git存储库的根目录。也许试着把那个放进./bin/custom-hook