rails_git_hooks 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +86 -168
  4. data/lib/rails_git_hooks/checks/commit_msg/not_empty.rb +25 -0
  5. data/lib/rails_git_hooks/checks/commit_msg.rb +1 -0
  6. data/lib/rails_git_hooks/checks/post_checkout/bundle_install.rb +16 -0
  7. data/lib/rails_git_hooks/checks/post_checkout/db_migrate.rb +16 -0
  8. data/lib/rails_git_hooks/checks/post_checkout/npm_install.rb +16 -0
  9. data/lib/rails_git_hooks/checks/post_checkout/yarn_install.rb +16 -0
  10. data/lib/rails_git_hooks/checks/post_checkout.rb +13 -0
  11. data/lib/rails_git_hooks/checks/post_merge/bundle_install.rb +16 -0
  12. data/lib/rails_git_hooks/checks/post_merge/db_migrate.rb +16 -0
  13. data/lib/rails_git_hooks/checks/post_merge/npm_install.rb +16 -0
  14. data/lib/rails_git_hooks/checks/post_merge/yarn_install.rb +16 -0
  15. data/lib/rails_git_hooks/checks/post_merge.rb +13 -0
  16. data/lib/rails_git_hooks/checks/pre_commit/erblint.rb +30 -0
  17. data/lib/rails_git_hooks/checks/pre_commit/eslint.rb +34 -0
  18. data/lib/rails_git_hooks/checks/pre_commit/go_vet.rb +30 -0
  19. data/lib/rails_git_hooks/checks/pre_commit/golint.rb +30 -0
  20. data/lib/rails_git_hooks/checks/pre_commit/haml_lint.rb +30 -0
  21. data/lib/rails_git_hooks/checks/pre_commit/jslint.rb +34 -0
  22. data/lib/rails_git_hooks/checks/pre_commit/php_lint.rb +30 -0
  23. data/lib/rails_git_hooks/checks/pre_commit/pylint.rb +30 -0
  24. data/lib/rails_git_hooks/checks/pre_commit/rails_best_practices.rb +31 -0
  25. data/lib/rails_git_hooks/checks/pre_commit/scss_lint.rb +30 -0
  26. data/lib/rails_git_hooks/checks/pre_commit.rb +10 -0
  27. data/lib/rails_git_hooks/checks/pre_push/run_go_test.rb +24 -0
  28. data/lib/rails_git_hooks/checks/pre_push/run_pytest.rb +24 -0
  29. data/lib/rails_git_hooks/checks/pre_push.rb +2 -0
  30. data/lib/rails_git_hooks/checks/shared/bundle_install_check.rb +28 -0
  31. data/lib/rails_git_hooks/checks/shared/db_migrate_check.rb +28 -0
  32. data/lib/rails_git_hooks/checks/shared/npm_install_check.rb +28 -0
  33. data/lib/rails_git_hooks/checks/shared/yarn_install_check.rb +28 -0
  34. data/lib/rails_git_hooks/checks.rb +6 -0
  35. data/lib/rails_git_hooks/cli.rb +8 -100
  36. data/lib/rails_git_hooks/config/constants.rb +7 -1
  37. data/lib/rails_git_hooks/config/defaults.yml +321 -1
  38. data/lib/rails_git_hooks/install/installer.rb +31 -5
  39. data/lib/rails_git_hooks/runtime/check_registry.rb +22 -1
  40. data/lib/rails_git_hooks/runtime/override_config.rb +10 -4
  41. data/lib/rails_git_hooks/runtime/repository.rb +8 -0
  42. data/lib/rails_git_hooks/runtime/runner.rb +4 -0
  43. data/lib/rails_git_hooks/version.rb +1 -1
  44. data/templates/hooks/post-checkout +13 -0
  45. data/templates/hooks/post-merge +13 -0
  46. metadata +31 -44
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class Golint < Base
7
+ check_definition key: 'golint-check',
8
+ hook: :pre_commit,
9
+ description: 'Run golint on staged Go files',
10
+ file_based: true,
11
+ enabled: false,
12
+ quiet: true,
13
+ dependencies: { 'executables' => ['golint'] },
14
+ command: %w[golint],
15
+ install_hint: 'Install golint or override command in config'
16
+
17
+ def run
18
+ go_files = applicable_files.select { |path| File.file?(path) && File.extname(path) == '.go' }
19
+ return CheckResult.pass if go_files.empty?
20
+
21
+ output, status = capture(*Array(config['command']), *go_files)
22
+ return CheckResult.pass if status.success?
23
+
24
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
25
+ CheckResult.fail(messages: messages)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class HamlLint < Base
7
+ check_definition key: 'haml-lint-check',
8
+ hook: :pre_commit,
9
+ description: 'Run haml-lint on staged HAML files',
10
+ file_based: true,
11
+ enabled: false,
12
+ quiet: true,
13
+ dependencies: { 'executables' => ['bundle'], 'libraries' => ['haml_lint'] },
14
+ command: %w[bundle exec haml-lint],
15
+ install_hint: 'Add `gem "haml_lint"` to your Gemfile and run bundle install'
16
+
17
+ def run
18
+ haml_files = applicable_files.select { |path| path.end_with?('.haml') && File.file?(path) }
19
+ return CheckResult.pass if haml_files.empty?
20
+
21
+ output, status = capture(*Array(config['command']), *haml_files)
22
+ return CheckResult.pass if status.success?
23
+
24
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
25
+ CheckResult.fail(messages: messages)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class Jslint < Base
7
+ JS_EXTENSIONS = %w[.js .jsx .mjs .cjs].freeze
8
+
9
+ check_definition key: 'jslint-check',
10
+ hook: :pre_commit,
11
+ description: 'Run jslint on staged JavaScript files',
12
+ file_based: true,
13
+ enabled: false,
14
+ quiet: true,
15
+ dependencies: { 'executables' => ['jslint'] },
16
+ command: %w[jslint],
17
+ install_hint: 'Install jslint or override command in config'
18
+
19
+ def run
20
+ js_files = applicable_files.select do |path|
21
+ File.file?(path) && JS_EXTENSIONS.include?(File.extname(path))
22
+ end
23
+ return CheckResult.pass if js_files.empty?
24
+
25
+ output, status = capture(*Array(config['command']), *js_files)
26
+ return CheckResult.pass if status.success?
27
+
28
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
29
+ CheckResult.fail(messages: messages)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class PhpLint < Base
7
+ check_definition key: 'php-lint-check',
8
+ hook: :pre_commit,
9
+ description: 'Run php -l (syntax check) on staged PHP files',
10
+ file_based: true,
11
+ enabled: false,
12
+ quiet: true,
13
+ dependencies: { 'executables' => ['php'] },
14
+ command: %w[php -l],
15
+ install_hint: 'Ensure PHP is installed and on PATH'
16
+
17
+ def run
18
+ php_files = applicable_files.select { |path| path.end_with?('.php') && File.file?(path) }
19
+ return CheckResult.pass if php_files.empty?
20
+
21
+ output, status = capture(*Array(config['command']), *php_files)
22
+ return CheckResult.pass if status.success?
23
+
24
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
25
+ CheckResult.fail(messages: messages)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class Pylint < Base
7
+ check_definition key: 'pylint-check',
8
+ hook: :pre_commit,
9
+ description: 'Run pylint on staged Python files',
10
+ file_based: true,
11
+ enabled: false,
12
+ quiet: true,
13
+ dependencies: { 'executables' => ['pylint'] },
14
+ command: %w[pylint],
15
+ install_hint: 'Install pylint (e.g. pip install pylint) or override command in config'
16
+
17
+ def run
18
+ py_files = applicable_files.select { |path| path.end_with?('.py') && File.file?(path) }
19
+ return CheckResult.pass if py_files.empty?
20
+
21
+ output, status = capture(*Array(config['command']), *py_files)
22
+ return CheckResult.pass if status.success?
23
+
24
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
25
+ CheckResult.fail(messages: messages)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class RailsBestPractices < Base
7
+ check_definition key: 'rails-best-practices',
8
+ hook: :pre_commit,
9
+ description: 'Warn on Rails best practices violations',
10
+ file_based: true,
11
+ enabled: false,
12
+ on_fail: :warn,
13
+ quiet: true,
14
+ dependencies: { 'executables' => ['bundle'], 'libraries' => ['rails_best_practices'] },
15
+ command: %w[bundle exec rails_best_practices],
16
+ install_hint: 'Add `gem "rails_best_practices"` to your Gemfile and run bundle install'
17
+
18
+ def run
19
+ ruby_files = applicable_files.select { |path| File.extname(path) == '.rb' && File.file?(path) }
20
+ return CheckResult.pass if ruby_files.empty?
21
+
22
+ output, status = capture(*Array(config['command']), *ruby_files)
23
+ return CheckResult.pass if status.success?
24
+
25
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
26
+ CheckResult.fail(messages: messages)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PreCommit
6
+ class ScssLint < Base
7
+ check_definition key: 'scss-lint-check',
8
+ hook: :pre_commit,
9
+ description: 'Run scss-lint on staged SCSS files',
10
+ file_based: true,
11
+ enabled: false,
12
+ quiet: true,
13
+ dependencies: { 'executables' => ['bundle'], 'libraries' => ['scss_lint'] },
14
+ command: %w[bundle exec scss-lint],
15
+ install_hint: 'Add `gem "scss_lint"` to your Gemfile and run bundle install'
16
+
17
+ def run
18
+ scss_files = applicable_files.select { |path| path.end_with?('.scss') && File.file?(path) }
19
+ return CheckResult.pass if scss_files.empty?
20
+
21
+ output, status = capture(*Array(config['command']), *scss_files)
22
+ return CheckResult.pass if status.success?
23
+
24
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
25
+ CheckResult.fail(messages: messages)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -14,3 +14,13 @@ require_relative 'pre_commit/json_format_check'
14
14
  require_relative 'pre_commit/migrations_check'
