rails_git_hooks 0.7.0 → 0.7.1

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -6
  3. data/README.md +143 -77
  4. data/lib/rails_git_hooks/checks/base.rb +55 -0
  5. data/lib/rails_git_hooks/checks/commit_msg/jira_prefix.rb +31 -0
  6. data/lib/rails_git_hooks/checks/commit_msg.rb +10 -0
  7. data/lib/rails_git_hooks/checks/pre_commit/debugger_check.rb +43 -0
  8. data/lib/rails_git_hooks/checks/pre_commit/default_branch.rb +20 -0
  9. data/lib/rails_git_hooks/checks/pre_commit/json_format_check.rb +30 -0
  10. data/lib/rails_git_hooks/checks/pre_commit/migrations_check.rb +37 -0
  11. data/lib/rails_git_hooks/checks/pre_commit/rubocop.rb +30 -0
  12. data/lib/rails_git_hooks/checks/pre_commit/whitespace_check.rb +31 -0
  13. data/lib/rails_git_hooks/checks/pre_commit/yaml_format_check.rb +31 -0
  14. data/lib/rails_git_hooks/checks/pre_commit.rb +16 -0
  15. data/lib/rails_git_hooks/checks/pre_push/run_tests.rb +24 -0
  16. data/lib/rails_git_hooks/checks/pre_push.rb +10 -0
  17. data/lib/rails_git_hooks/checks.rb +6 -0
  18. data/lib/rails_git_hooks/cli.rb +78 -59
  19. data/lib/rails_git_hooks/config/constants.rb +20 -0
  20. data/lib/rails_git_hooks/config/defaults.yml +127 -0
  21. data/lib/rails_git_hooks/config/defaults_loader.rb +42 -0
  22. data/lib/rails_git_hooks/core/check_definition.rb +63 -0
  23. data/lib/rails_git_hooks/core/check_result.rb +41 -0
  24. data/lib/rails_git_hooks/core/error.rb +5 -0
  25. data/lib/rails_git_hooks/install/installer.rb +53 -0
  26. data/lib/rails_git_hooks/runtime/check_registry.rb +29 -0
  27. data/lib/rails_git_hooks/runtime/dependency_checker.rb +51 -0
  28. data/lib/rails_git_hooks/runtime/file_matcher.rb +23 -0
  29. data/lib/rails_git_hooks/runtime/override_config.rb +125 -0
  30. data/lib/rails_git_hooks/runtime/policy_resolver.rb +36 -0
  31. data/lib/rails_git_hooks/runtime/repository.rb +61 -0
  32. data/lib/rails_git_hooks/runtime/runner.rb +76 -0
  33. data/lib/rails_git_hooks/runtime.rb +25 -0
  34. data/lib/rails_git_hooks/version.rb +1 -1
  35. data/lib/rails_git_hooks.rb +14 -6
  36. data/templates/hooks/commit-msg +7 -17
  37. data/templates/hooks/pre-commit +7 -21
  38. data/templates/hooks/pre-push +7 -17
  39. metadata +30 -9
  40. data/lib/rails_git_hooks/constants.rb +0 -21
  41. data/lib/rails_git_hooks/installer.rb +0 -156
  42. data/templates/shared/commit_msg/jira_prefix.rb +0 -20
  43. data/templates/shared/pre_commit/debugger_check.rb +0 -48
  44. data/templates/shared/pre_commit/default_branch.rb +0 -9
  45. data/templates/shared/pre_commit/rubocop_check.rb +0 -24
  46. data/templates/shared/pre_commit/whitespace_check.rb +0 -25
  47. data/templates/shared/pre_push/run_tests.rb +0 -9
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ class DependencyChecker
5
+ def initialize(repo:)
6
+ @repo = repo
7
+ end
8
+
9
+ def check(config)
10
+ dependencies = config.fetch('dependencies', {})
11
+ missing = []
12
+
13
+ Array(dependencies['executables']).each do |name|
14
+ missing << "missing executable: #{name}" unless executable_available?(name)
15
+ end
16
+
17
+ Array(dependencies['libraries']).each do |name|
18
+ missing << "missing library: #{name}" unless library_available?(name)
19
+ end
20
+
21
+ Array(dependencies['files']).each do |name|
22
+ path = File.expand_path(name, @repo.root)
23
+ missing << "missing file: #{name}" unless File.exist?(path)
24
+ end
25
+
26
+ return CheckResult.pass if missing.empty?
27
+
28
+ hint = config['install_hint']
29
+ messages = missing.dup
30
+ messages << hint if hint && !hint.empty?
31
+ CheckResult.fail(messages: messages, reason: :missing_dependency)
32
+ end
33
+
34
+ private
35
+
36
+ def executable_available?(name)
37
+ return File.executable?(File.expand_path(name, @repo.root)) if name.include?(File::SEPARATOR)
38
+
39
+ ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).any? do |dir|
40
+ File.executable?(File.join(dir, name))
41
+ end
42
+ end
43
+
44
+ def library_available?(name)
45
+ require name
46
+ true
47
+ rescue LoadError
48
+ false
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ module FileMatcher
5
+ FLAGS = File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB
6
+
7
+ module_function
8
+
9
+ def filter(paths, include_patterns:, exclude_patterns:)
10
+ filtered = if include_patterns.empty?
11
+ paths
12
+ else
13
+ paths.select { |path| matches_any?(path, include_patterns) }
14
+ end
15
+
16
+ filtered.reject { |path| matches_any?(path, exclude_patterns) }
17
+ end
18
+
19
+ def matches_any?(path, patterns)
20
+ Array(patterns).any? { |pattern| File.fnmatch?(pattern, path, FLAGS) }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'yaml'
5
+
6
+ require_relative '../config/defaults_loader'
7
+
8
+ module GitHooks
9
+ class OverrideConfig
10
+ BOOLEAN_OPTIONS = %w[enabled quiet].freeze
11
+ POLICY_OPTIONS = %w[on_fail on_warn on_missing_dependency].freeze
12
+
13
+ def initialize(repo:)
14
+ @repo = repo
15
+ end
16
+
17
+ def load
18
+ return {} unless File.exist?(@repo.config_path)
19
+
20
+ deep_stringify(YAML.safe_load(File.read(@repo.config_path), aliases: true) || {})
21
+ end
22
+
23
+ def config_for(definition)
24
+ base = DefaultsLoader.config_for(definition.hook_section, definition.config_name) || definition.default_config
25
+ data = load
26
+ section = data.fetch(definition.hook_section, {})
27
+ merged = deep_merge(base, section.fetch('ALL', {}))
28
+ deep_merge(merged, section.fetch(definition.config_name, {}))
29
+ end
30
+
31
+ def effective_config(registry)
32
+ registry.group_by(&:hook_section).transform_values do |definitions|
33
+ definitions.to_h { |definition| [definition.config_name, config_for(definition)] }
34
+ end
35
+ end
36
+
37
+ def set_option(definition, option, value)
38
+ data = load
39
+ section = data[definition.hook_section] ||= {}
40
+ section[definition.config_name] ||= {}
41
+
42
+ normalized = normalize_value(option, value)
43
+ base = DefaultsLoader.config_for(definition.hook_section, definition.config_name) || definition.default_config
44
+ default_value = base[option]
45
+
46
+ if normalized == default_value
47
+ section[definition.config_name].delete(option)
48
+ else
49
+ section[definition.config_name][option] = normalized
50
+ end
51
+
52
+ cleanup_empty_nodes!(data, definition)
53
+ write(data)
54
+ end
55
+
56
+ def init
57
+ return if File.exist?(@repo.config_path)
58
+
59
+ File.write(@repo.config_path, <<~YAML)
60
+ # rails_git_hooks overrides
61
+ #
62
+ # Example:
63
+ # PreCommit:
64
+ # RuboCop:
65
+ # enabled: true
66
+ # on_fail: fail
67
+ YAML
68
+ end
69
+
70
+ private
71
+
72
+ def write(data)
73
+ if data.empty?
74
+ FileUtils.rm_f(@repo.config_path)
75
+ else
76
+ File.write(@repo.config_path, YAML.dump(data))
77
+ end
78
+ end
79
+
80
+ def cleanup_empty_nodes!(data, definition)
81
+ section = data.fetch(definition.hook_section, {})
82
+ section.delete(definition.config_name) if section.fetch(definition.config_name, {}).empty?
83
+ data.delete(definition.hook_section) if section.empty?
84
+ end
85
+
86
+ def normalize_value(option, value)
87
+ case option
88
+ when *BOOLEAN_OPTIONS
89
+ parse_boolean(value)
90
+ when *POLICY_OPTIONS
91
+ value.to_s
92
+ else
93
+ value
94
+ end
95
+ end
96
+
97
+ def parse_boolean(value)
98
+ return value if [true, false].include?(value)
99
+
100
+ case value.to_s
101
+ when 'true', 'yes', 'on', '1' then true
102
+ when 'false', 'no', 'off', '0' then false
103
+ else
104
+ raise GitHooks::Error, "Invalid boolean value: #{value.inspect}"
105
+ end
106
+ end
107
+
108
+ def deep_merge(base, override)
109
+ base.merge(override) do |_key, old, new|
110
+ old.is_a?(Hash) && new.is_a?(Hash) ? deep_merge(old, new) : new
111
+ end
112
+ end
113
+
114
+ def deep_stringify(value)
115
+ case value
116
+ when Hash
117
+ value.each_with_object({}) { |(key, nested), out| out[key.to_s] = deep_stringify(nested) }
118
+ when Array
119
+ value.map { |nested| deep_stringify(nested) }
120
+ else
121
+ value
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ class PolicyResolver
5
+ VALID_FAIL_POLICIES = %w[fail warn pass].freeze
6
+ VALID_WARN_POLICIES = %w[warn fail pass].freeze
7
+
8
+ def resolve(result, config)
9
+ policy = policy_for(result, config)
10
+ return result if policy == result.status.to_s
11
+
12
+ result.with_status(policy.to_sym)
13
+ end
14
+
15
+ private
16
+
17
+ def policy_for(result, config)
18
+ case result.reason
19
+ when :missing_dependency
20
+ validate(config.fetch('on_missing_dependency', 'warn'), VALID_FAIL_POLICIES)
21
+ else
22
+ case result.status
23
+ when :fail then validate(config.fetch('on_fail', 'fail'), VALID_FAIL_POLICIES)
24
+ when :warn then validate(config.fetch('on_warn', 'warn'), VALID_WARN_POLICIES)
25
+ else 'pass'
26
+ end
27
+ end
28
+ end
29
+
30
+ def validate(value, valid_values)
31
+ return value if valid_values.include?(value)
32
+
33
+ raise GitHooks::Error, "Invalid policy value: #{value.inspect}"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module GitHooks
6
+ class Repository
7
+ attr_reader :root, :git_dir
8
+
9
+ def initialize(start_dir = Dir.pwd)
10
+ @root, @git_dir = resolve_paths(start_dir)
11
+ end
12
+
13
+ def config_path
14
+ File.join(root, Constants::CONFIG_FILE)
15
+ end
16
+
17
+ def hook_runtime_dir(hooks_dir)
18
+ File.join(hooks_dir, Constants::RUNTIME_DIR_NAME)
19
+ end
20
+
21
+ def git(*args)
22
+ stdout, status = Open3.capture2e('git', *args, chdir: root)
23
+ [stdout, status]
24
+ end
25
+
26
+ def git_output(*args)
27
+ stdout, status = git(*args)
28
+ raise GitHooks::Error, stdout.strip unless status.success?
29
+
30
+ stdout
31
+ end
32
+
33
+ def current_branch
34
+ git_output('rev-parse', '--abbrev-ref', 'HEAD').strip
35
+ end
36
+
37
+ def staged_files
38
+ git_output('diff', '--cached', '--name-only').split("\n").map(&:strip).reject(&:empty?)
39
+ end
40
+
41
+ private
42
+
43
+ def resolve_paths(start_dir)
44
+ dir = File.expand_path(start_dir)
45
+ loop do
46
+ git_entry = File.join(dir, '.git')
47
+ if File.directory?(git_entry)
48
+ return [dir, git_entry]
49
+ elsif File.file?(git_entry)
50
+ git_dir = File.expand_path(File.read(git_entry).strip.sub(/\Agitdir: \s*/, ''), dir)
51
+ return [dir, git_dir]
52
+ end
53
+
54
+ parent = File.dirname(dir)
55
+ raise GitHooks::Error, 'Not inside a git repository' if parent == dir
56
+
57
+ dir = parent
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitHooks
4
+ class Runner
5
+ def initialize(repo:, hook_name:, argv:, stdin:)
6
+ @repo = repo
7
+ @hook_name = hook_name.to_sym
8
+ @argv = argv
9
+ @stdin = stdin
10
+ @overrides = OverrideConfig.new(repo: repo)
11
+ @dependencies = DependencyChecker.new(repo: repo)
12
+ @policy = PolicyResolver.new
13
+ end
14
+
15
+ def run
16
+ failed = false
17
+
18
+ CheckRegistry.for(@hook_name).each do |definition|
19
+ config = @overrides.config_for(definition)
20
+ next unless config['enabled']
21
+
22
+ context = {
23
+ repo: @repo,
24
+ argv: @argv,
25
+ stdin: @stdin,
26
+ applicable_files: applicable_files_for(config)
27
+ }
28
+
29
+ raw_result = @dependencies.check(config)
30
+ raw_result = definition.klass.new(config: config, context: context).run if raw_result.pass?
31
+ final_result = @policy.resolve(raw_result, config)
32
+
33
+ print_result(definition, final_result, quiet: config['quiet'])
34
+ failed ||= final_result.fail?
35
+ end
36
+
37
+ failed ? 1 : 0
38
+ end
39
+
40
+ private
41
+
42
+ def applicable_files_for(config)
43
+ return [] unless config['file_based']
44
+
45
+ FileMatcher.filter(
46
+ modified_files,
47
+ include_patterns: Array(config['include']),
48
+ exclude_patterns: Array(config['exclude'])
49
+ )
50
+ end
51
+
52
+ def modified_files
53
+ @modified_files ||= case @hook_name
54
+ when :pre_commit then @repo.staged_files
55
+ else []
56
+ end
57
+ end
58
+
59
+ def print_result(definition, result, quiet:)
60
+ return if result.pass? && quiet
61
+ return if result.pass? && result.messages.empty?
62
+
63
+ case result.status
64
+ when :warn
65
+ warn ''
66
+ warn "Warning (#{definition.config_name}):"
67
+ when :fail
68
+ warn ''
69
+ warn "Commit rejected (#{definition.config_name}):"
70
+ end
71
+
72
+ result.messages.each { |message| warn " #{message}" } unless result.pass?
73
+ warn '' unless result.pass?
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'config/constants'
4
+ require_relative 'core/error'
5
+ require_relative 'core/check_result'
6
+ require_relative 'core/check_definition'
7
+ require_relative 'runtime/repository'
8
+ require_relative 'runtime/file_matcher'
9
+ require_relative 'runtime/dependency_checker'
10
+ require_relative 'runtime/policy_resolver'
11
+ require_relative 'runtime/override_config'
12
+ require_relative 'checks'
13
+ require_relative 'runtime/check_registry'
14
+ require_relative 'runtime/runner'
15
+
16
+ module GitHooks
17
+ module Runtime
18
+ module_function
19
+
20
+ def execute(hook_name, argv: [], stdin: '')
21
+ repo = Repository.new
22
+ Runner.new(repo: repo, hook_name: hook_name, argv: argv, stdin: stdin).run
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitHooks
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.1'
5
5
  end
