jish / pre-commit

A slightly improved pre-commit hook for git
https://jish.github.io/pre-commit/
Other
796 stars 96 forks source link

Bundler 1.15.0 incompatibility #258

Closed jonatanklosko closed 7 years ago

jonatanklosko commented 7 years ago

It's a fault of the pluginator dependency, I'm writing just for the record. See rvm/pluginator/issues/10.

mpapis commented 7 years ago

fixed in pluginator 1.4.1

jonatanklosko commented 7 years ago

Great!

jonatanklosko commented 7 years ago

I can still see an error, but now it's probably some pre-commit thing

jonatanklosko@mockingjay:~/projects/worldcubeassociation.org/WcaOnRails (update-pre-commit) $ bundle exec pre-commit run git
bundler: failed to load command: pre-commit (/home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit)
NameError: uninitialized constant PreCommit::Checks::Plugin
Did you mean?  Pluginator
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/plugins/pre_commit/checks/go_fmt.rb:3:in `<module:Checks>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/plugins/pre_commit/checks/go_fmt.rb:2:in `<module:PreCommit>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/plugins/pre_commit/checks/go_fmt.rb:1:in `<top (required)>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/autodetect.rb:76:in `require'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/autodetect.rb:76:in `block in load_plugins'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/autodetect.rb:75:in `each'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/autodetect.rb:75:in `load_plugins'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/autodetect.rb:55:in `refresh'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/autodetect.rb:44:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator/extendable_autodetect.rb:42:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator.rb:33:in `new'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.4.1/lib/pluginator.rb:33:in `find'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/pre-commit/plugins_list.rb:4:in `pluginator'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/pre-commit/runner.rb:17:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/pre-commit/cli.rb:38:in `new'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/pre-commit/cli.rb:38:in `execute_run'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/lib/pre-commit/cli.rb:21:in `execute'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.33.0/bin/pre-commit:10:in `<top (required)>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit:22:in `load'
  /home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit:22:in `<top (required)>'
jish commented 7 years ago

Released 0.34.0 https://rubygems.org/gems/pre-commit/versions/0.34.0

jonatanklosko commented 7 years ago

Unfortunately the error remains. I see that #259 only updates the pluginator gem, but it may be something wrong with the pre-commit itself.

jonatanklosko@mockingjay:~/projects/worldcubeassociation.org/WcaOnRails (update-gems) $ bundle list | grep "pre-commit\|pluginator"
  * pluginator (1.5.0)
  * pre-commit (0.34.0)
jonatanklosko@mockingjay:~/projects/worldcubeassociation.org/WcaOnRails (update-gems) $ bundle exec pre-commit run git
bundler: failed to load command: pre-commit (/home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit)
NameError: uninitialized constant PreCommit::Checks::Plugin
Did you mean?  Pluginator
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb:3:in `<module:Checks>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb:2:in `<module:PreCommit>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb:1:in `<top (required)>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:81:in `require'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:81:in `block in load_plugins'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:80:in `each'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:80:in `load_plugins'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:60:in `refresh'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:49:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/extendable_autodetect.rb:42:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator.rb:37:in `new'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator.rb:37:in `find'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/plugins_list.rb:4:in `pluginator'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/runner.rb:17:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/cli.rb:38:in `new'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/cli.rb:38:in `execute_run'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/cli.rb:21:in `execute'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/bin/pre-commit:10:in `<top (required)>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit:22:in `load'
  /home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit:22:in `<top (required)>'
jonatanklosko commented 7 years ago

Bump

mpapis commented 7 years ago

@jonatanklosko I can not reproduce this error, can you open a new ticket and show in it the error and full content of /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb

jonatanklosko commented 7 years ago

(What did you mean by "new ticket", a new issue?)

The error:

bundler: failed to load command: pre-commit (/home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit)
NameError: uninitialized constant PreCommit::Checks::Plugin
Did you mean?  Pluginator
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb:3:in `<module:Checks>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb:2:in `<module:PreCommit>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb:1:in `<top (required)>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:81:in `require'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:81:in `block in load_plugins'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:80:in `each'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:80:in `load_plugins'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:60:in `refresh'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/autodetect.rb:49:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator/extendable_autodetect.rb:42:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator.rb:37:in `new'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pluginator-1.5.0/lib/pluginator.rb:37:in `find'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/plugins_list.rb:4:in `pluginator'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/runner.rb:17:in `initialize'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/cli.rb:38:in `new'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/cli.rb:38:in `execute_run'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/pre-commit/cli.rb:21:in `execute'
  /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/bin/pre-commit:10:in `<top (required)>'
  /home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit:22:in `load'
  /home/jonatanklosko/.rbenv/versions/2.4.1/bin/pre-commit:22:in `<top (required)>'

And the file cat /home/jonatanklosko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pre-commit-0.34.0/lib/plugins/pre_commit/checks/go_fmt.rb

module PreCommit
  module Checks
    class GoFmt < Plugin

      def call(staged_files)
        staged_files = staged_files.grep(/\.go$/)
        return if staged_files.empty?

        errors = staged_files.map { |file| run_check(file) }.compact
        return if errors.empty?

        errors.join("\n")
      end

      def run_check(file)
        cmd = "gofmt -l #{file} 2>&1"
        %x[ #{cmd} ]
      end

      def self.description
        "Detects bad Go formatting"
      end
    end
  end
end