15
15
  require_relative 'pre_commit/whitespace_check'
16
16
  require_relative 'pre_commit/rubocop'
17
+ require_relative 'pre_commit/rails_best_practices'
18
+ require_relative 'pre_commit/erblint'
19
+ require_relative 'pre_commit/eslint'
20
+ require_relative 'pre_commit/golint'
21
+ require_relative 'pre_commit/haml_lint'
22
+ require_relative 'pre_commit/jslint'
23
+ require_relative 'pre_commit/php_lint'
24
+ require_relative 'pre_commit/pylint'
25
+ require_relative 'pre_commit/scss_lint'
26
+ require_relative 'pre_commit/go_vet'
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PrePush
6
+ class RunGoTest < Base
7
+ check_definition key: 'run-go-test',
8
+ hook: :pre_push,
9
+ description: 'Run go test suite before push',
10
+ dependencies: { 'executables' => ['go'] },
11
+ command: %w[go test ./...],
12
+ install_hint: 'Ensure Go toolchain is installed and `go test ./...` runs successfully'
13
+
14
+ def run
15
+ output, status = capture(*Array(config['command']))
16
+ return CheckResult.pass if status.success?
17
+
18
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
19
+ CheckResult.fail(messages: messages)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ module PrePush
6
+ class RunPytest < Base
7
+ check_definition key: 'run-pytest',
8
+ hook: :pre_push,
9
+ description: 'Run pytest test suite before push',
10
+ dependencies: { 'executables' => ['pytest'] },
11
+ command: %w[pytest],
12
+ install_hint: 'Install pytest (e.g. pip install pytest) and ensure pytest runs successfully'
13
+
14
+ def run
15
+ output, status = capture(*Array(config['command']))
16
+ return CheckResult.pass if status.success?
17
+
18
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
19
+ CheckResult.fail(messages: messages)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -8,3 +8,5 @@ module GitHooks
8
8
  end