@@ -1,9 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'rails_git_hooks/version'
4
- require_relative 'rails_git_hooks/constants'
5
- require_relative 'rails_git_hooks/installer'
6
-
7
- module GitHooks
8
- class Error < StandardError; end
9
- end
4
+ require_relative 'rails_git_hooks/core/error'
5
+ require_relative 'rails_git_hooks/config/constants'
6
+ require_relative 'rails_git_hooks/core/check_result'
7
+ require_relative 'rails_git_hooks/core/check_definition'
8
+ require_relative 'rails_git_hooks/runtime/repository'
9
+ require_relative 'rails_git_hooks/runtime/file_matcher'
10
+ require_relative 'rails_git_hooks/runtime/dependency_checker'
11
+ require_relative 'rails_git_hooks/runtime/policy_resolver'
12
+ require_relative 'rails_git_hooks/runtime/override_config'
13
+ require_relative 'rails_git_hooks/checks'
14
+ require_relative 'rails_git_hooks/runtime/check_registry'
15
+ require_relative 'rails_git_hooks/runtime/runner'
16
+ require_relative 'rails_git_hooks/install/installer'
17
+ require_relative 'rails_git_hooks/runtime'
@@ -1,23 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- #
5
- # Git commit-msg hook: prepends [TICKET] when branch contains a Jira-style ticket.
6
- # Logic in templates/shared/commit_msg/.
7
-
8
- # Bootstrap: resolve .git dir and skip if hook is disabled
9
- repo_root = Dir.pwd
10
- git_dir = File.join(repo_root, '.git')
11
- git_dir = File.expand_path(File.read(git_dir).strip.sub(/\Agitdir: \s*/, ''), repo_root) if File.file?(git_dir)
12
- disabled_file = File.join(git_dir, 'rails_git_hooks_disabled')
13
- if File.exist?(disabled_file)
14
- disabled = File.read(disabled_file).split("\n").map(&:strip)
15
- exit 0 if disabled.include?('*') || disabled.include?('commit-msg')
4
+ hooks_dir = File.dirname(File.expand_path(__FILE__))
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError, StandardError
8
+ nil
16
9
  end
