overcommit 0.26.0 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +38 -0
  3. data/config/starter.yml +2 -1
  4. data/lib/overcommit/cli.rb +2 -0
  5. data/lib/overcommit/command_splitter.rb +144 -0
  6. data/lib/overcommit/configuration.rb +45 -10
  7. data/lib/overcommit/exceptions.rb +3 -0
  8. data/lib/overcommit/git_repo.rb +8 -0
  9. data/lib/overcommit/hook/base.rb +16 -2
  10. data/lib/overcommit/hook/post_rewrite/base.rb +1 -1
  11. data/lib/overcommit/hook/pre_commit/case_conflicts.rb +1 -1
  12. data/lib/overcommit/hook/pre_commit/hard_tabs.rb +1 -1
  13. data/lib/overcommit/hook/pre_commit/html_hint.rb +21 -0
  14. data/lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb +1 -1
  15. data/lib/overcommit/hook/pre_commit/merge_conflicts.rb +1 -1
  16. data/lib/overcommit/hook/pre_commit/semi_standard.rb +2 -2
  17. data/lib/overcommit/hook/pre_commit/standard.rb +2 -2
  18. data/lib/overcommit/hook/pre_commit/trailing_whitespace.rb +1 -1
  19. data/lib/overcommit/hook_context/base.rb +43 -1
  20. data/lib/overcommit/hook_context/commit_msg.rb +2 -2
  21. data/lib/overcommit/hook_context/post_checkout.rb +8 -0
  22. data/lib/overcommit/hook_context/post_rewrite.rb +29 -0
  23. data/lib/overcommit/hook_context/pre_commit.rb +1 -14
  24. data/lib/overcommit/hook_loader/plugin_hook_loader.rb +42 -3
  25. data/lib/overcommit/hook_runner.rb +12 -0
  26. data/lib/overcommit/hook_signer.rb +41 -6
  27. data/lib/overcommit/logger.rb +5 -0
  28. data/lib/overcommit/printer.rb +1 -1
  29. data/lib/overcommit/subprocess.rb +22 -1
  30. data/lib/overcommit/utils.rb +58 -4
  31. data/lib/overcommit/version.rb +1 -1
  32. data/template-dir/hooks/commit-msg +24 -4
  33. data/template-dir/hooks/overcommit-hook +24 -4
  34. data/template-dir/hooks/post-checkout +24 -4
  35. data/template-dir/hooks/post-commit +24 -4
  36. data/template-dir/hooks/post-merge +24 -4
  37. data/template-dir/hooks/post-rewrite +24 -4
  38. data/template-dir/hooks/pre-commit +24 -4
  39. data/template-dir/hooks/pre-push +24 -4
  40. data/template-dir/hooks/pre-rebase +24 -4
  41. metadata +6 -3
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.26.0'
3
+ VERSION = '0.27.0'
4
4
  end
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message
@@ -25,17 +25,32 @@ if hook_type == 'overcommit-hook'
25
25
  exit 64 # EX_USAGE
26
26
  end
27
27
 
28
+ # Check if Overcommit should invoke a Bundler context for loading gems
29
+ require 'yaml'
30
+ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
31
+ ENV['BUNDLE_GEMFILE'] = gemfile
32
+ require 'bundler/setup'
33
+ end
34
+
28
35
  begin
29
36
  require 'overcommit'
30
37
  rescue LoadError
31
- puts 'This repository contains hooks installed by Overcommit, but the ' \
32
- "overcommit gem is not installed.\n" \
33
- 'Install it with `gem install overcommit`.'
34
- exit
38
+ if gemfile
39
+ puts 'You have specified the `gemfile` option in your Overcommit ' \
40
+ 'configuration but have not added the `overcommit` gem to ' \
41
+ "#{gemfile}."
42
+ else
43
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
44
+ "`overcommit` gem is not installed.\n" \
45
+ 'Install it with `gem install overcommit`.'
46
+ end
47
+
48
+ exit 64 # EX_USAGE
35
49
  end
36
50
 
37
51
  begin
38
52
  logger = Overcommit::Logger.new(STDOUT)
53
+ Overcommit::Utils.log = logger
39
54
 
40
55
  # Ensure master hook is up-to-date
41
56
  installer = Overcommit::Installer.new(logger)
@@ -61,6 +76,11 @@ rescue Overcommit::Exceptions::HookContextLoadError => error
61
76
  puts error
62
77
  puts 'Are you running an old version of Overcommit?'
63
78
  exit 69 # EX_UNAVAILABLE
79
+ rescue Overcommit::Exceptions::HookLoadError,
80
+ Overcommit::Exceptions::InvalidHookDefinition => error
81
+ puts error.message
82
+ puts error.backtrace
83
+ exit 78 # EX_CONFIG
64
84
  rescue Overcommit::Exceptions::HookSetupFailed,
65
85
  Overcommit::Exceptions::HookCleanupFailed => error
66
86
  puts error.message