9
9
 
10
10
  require_relative 'pre_push/run_tests'
11
+ require_relative 'pre_push/run_pytest'
12
+ require_relative 'pre_push/run_go_test'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ # Shared logic and options for "run bundle install when Gemfile/Gemfile.lock changed"
6
+ # (post-checkout and post-merge). Each hook has its own class that passes hook + description.
7
+ module BundleInstallCheck
8
+ DEFINITION_OPTIONS = {
9
+ file_based: true,
10
+ enabled: false,
11
+ include: %w[Gemfile Gemfile.lock],
12
+ dependencies: { executables: ['bundle'] },
13
+ command: %w[bundle install],
14
+ install_hint: 'Ensure bundle is available'
15
+ }.freeze
16
+
17
+ def run
18
+ return CheckResult.pass if applicable_files.empty?
19
+
20
+ output, status = capture(*Array(config['command']))
21
+ return CheckResult.pass if status.success?
22
+
23
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
24
+ CheckResult.fail(messages: messages)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ # Shared logic and options for "run db:migrate when migrations or schema changed"
6
+ # (post-checkout and post-merge). Each hook has its own class that passes hook + description.
7
+ module DbMigrateCheck
8
+ DEFINITION_OPTIONS = {
9
+ file_based: true,
10
+ enabled: false,
11
+ include: ['db/migrate/*.rb', 'db/schema.rb', 'db/structure.sql'],
12
+ dependencies: { executables: ['bundle'] },
13
+ command: %w[bundle exec rails db:migrate],
14
+ install_hint: 'Rails app with db:migrate (or override command in config)'
15
+ }.freeze
16
+
17
+ def run
18
+ return CheckResult.pass if applicable_files.empty?
19
+
20
+ output, status = capture(*Array(config['command']))
21
+ return CheckResult.pass if status.success?
22
+
23
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
24
+ CheckResult.fail(messages: messages)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ # Shared logic and options for "run npm install when package.json/package-lock.json changed"
6
+ # (post-checkout and post-merge). Each hook has its own class that passes hook + description.
7
+ module NpmInstallCheck
8
+ DEFINITION_OPTIONS = {
9
+ file_based: true,
10
+ enabled: false,
11
+ include: %w[package.json package-lock.json],
12
+ dependencies: { executables: ['npm'] },
13
+ command: %w[npm install],
14
+ install_hint: 'Ensure npm is available'
15
+ }.freeze
16
+
17
+ def run
18
+ return CheckResult.pass if applicable_files.empty?
19
+
20
+ output, status = capture(*Array(config['command']))
21
+ return CheckResult.pass if status.success?
22
+
23
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
24
+ CheckResult.fail(messages: messages)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module Checks
5
+ # Shared logic and options for "run yarn install when package.json/yarn.lock changed"
6
+ # (post-checkout and post-merge). Each hook has its own class that passes hook + description.
7
+ module YarnInstallCheck
8
+ DEFINITION_OPTIONS = {
9
+ file_based: true,
10
+ enabled: false,
11
+ include: %w[package.json yarn.lock],
12
+ dependencies: { executables: ['yarn'] },
13
+ command: %w[yarn install],
14
+ install_hint: 'Ensure yarn is available'
15
+ }.freeze
16
+
17
+ def run
18
+ return CheckResult.pass if applicable_files.empty?
19
+
20
+ output, status = capture(*Array(config['command']))
21
+ return CheckResult.pass if status.success?
22
+
23
+ messages = output.split("\n").map(&:rstrip).reject(&:empty?)
24
+ CheckResult.fail(messages: messages)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -4,3 +4,9 @@ require_relative 'checks/base'
4
4
  require_relative 'checks/pre_commit'