17
10
 
18
- module RailsGitHooks
19
- end
20
- RailsGitHooks.const_set(:GIT_DIR, git_dir.freeze)
21
- hooks_dir = File.dirname(File.expand_path(__FILE__))
11
+ require File.join(hooks_dir, 'rails_git_hooks', 'runtime')
22
12
 
23
- load File.join(hooks_dir, 'commit_msg', 'jira_prefix.rb')
13
+ exit GitHooks::Runtime.execute(:commit_msg, argv: ARGV, stdin: $stdin.read)
@@ -1,27 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- #
5
- # Blocks commits on default branch (master/main). Warns on debugger statements (Ruby/JS/TS/Python).
6
- # Optionally runs RuboCop and whitespace/conflict checks.
7
- # Logic is in templates/shared/pre_commit/ for easier maintenance and adding new checks.
8
-
9
- # Bootstrap: resolve .git dir and skip if hook is disabled
10
- repo_root = Dir.pwd
11
- git_dir = File.join(repo_root, '.git')
12
- git_dir = File.expand_path(File.read(git_dir).strip.sub(/\Agitdir: \s*/, ''), repo_root) if File.file?(git_dir)
13
- disabled_file = File.join(git_dir, 'rails_git_hooks_disabled')
14
- if File.exist?(disabled_file)
15
- disabled = File.read(disabled_file).split("\n").map(&:strip)
16
- exit 0 if disabled.include?('*') || disabled.include?('pre-commit')
4
+ hooks_dir = File.dirname(File.expand_path(__FILE__))
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError, StandardError
8
+ nil
17
9
  end
