code_quality_check 0.1.5 → 0.1.6
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7ae4cff95b35c9f984ce1578f97675f6febe7ca1b9c1d37f9c46ece5164c90
|
4
|
+
data.tar.gz: b823b189b8dc85ed5296162efd4fb3fdcf8bbd6e92a075aa41393b6dc56c5043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b50c71709df027071bfc5f727d698cece3179a471963169c16ebe27895538b972e76e0f16d20e10e8ca3b12f2cd810d0610fbd4a18836d4cfde17f73e0971d
|
7
|
+
data.tar.gz: b712522bc8f6d26643d1504ff130547557b7f67cf38d6dfea60d8d3179d12b726bc6bdfd2d87da4b3d019224d36c133ab58f2f6aee21c979e9710b354501d7e6
|
@@ -9,6 +9,11 @@ module CodeQualityCheck
|
|
9
9
|
source_root File.expand_path('templates', __dir__)
|
10
10
|
desc 'This generator creates an initializer file for Overcommit'
|
11
11
|
|
12
|
+
def install_overcommit
|
13
|
+
# Install Overcommit
|
14
|
+
run 'bundle exec overcommit --install'
|
15
|
+
end
|
16
|
+
|
12
17
|
# Define a method that copies the initializer file to the config/initializers directory
|
13
18
|
def copy_required_files
|
14
19
|
# Copy the initializer file to the config/initializers directory
|
@@ -19,6 +24,10 @@ module CodeQualityCheck
|
|
19
24
|
|
20
25
|
# Copy the RuboCop configuration file to the root directory
|
21
26
|
template 'rubocop.yml', '.rubocop.yml'
|
27
|
+
|
28
|
+
# Copy the pre-commit hook to the .git/hooks directory
|
29
|
+
template 'pre-commit', '.git/hooks/pre-commit', force: true
|
30
|
+
template 'post-checkout', '.git/hooks/post-checkout', force: true
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
5
|
+
# in all of your git hooks being copied from this file, allowing the framework
|
6
|
+
# to manage your hooks for you.
|
7
|
+
|
8
|
+
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
9
|
+
# Note that this will be overridden when Overcommit is loaded, since the
|
10
|
+
# InterruptHandler will redefine the trap at that time.
|
11
|
+
Signal.trap('INT') do
|
12
|
+
puts 'Hook run interrupted'
|
13
|
+
exit 130
|
14
|
+
end
|
15
|
+
|
16
|
+
# Allow hooks to be disabled via environment variable so git commands can be run
|
17
|
+
# in scripts without Overcommit running hooks
|
18
|
+
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
hook_type = File.basename($0)
|
23
|
+
if hook_type == 'overcommit-hook'
|
24
|
+
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
25
|
+
"by each hook in a repository's .git/hooks directory."
|
26
|
+
exit 64 # EX_USAGE
|
27
|
+
end
|
28
|
+
|
29
|
+
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
+
require 'yaml'
|
31
|
+
# rubocop:disable Style/RescueModifier
|
32
|
+
gemfile =
|
33
|
+
begin
|
34
|
+
YAML.load_file('.overcommit.yml', aliases: true)['gemfile']
|
35
|
+
rescue ArgumentError
|
36
|
+
YAML.load_file('.overcommit.yml')['gemfile']
|
37
|
+
end rescue nil
|
38
|
+
|
39
|
+
if gemfile
|
40
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
41
|
+
require 'bundler'
|
42
|
+
|
43
|
+
begin
|
44
|
+
Bundler.setup
|
45
|
+
rescue Bundler::BundlerError => e
|
46
|
+
puts "Problem loading '#{gemfile}': #{e.message}"
|
47
|
+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if e.is_a?(Bundler::GemNotFound)
|
48
|
+
exit 78 # EX_CONFIG
|
49
|
+
end
|
50
|
+
end
|
51
|
+
# rubocop:enable Style/RescueModifier
|
52
|
+
|
53
|
+
begin
|
54
|
+
require 'overcommit'
|
55
|
+
puts 'Signing Overcommit hooks...'
|
56
|
+
exec('overcommit --sign')
|
57
|
+
rescue LoadError
|
58
|
+
if gemfile
|
59
|
+
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
60
|
+
'configuration but have not added the `overcommit` gem to ' \
|
61
|
+
"#{gemfile}."
|
62
|
+
else
|
63
|
+
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
64
|
+
"`overcommit` gem is not installed.\n" \
|
65
|
+
'Install it with `gem install overcommit`.'
|
66
|
+
end
|
67
|
+
|
68
|
+
exit 64 # EX_USAGE
|
69
|
+
end
|
70
|
+
|
71
|
+
begin
|
72
|
+
logger = Overcommit::Logger.new(STDOUT)
|
73
|
+
Overcommit::Utils.log = logger
|
74
|
+
|
75
|
+
# Ensure master hook is up-to-date
|
76
|
+
installer = Overcommit::Installer.new(logger)
|
77
|
+
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
78
|
+
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
79
|
+
end
|
80
|
+
|
81
|
+
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
82
|
+
|
83
|
+
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
84
|
+
config.apply_environment!(context, ENV)
|
85
|
+
|
86
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
87
|
+
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
88
|
+
|
89
|
+
status = runner.run
|
90
|
+
|
91
|
+
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
92
|
+
rescue Overcommit::Exceptions::ConfigurationError => e
|
93
|
+
puts e
|
94
|
+
exit 78 # EX_CONFIG
|
95
|
+
rescue Overcommit::Exceptions::HookContextLoadError => e
|
96
|
+
puts e
|
97
|
+
puts 'Are you running an old version of Overcommit?'
|
98
|
+
exit 69 # EX_UNAVAILABLE
|
99
|
+
rescue Overcommit::Exceptions::HookLoadError,
|
100
|
+
Overcommit::Exceptions::InvalidHookDefinition => e
|
101
|
+
puts e.message
|
102
|
+
puts e.backtrace
|
103
|
+
exit 78 # EX_CONFIG
|
104
|
+
rescue Overcommit::Exceptions::HookSetupFailed,
|
105
|
+
Overcommit::Exceptions::HookCleanupFailed => e
|
106
|
+
puts e.message
|
107
|
+
exit 74 # EX_IOERR
|
108
|
+
rescue Overcommit::Exceptions::HookCancelled
|
109
|
+
puts 'You cancelled the hook run'
|
110
|
+
exit 130 # Ctrl-C cancel
|
111
|
+
rescue Overcommit::Exceptions::InvalidGitRepo => e
|
112
|
+
puts e
|
113
|
+
exit 64 # EX_USAGE
|
114
|
+
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => e
|
115
|
+
puts e
|
116
|
+
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
117
|
+
exit 1
|
118
|
+
rescue Overcommit::Exceptions::InvalidHookSignature
|
119
|
+
exit 1
|
120
|
+
rescue StandardError => e
|
121
|
+
puts e.message
|
122
|
+
puts e.backtrace
|
123
|
+
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
124
|
+
exit 70 # EX_SOFTWARE
|
125
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
5
|
+
# in all of your git hooks being copied from this file, allowing the framework
|
6
|
+
# to manage your hooks for you.
|
7
|
+
|
8
|
+
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
9
|
+
# Note that this will be overridden when Overcommit is loaded, since the
|
10
|
+
# InterruptHandler will redefine the trap at that time.
|
11
|
+
Signal.trap('INT') do
|
12
|
+
puts 'Hook run interrupted'
|
13
|
+
exit 130
|
14
|
+
end
|
15
|
+
|
16
|
+
# Allow hooks to be disabled via environment variable so git commands can be run
|
17
|
+
# in scripts without Overcommit running hooks
|
18
|
+
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
hook_type = File.basename($0)
|
23
|
+
if hook_type == 'overcommit-hook'
|
24
|
+
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
25
|
+
"by each hook in a repository's .git/hooks directory."
|
26
|
+
exit 64 # EX_USAGE
|
27
|
+
end
|
28
|
+
|
29
|
+
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
+
require 'yaml'
|
31
|
+
# rubocop:disable Style/RescueModifier
|
32
|
+
gemfile =
|
33
|
+
begin
|
34
|
+
YAML.load_file('.overcommit.yml', aliases: true)['gemfile']
|
35
|
+
rescue ArgumentError
|
36
|
+
YAML.load_file('.overcommit.yml')['gemfile']
|
37
|
+
end rescue nil
|
38
|
+
|
39
|
+
if gemfile
|
40
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
41
|
+
require 'bundler'
|
42
|
+
|
43
|
+
begin
|
44
|
+
Bundler.setup
|
45
|
+
rescue Bundler::BundlerError => e
|
46
|
+
puts "Problem loading '#{gemfile}': #{e.message}"
|
47
|
+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if e.is_a?(Bundler::GemNotFound)
|
48
|
+
exit 78 # EX_CONFIG
|
49
|
+
end
|
50
|
+
end
|
51
|
+
# rubocop:enable Style/RescueModifier
|
52
|
+
|
53
|
+
begin
|
54
|
+
require 'overcommit'
|
55
|
+
puts 'Signing Overcommit hooks...'
|
56
|
+
exec('overcommit --sign')
|
57
|
+
rescue LoadError
|
58
|
+
if gemfile
|
59
|
+
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
60
|
+
'configuration but have not added the `overcommit` gem to ' \
|
61
|
+
"#{gemfile}."
|
62
|
+
else
|
63
|
+
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
64
|
+
"`overcommit` gem is not installed.\n" \
|
65
|
+
'Install it with `gem install overcommit`.'
|
66
|
+
end
|
67
|
+
|
68
|
+
exit 64 # EX_USAGE
|
69
|
+
end
|
70
|
+
|
71
|
+
begin
|
72
|
+
logger = Overcommit::Logger.new(STDOUT)
|
73
|
+
Overcommit::Utils.log = logger
|
74
|
+
|
75
|
+
# Ensure master hook is up-to-date
|
76
|
+
installer = Overcommit::Installer.new(logger)
|
77
|
+
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
78
|
+
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
79
|
+
end
|
80
|
+
|
81
|
+
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
82
|
+
|
83
|
+
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
84
|
+
config.apply_environment!(context, ENV)
|
85
|
+
|
86
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
87
|
+
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
88
|
+
|
89
|
+
status = runner.run
|
90
|
+
|
91
|
+
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
92
|
+
rescue Overcommit::Exceptions::ConfigurationError => e
|
93
|
+
puts e
|
94
|
+
exit 78 # EX_CONFIG
|
95
|
+
rescue Overcommit::Exceptions::HookContextLoadError => e
|
96
|
+
puts e
|
97
|
+
puts 'Are you running an old version of Overcommit?'
|
98
|
+
exit 69 # EX_UNAVAILABLE
|
99
|
+
rescue Overcommit::Exceptions::HookLoadError,
|
100
|
+
Overcommit::Exceptions::InvalidHookDefinition => e
|
101
|
+
puts e.message
|
102
|
+
puts e.backtrace
|
103
|
+
exit 78 # EX_CONFIG
|
104
|
+
rescue Overcommit::Exceptions::HookSetupFailed,
|
105
|
+
Overcommit::Exceptions::HookCleanupFailed => e
|
106
|
+
puts e.message
|
107
|
+
exit 74 # EX_IOERR
|
108
|
+
rescue Overcommit::Exceptions::HookCancelled
|
109
|
+
puts 'You cancelled the hook run'
|
110
|
+
exit 130 # Ctrl-C cancel
|
111
|
+
rescue Overcommit::Exceptions::InvalidGitRepo => e
|
112
|
+
puts e
|
113
|
+
exit 64 # EX_USAGE
|
114
|
+
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => e
|
115
|
+
puts e
|
116
|
+
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
117
|
+
exit 1
|
118
|
+
rescue Overcommit::Exceptions::InvalidHookSignature
|
119
|
+
exit 1
|
120
|
+
rescue StandardError => e
|
121
|
+
puts e.message
|
122
|
+
puts e.backtrace
|
123
|
+
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
124
|
+
exit 70 # EX_SOFTWARE
|
125
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_quality_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aniruddha Mirajkar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brakeman
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- lib/generators/code_quality_check/install_generator.rb
|
86
86
|
- lib/generators/code_quality_check/templates/overcommit.rb
|
87
87
|
- lib/generators/code_quality_check/templates/overcommit.yml
|
88
|
+
- lib/generators/code_quality_check/templates/post-checkout
|
89
|
+
- lib/generators/code_quality_check/templates/pre-commit
|
88
90
|
- lib/generators/code_quality_check/templates/rubocop.yml
|
89
91
|
- lib/generators/code_quality_check/uninstall_generator.rb
|
90
92
|
homepage: https://github.com/aniruddhami/code_quality_check
|
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
113
|
- !ruby/object:Gem::Version
|
112
114
|
version: '0'
|
113
115
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.4.19
|
115
117
|
signing_key:
|
116
118
|
specification_version: 4
|
117
119
|
summary: A gem to enforce code quality checks using Git hooks
|