5
5
  require_relative 'checks/commit_msg'
6
6
  require_relative 'checks/pre_push'
7
+ require_relative 'checks/shared/bundle_install_check'
8
+ require_relative 'checks/shared/db_migrate_check'
9
+ require_relative 'checks/shared/npm_install_check'
10
+ require_relative 'checks/shared/yarn_install_check'
11
+ require_relative 'checks/post_checkout'
12
+ require_relative 'checks/post_merge'
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rails_git_hooks'
4
- require 'yaml'
5
4
 
6
5
  module GitHooks
7
6
  class CLI
@@ -10,22 +9,13 @@ module GitHooks
10
9
  end
11
10
 
12
11
  def run(argv)
13
- case argv[0]
12
+ cmd = argv[0].to_s.strip.tr('_', '-')
13
+ case cmd
14
14
  when 'install'
15
- run_install(argv[1..])
16
- when 'list'
17
- run_list
15
+ run_install
18
16
  when 'init'
19
17
  run_init
20
- when 'disable'
21
- run_disable(argv[1..])
22
- when 'enable'
23
- run_enable(argv[1..])
24
- when 'set'
25
- run_set(argv[1..])
26
- when 'show-config'
27
- run_show_config
28
- when nil, '-h', '--help'
18
+ when '', '-h', '--help'
29
19
  print_help
30
20
  else
31
21
  warn "Unknown command: #{argv[0]}"
@@ -36,118 +26,36 @@ module GitHooks
36
26
 
37
27
  private
38
28
 
39
- def run_install(args)
29
+ def run_install
40
30
  installer = Installer.new
41
- installed = installer.install(*args)
31
+ installed = installer.install
42
32
  puts "Installed hooks: #{installed.join(', ')}"
43
33
  rescue GitHooks::Error => e
44
34
  warn "Error: #{e.message}"
45
35
  exit 1
46
36
  end
47
37
 
48
- def run_list
49
- repo = Repository.new
50
- config = OverrideConfig.new(repo: repo)
51
-
52
- puts 'Available hooks:'
53
- Installer.available_hook_names.each { |name| puts " #{name}" }
54
- puts
55
- puts 'Available checks:'
56
- CheckRegistry.all.each do |definition|
57
- check_config = config.config_for(definition)
58
- puts " #{definition.key} (#{definition.hook_section}/#{definition.config_name}, enabled=#{check_config['enabled']})"
59
- end
60
- rescue GitHooks::Error
61
- puts 'Available hooks:'
62
- Installer.available_hook_names.each { |name| puts " #{name}" }
63
- puts
64
- puts 'Available checks:'
65
- CheckRegistry.all.each do |definition|
66
- puts " #{definition.key} (#{definition.hook_section}/#{definition.config_name})"
67
- end
68
- end
69
-
70
38
  def run_init