18
10
 
19
- module RailsGitHooks
20
- end
21
- RailsGitHooks.const_set(:GIT_DIR, git_dir.freeze)
22
- hooks_dir = File.dirname(File.expand_path(__FILE__))
11
+ require File.join(hooks_dir, 'rails_git_hooks', 'runtime')
23
12
 
24
- load File.join(hooks_dir, 'pre_commit', 'whitespace_check.rb')
25
- load File.join(hooks_dir, 'pre_commit', 'default_branch.rb')
26
- load File.join(hooks_dir, 'pre_commit', 'debugger_check.rb')
27
- load File.join(hooks_dir, 'pre_commit', 'rubocop_check.rb')
13
+ exit GitHooks::Runtime.execute(:pre_commit, argv: ARGV, stdin: $stdin.read)
@@ -1,23 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- #
5
- # Runs the full test suite before push. Push is aborted if tests fail.
6
- # Logic in templates/shared/pre_push/.
7
-
8
- # Bootstrap: resolve .git dir and skip if hook is disabled
9
- repo_root = Dir.pwd
10
- git_dir = File.join(repo_root, '.git')
11
- git_dir = File.expand_path(File.read(git_dir).strip.sub(/\Agitdir: \s*/, ''), repo_root) if File.file?(git_dir)
12
- disabled_file = File.join(git_dir, 'rails_git_hooks_disabled')
13
- if File.exist?(disabled_file)
14
- disabled = File.read(disabled_file).split("\n").map(&:strip)
15
- exit 0 if disabled.include?('*') || disabled.include?('pre-push')
4
+ hooks_dir = File.dirname(File.expand_path(__FILE__))
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError, StandardError
8
+ nil
16
9
  end