71
39
  config = OverrideConfig.new(repo: Repository.new)
72
40
  config.init
73
41
  puts "Initialized #{Constants::CONFIG_FILE}"
74
42
  end
75
43
 
76
- def run_disable(args)
77
- key = args.first
78
- if key.nil?
79
- warn 'Usage: rails_git_hooks disable CHECK_NAME'
80
- exit 1
81
- end
82
-
83
- repo = Repository.new
84
- definition = CheckRegistry.find!(key)
85
- OverrideConfig.new(repo: repo).set_option(definition, 'enabled', false)
86
- puts "Disabled: #{key}"
87
- end
88
-
89
- def run_enable(args)
90
- key = args.first
91
- if key.nil?
92
- warn 'Usage: rails_git_hooks enable CHECK_NAME'
93
- exit 1
94
- end
95
-
96
- repo = Repository.new
97
- definition = CheckRegistry.find!(key)
98
- OverrideConfig.new(repo: repo).set_option(definition, 'enabled', true)
99
- puts "Enabled: #{key}"
100
- end
101
-
102
- def run_set(args)
103
- key, option, value = args
104
- if key.nil? || option.nil? || value.nil?
105
- warn 'Usage: rails_git_hooks set CHECK_NAME OPTION VALUE'
106
- exit 1
107
- end
108
-
109
- definition = CheckRegistry.find!(key)
110
- OverrideConfig.new(repo: Repository.new).set_option(definition, option, value)
111
- puts "Updated: #{key} #{option}=#{value}"
112
- end
113
-
114
- def run_show_config
115
- repo = Repository.new
116
- config = OverrideConfig.new(repo: repo).effective_config(CheckRegistry.all)
117
- puts YAML.dump(config)
118
- end
119
-
120
44
  def print_help
121
45
  puts <<~HELP
122
46
  rails_git_hooks - Install configurable Git hooks
123
47
 
124
48
  Usage:
125
- rails_git_hooks install [HOOK...]
126
- rails_git_hooks list
49
+ rails_git_hooks install
127
50
  rails_git_hooks init
128
- rails_git_hooks enable CHECK_NAME
129
- rails_git_hooks disable CHECK_NAME
130
- rails_git_hooks set CHECK_NAME OPTION VALUE
131
- rails_git_hooks show-config
132
51
  rails_git_hooks --help
133
52
 
134
53
  Commands:
135
- install Install hooks into current repo's .git/hooks.
136
- list List available hooks and checks.
54
+ install Install hooks that have at least one enabled check (merged config: defaults + .rails_git_hooks.yml + .rails_git_hooks.local.yml).
137
55
  init Create a sparse #{Constants::CONFIG_FILE} override file.
138
- enable Enable a check in #{Constants::CONFIG_FILE}.
139
- disable Disable a check in #{Constants::CONFIG_FILE}.
140
- set Set a check option like on_fail/on_warn/quiet.
141
- show-config Print effective merged configuration.
142
56
 
143
57
  Examples:
144
58
  rails_git_hooks install
145
- rails_git_hooks enable rubocop-check
146
- rails_git_hooks disable migrations-check
147
- rails_git_hooks set debugger-check on_fail fail
148
- rails_git_hooks set rubocop-check quiet true
149
- rails_git_hooks show-config
150
- rails_git_hooks install commit-msg pre-commit
151
59
  HELP
152
60
  end
153
61
  end
@@ -8,13 +8,19 @@ module GitHooks
8
8
  RUNTIME_SOURCE_DIR = File.expand_path('lib/rails_git_hooks', GEM_ROOT).freeze
9
9
  RUNTIME_DIR_NAME = 'rails_git_hooks'
10
10
  CONFIG_FILE = '.rails_git_hooks.yml'
11
+ CONFIG_FILE_LOCAL = '.rails_git_hooks.local.yml'
11
12
 
12
13
  # Default hooks when install is run with no arguments.
13
14
  DEFAULT_HOOKS = %w[commit-msg pre-commit].freeze
14
15
  HOOK_CONFIG_NAMES = {
15
16
  pre_commit: 'PreCommit',
16
17
  commit_msg: 'CommitMsg',
17
- pre_push: 'PrePush'
18
+ pre_push: 'PrePush',
19
+ post_checkout: 'PostCheckout',
20
+ post_merge: 'PostMerge'
18
21
  }.freeze
22
+
23
+ # Section name (from YAML) -> hook script name (e.g. for install)
24
+ SECTION_TO_HOOK = HOOK_CONFIG_NAMES.invert.transform_values { |sym| sym.to_s.tr('_', '-') }.freeze
19
25
  end
20
26
  end