17
10
 
18
- module RailsGitHooks
19
- end
20
- RailsGitHooks.const_set(:GIT_DIR, git_dir.freeze)
21
- hooks_dir = File.dirname(File.expand_path(__FILE__))
11
+ require File.join(hooks_dir, 'rails_git_hooks', 'runtime')
22
12
 
23
- load File.join(hooks_dir, 'pre_push', 'run_tests.rb')
13
+ exit GitHooks::Runtime.execute(:pre_push, argv: ARGV, stdin: $stdin.read)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_git_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Nazarov
@@ -64,19 +64,40 @@ files:
64
64
  - README.md
65
65
  - bin/rails_git_hooks
66
66
  - lib/rails_git_hooks.rb
67
+ - lib/rails_git_hooks/checks.rb
68
+ - lib/rails_git_hooks/checks/base.rb
69
+ - lib/rails_git_hooks/checks/commit_msg.rb
70
+ - lib/rails_git_hooks/checks/commit_msg/jira_prefix.rb
71
+ - lib/rails_git_hooks/checks/pre_commit.rb
72
+ - lib/rails_git_hooks/checks/pre_commit/debugger_check.rb
73
+ - lib/rails_git_hooks/checks/pre_commit/default_branch.rb
74
+ - lib/rails_git_hooks/checks/pre_commit/json_format_check.rb
75
+ - lib/rails_git_hooks/checks/pre_commit/migrations_check.rb
76
+ - lib/rails_git_hooks/checks/pre_commit/rubocop.rb
77
+ - lib/rails_git_hooks/checks/pre_commit/whitespace_check.rb
78
+ - lib/rails_git_hooks/checks/pre_commit/yaml_format_check.rb
79
+ - lib/rails_git_hooks/checks/pre_push.rb
80
+ - lib/rails_git_hooks/checks/pre_push/run_tests.rb
67
81
  - lib/rails_git_hooks/cli.rb
68
- - lib/rails_git_hooks/constants.rb
69
- - lib/rails_git_hooks/installer.rb
82
+ - lib/rails_git_hooks/config/constants.rb
83
+ - lib/rails_git_hooks/config/defaults.yml
84
+ - lib/rails_git_hooks/config/defaults_loader.rb
85
+ - lib/rails_git_hooks/core/check_definition.rb
86
+ - lib/rails_git_hooks/core/check_result.rb
87
+ - lib/rails_git_hooks/core/error.rb
88
+ - lib/rails_git_hooks/install/installer.rb
89
+ - lib/rails_git_hooks/runtime.rb
90
+ - lib/rails_git_hooks/runtime/check_registry.rb
91
+ - lib/rails_git_hooks/runtime/dependency_checker.rb
92
+ - lib/rails_git_hooks/runtime/file_matcher.rb
93
+ - lib/rails_git_hooks/runtime/override_config.rb
94
+ - lib/rails_git_hooks/runtime/policy_resolver.rb
95
+ - lib/rails_git_hooks/runtime/repository.rb
96
+ - lib/rails_git_hooks/runtime/runner.rb
70
97
  - lib/rails_git_hooks/version.rb
71
98
  - templates/hooks/commit-msg
72
99
  - templates/hooks/pre-commit
73
100
  - templates/hooks/pre-push
74
- - templates/shared/commit_msg/jira_prefix.rb
75
- - templates/shared/pre_commit/debugger_check.rb
76
- - templates/shared/pre_commit/default_branch.rb
77
- - templates/shared/pre_commit/rubocop_check.rb
78
- - templates/shared/pre_commit/whitespace_check.rb
79
- - templates/shared/pre_push/run_tests.rb
80
101
  homepage: https://github.com/NikitaNazarov1/rails_git_hooks
81
102
  licenses:
82
103
  - MIT
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GitHooks
4
- # Paths and default config (single source of truth).
5
- module Constants
6
- GEM_ROOT = File.expand_path('../..', __dir__)
7
- HOOKS_DIR = File.expand_path('templates/hooks', GEM_ROOT).freeze
8
- SHARED_DIR = File.expand_path('templates/shared', GEM_ROOT).freeze
9
-
10
- DISABLED_FILE = 'rails_git_hooks_disabled'
11
-
12
- # Default hooks when install is run with no arguments.
13
- DEFAULT_HOOKS = %w[commit-msg pre-commit].freeze
14
-
15
- # Pre-commit feature flag file names (keys = CLI tokens).
16
- FEATURE_FLAG_FILES = {
17
- 'whitespace-check' => 'rails_git_hooks_whitespace_check',
18
- 'rubocop-check' => 'rails_git_hooks_rubocop'
19
- }.freeze
20
- end
21
- end