rabbitt-githooks 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Gemfile.lock +29 -19
- data/Rakefile +20 -0
- data/bin/githooks +2 -1
- data/bin/githooks-runner +10 -2
- data/lib/githooks.rb +11 -7
- data/lib/githooks/action.rb +67 -53
- data/lib/githooks/cli.rb +9 -6
- data/lib/githooks/commands/config.rb +26 -19
- data/lib/githooks/core_ext.rb +2 -1
- data/lib/githooks/core_ext/array/extract_options.rb +5 -1
- data/lib/githooks/core_ext/array/min_max.rb +4 -4
- data/lib/githooks/core_ext/array/select_with_index.rb +1 -1
- data/lib/githooks/core_ext/colorize.rb +30 -0
- data/lib/githooks/core_ext/object.rb +8 -0
- data/lib/githooks/core_ext/pathname.rb +7 -6
- data/lib/githooks/core_ext/string.rb +1 -1
- data/lib/githooks/core_ext/string/sanitize.rb +51 -0
- data/lib/githooks/error.rb +1 -0
- data/lib/githooks/hook.rb +21 -26
- data/lib/githooks/repository.rb +31 -35
- data/lib/githooks/repository/config.rb +16 -24
- data/lib/githooks/repository/diff_index_entry.rb +3 -2
- data/lib/githooks/repository/file.rb +14 -7
- data/lib/githooks/runner.rb +38 -36
- data/lib/githooks/section.rb +13 -19
- data/lib/githooks/system_utils.rb +132 -47
- data/lib/githooks/version.rb +1 -1
- data/lib/tasks/dev.task +14 -0
- data/rabbitt-githooks.gemspec +18 -15
- metadata +58 -33
- data/.gitignore +0 -34
- data/.hooks/commit-messages.rb +0 -29
- data/.hooks/formatting.rb +0 -44
- data/.rubocop.yml +0 -87
- data/lib/githooks/core_ext/process.rb +0 -9
- data/lib/githooks/core_ext/string/strip_empty_lines.rb +0 -9
- data/lib/githooks/terminal_colors.rb +0 -62
- data/thoughts.txt +0 -56
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZDQ3ZGMwYTI1MGY3NDc3ZmM2NTk0NGJkMjg1NjBlYWU5NTgyN2MwOQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8a2ed779870b84aa9cc8d2a61a1cec2b9ce00bb
|
4
|
+
data.tar.gz: 74d1c181b0fb1f3ead9de7fba24cf55485d5e5fc
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZWVkOGNmOTJhZmNhZGI1NjQ2ZDYxMTNiYzU5ZTA0MTFhMTUwODhkMmQ4MWZk
|
11
|
-
NzExZTY3MDQyNzAxMzNhMzA4MzU2YTdmOGE5YmUwOWQ1Y2E5YTI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDZiMTMyZDllMDZjZmE3Yjg2ZTcyODJiMWJkNDAzYjAxNDRjYjViYWY2ZjBm
|
14
|
-
YWRkNmY5MTc2ZGEyMGRlNDRiZmRiMjAzOGMyOGE0MTk5NDFhMmFlNDliODdj
|
15
|
-
N2I0MzI4NDY5MTkxNGFmMDhiMWIzZDFmMDA5MWE5NWVlYmFiY2I=
|
6
|
+
metadata.gz: 8b5aa0a35e390045e234980f8a132eb4cbf112444df25811e1d7becb50f3a79e85c25810445585743a2a79dcb324c1a50cee34c4202ccd8976fe0f4760b8e759
|
7
|
+
data.tar.gz: 3408b935632cb28b2c1ff13f6aacd2b83fdc407b4b3acc881ae29ed76f7d0e6b60ce8edd187fe95fc8b0b53d91b64085066451425d9a554ab0ea2b266b01959a
|
data/Gemfile.lock
CHANGED
@@ -1,43 +1,51 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rabbitt-githooks (1.3.
|
5
|
-
colorize (~> 0.
|
4
|
+
rabbitt-githooks (1.3.2)
|
5
|
+
colorize (~> 0.7.0)
|
6
6
|
thor (~> 0.18)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ast (2.0.0)
|
12
|
-
|
12
|
+
astrolabe (1.3.0)
|
13
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
14
|
+
colorize (0.7.5)
|
13
15
|
diff-lcs (1.2.5)
|
14
|
-
|
15
|
-
|
16
|
+
docile (1.1.5)
|
17
|
+
multi_json (1.10.1)
|
18
|
+
parser (2.2.0.2)
|
16
19
|
ast (>= 1.1, < 3.0)
|
17
|
-
|
18
|
-
powerpack (0.0.9)
|
20
|
+
powerpack (0.1.0)
|
19
21
|
rainbow (2.0.0)
|
20
|
-
rake (10.
|
22
|
+
rake (10.4.2)
|
21
23
|
rspec (2.99.0)
|
22
24
|
rspec-core (~> 2.99.0)
|
23
25
|
rspec-expectations (~> 2.99.0)
|
24
26
|
rspec-mocks (~> 2.99.0)
|
25
|
-
rspec-core (2.99.
|
26
|
-
rspec-expectations (2.99.
|
27
|
+
rspec-core (2.99.2)
|
28
|
+
rspec-expectations (2.99.2)
|
27
29
|
diff-lcs (>= 1.1.3, < 2.0)
|
28
|
-
rspec-mocks (2.99.
|
29
|
-
rubocop (0.
|
30
|
-
|
31
|
-
parser (
|
32
|
-
powerpack (~> 0.
|
30
|
+
rspec-mocks (2.99.3)
|
31
|
+
rubocop (0.29.0)
|
32
|
+
astrolabe (~> 1.3)
|
33
|
+
parser (>= 2.2.0.1, < 3.0)
|
34
|
+
powerpack (~> 0.1)
|
33
35
|
rainbow (>= 1.99.1, < 3.0)
|
34
36
|
ruby-progressbar (~> 1.4)
|
35
|
-
ruby-lint (2.0.
|
37
|
+
ruby-lint (2.0.3)
|
36
38
|
parser (~> 2.1, >= 2.1.1)
|
37
39
|
slop (~> 3.4, >= 3.4.7)
|
38
|
-
ruby-progressbar (1.
|
39
|
-
|
40
|
+
ruby-progressbar (1.7.1)
|
41
|
+
simplecov (0.9.1)
|
42
|
+
docile (~> 1.1.0)
|
43
|
+
multi_json (~> 1.0)
|
44
|
+
simplecov-html (~> 0.8.0)
|
45
|
+
simplecov-html (0.8.0)
|
46
|
+
slop (3.6.0)
|
40
47
|
thor (0.19.1)
|
48
|
+
yard (0.8.7.6)
|
41
49
|
|
42
50
|
PLATFORMS
|
43
51
|
ruby
|
@@ -48,4 +56,6 @@ DEPENDENCIES
|
|
48
56
|
rake (~> 10.1)
|
49
57
|
rspec (~> 2.14)
|
50
58
|
rubocop (~> 0.18)
|
51
|
-
ruby-lint (~> 2.0
|
59
|
+
ruby-lint (~> 2.0)
|
60
|
+
simplecov (~> 0.9)
|
61
|
+
yard (~> 0.7)
|
data/Rakefile
CHANGED
@@ -17,3 +17,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
17
|
=end
|
18
18
|
|
19
19
|
require 'bundler/gem_tasks'
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Code coverage detail'
|
29
|
+
task :simplecov do
|
30
|
+
ENV['COVERAGE'] = 'true'
|
31
|
+
Rake::Task['test'].execute
|
32
|
+
end
|
33
|
+
|
34
|
+
task default: :test
|
35
|
+
|
36
|
+
require 'yard'
|
37
|
+
YARD::Rake::YardocTask.new
|
38
|
+
|
39
|
+
Dir['lib/tasks/*.task'].each { |t| load t }
|
data/bin/githooks
CHANGED
data/bin/githooks-runner
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# rubocop:disable
|
2
|
+
# rubocop:disable FileName
|
3
3
|
|
4
4
|
if ENV['GITHOOKS_DEV']
|
5
|
-
|
5
|
+
require 'pathname'
|
6
|
+
path = Pathname.new(__FILE__).dirname
|
7
|
+
$:.unshift(
|
8
|
+
if path.to_s.end_with? '.git/hooks'
|
9
|
+
path.parent.parent
|
10
|
+
else
|
11
|
+
path.parent
|
12
|
+
end.join('lib').realpath.to_s
|
13
|
+
)
|
6
14
|
end
|
7
15
|
require 'githooks'
|
8
16
|
|
data/lib/githooks.rb
CHANGED
@@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
20
20
|
require 'pathname'
|
21
21
|
require 'githooks/error'
|
22
22
|
require 'githooks/core_ext'
|
23
|
+
require 'githooks/core_ext/colorize'
|
23
24
|
require 'githooks/version'
|
24
25
|
|
25
26
|
module GitHooks
|
@@ -35,7 +36,6 @@ module GitHooks
|
|
35
36
|
autoload :Repository, 'githooks/repository'
|
36
37
|
autoload :Runner, 'githooks/runner'
|
37
38
|
autoload :SystemUtils, 'githooks/system_utils'
|
38
|
-
autoload :TerminalColors, 'githooks/terminal_colors'
|
39
39
|
|
40
40
|
class << self
|
41
41
|
attr_reader :debug, :verbose, :ignore_script
|
@@ -74,13 +74,17 @@ module GitHooks
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
SUCCESS_SYMBOL = '✓'.success! unless defined? SUCCESS_SYMBOL
|
78
|
+
FAILURE_SYMBOL = 'X'.failure! unless defined? FAILURE_SYMBOL
|
79
|
+
UNKNOWN_SYMBOL = '?'.unknown! unless defined? UNKNOWN_SYMBOL
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
LIB_PATH = Pathname.new(__FILE__).dirname.realpath unless defined? LIB_PATH
|
82
|
+
GEM_PATH = LIB_PATH.parent unless defined? GEM_PATH
|
83
|
+
BIN_PATH = GEM_PATH.join('bin') unless defined? BIN_PATH
|
84
|
+
|
85
|
+
SCRIPT_PATH = Pathname.new($0) unless defined? SCRIPT_PATH
|
86
|
+
SCRIPT_NAME = SCRIPT_PATH.basename.to_s unless defined? SCRIPT_NAME
|
87
|
+
HOOK_NAME = SCRIPT_NAME.to_s unless defined? HOOK_NAME
|
84
88
|
|
85
89
|
if ARGV.include? '--ignore-script'
|
86
90
|
ARGV.delete('--ignore-script')
|
data/lib/githooks/action.rb
CHANGED
@@ -17,14 +17,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
17
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
18
|
=end
|
19
19
|
|
20
|
-
require 'stringio'
|
21
|
-
require 'open3'
|
22
20
|
require 'set'
|
21
|
+
require 'stringio'
|
22
|
+
require 'colorize'
|
23
|
+
require_relative 'repository'
|
23
24
|
|
24
25
|
module GitHooks
|
25
|
-
class Action # rubocop:disable
|
26
|
-
include TerminalColors
|
27
|
-
|
26
|
+
class Action # rubocop:disable Metrics/ClassLength
|
28
27
|
attr_reader :title, :section, :on, :limiters
|
29
28
|
attr_reader :success, :errors, :warnings, :benchmark
|
30
29
|
private :section, :on
|
@@ -55,9 +54,9 @@ module GitHooks
|
|
55
54
|
status_colorize title
|
56
55
|
end
|
57
56
|
|
58
|
-
def
|
59
|
-
return
|
60
|
-
|
57
|
+
def status_symbol
|
58
|
+
return GitHooks::UNKNOWN_SYMBOL unless finished?
|
59
|
+
success? ? GitHooks::SUCCESS_SYMBOL : GitHooks::FAILURE_SYMBOL
|
61
60
|
end
|
62
61
|
|
63
62
|
%w(finished running waiting).each do |method|
|
@@ -66,42 +65,61 @@ module GitHooks
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def status_colorize(text)
|
69
|
-
return
|
70
|
-
success? ?
|
68
|
+
return text.unknown! unless finished?
|
69
|
+
success? ? text.success! : text.failure!
|
70
|
+
end
|
71
|
+
|
72
|
+
def run # rubocop:disable MethodLength, AbcSize
|
73
|
+
running!
|
74
|
+
with_benchmark do
|
75
|
+
with_captured_output {
|
76
|
+
begin
|
77
|
+
@success &= @on.call
|
78
|
+
rescue StandardError => e
|
79
|
+
$stderr.puts "Exception thrown during action call: #{e.class.name}: #{e.message}"
|
80
|
+
if GitHooks.debug?
|
81
|
+
$stderr.puts "#{e.class}: #{e.message}:\n\t#{e.backtrace.join("\n\t")}"
|
82
|
+
else
|
83
|
+
hooks_files = e.backtrace.select! { |line| line =~ %r{/hooks/} }
|
84
|
+
hooks_files.collect! { |line| line.split(':')[0..1].join(':') }
|
85
|
+
$stderr.puts " -> in hook file:line, #{hooks_files.join("\n\t")}" unless hooks_files.empty?
|
86
|
+
end
|
87
|
+
@success = false
|
88
|
+
ensure
|
89
|
+
finished!
|
90
|
+
end
|
91
|
+
}
|
92
|
+
end
|
71
93
|
end
|
72
94
|
|
73
|
-
def
|
74
|
-
|
95
|
+
def with_captured_output(&_block)
|
96
|
+
fail ArgumentError, 'expected block, none given' unless block_given?
|
75
97
|
|
76
98
|
begin
|
77
|
-
|
78
|
-
$
|
79
|
-
|
80
|
-
@success &= @on.call
|
81
|
-
rescue => error
|
82
|
-
errors.puts "Exception thrown during action call: #{error.class.name}: #{error.message}"
|
83
|
-
|
84
|
-
if !GitHooks.debug?
|
85
|
-
hooks_files = error.backtrace.select! { |line| line =~ %r{/hooks/} }
|
86
|
-
hooks_files.collect! { |line| line.split(':')[0..1].join(':') }
|
87
|
-
errors.puts " -> in hook file:line, #{hooks_files.join("\n\t")}" unless hooks_files.empty?
|
88
|
-
else
|
89
|
-
errors.puts "\t#{error.backtrace.join("\n\t")}"
|
90
|
-
end
|
91
|
-
|
92
|
-
@success = false
|
99
|
+
$stdout = warnings = StringIO.new
|
100
|
+
$stderr = errors = StringIO.new
|
101
|
+
yield
|
93
102
|
ensure
|
94
|
-
@
|
95
|
-
@
|
96
|
-
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
$stdout, $stderr = STDOUT, STDERR
|
101
|
-
finished!
|
103
|
+
@errors = errors.rewind && errors.read.split(/\n/)
|
104
|
+
@warnings = warnings.rewind && warnings.read.split(/\n/)
|
105
|
+
$stdout = STDOUT
|
106
|
+
$stderr = STDERR
|
102
107
|
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def with_benchmark(&_block)
|
111
|
+
fail ArgumentError, 'expected block, none given' unless block_given?
|
112
|
+
begin
|
113
|
+
start_time = Time.now
|
114
|
+
yield
|
115
|
+
ensure
|
116
|
+
@benchmark = Time.now - start_time
|
117
|
+
end
|
118
|
+
end
|
103
119
|
|
104
|
-
|
120
|
+
def respond_to_missing?(method, include_private = false)
|
121
|
+
return super unless section.hook.find_command(method)
|
122
|
+
true
|
105
123
|
end
|
106
124
|
|
107
125
|
def method_missing(method, *args, &block)
|
@@ -123,15 +141,15 @@ module GitHooks
|
|
123
141
|
end
|
124
142
|
|
125
143
|
def on_all_files(&block)
|
126
|
-
@on = ->
|
144
|
+
@on = -> { block.call manifest }
|
127
145
|
end
|
128
146
|
|
129
147
|
def on_argv(&block)
|
130
|
-
@on = ->
|
148
|
+
@on = -> { block.call section.hook.args }
|
131
149
|
end
|
132
150
|
|
133
151
|
def on(*args, &block)
|
134
|
-
@on = ->
|
152
|
+
@on = -> { block.call(*args) }
|
135
153
|
end
|
136
154
|
|
137
155
|
private
|
@@ -141,19 +159,15 @@ module GitHooks
|
|
141
159
|
end
|
142
160
|
|
143
161
|
def run_command(command, *args, &block)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
res.error.split(/\n/).each do |line|
|
154
|
-
$stderr.puts prefix ? "#{prefix}: #{line}" : line
|
155
|
-
end
|
156
|
-
end.status.success?
|
162
|
+
prefix = nil
|
163
|
+
args.extract_options.tap { |options|
|
164
|
+
prefix = options.delete(:prefix_output)
|
165
|
+
}
|
166
|
+
|
167
|
+
result = command.execute(*args, &block)
|
168
|
+
result.output_lines(prefix).each { |line| puts line }
|
169
|
+
result.error_lines(prefix).each { |line| puts line }
|
170
|
+
result.status.success?
|
157
171
|
end
|
158
172
|
end
|
159
173
|
end
|
data/lib/githooks/cli.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require_relative 'hook'
|
3
|
+
require_relative 'runner'
|
2
4
|
|
3
5
|
module GitHooks
|
4
6
|
module CLI
|
5
7
|
autoload :Config, 'githooks/commands/config'
|
6
8
|
|
9
|
+
# rubocop:disable AbcSize
|
7
10
|
class Base < Thor
|
8
11
|
class_option :verbose, aliases: '-v', type: :boolean, desc: 'verbose output', default: false
|
9
12
|
class_option :debug, aliases: '-d', type: :boolean, desc: 'debug output', default: false
|
@@ -18,7 +21,7 @@ module GitHooks
|
|
18
21
|
method_option :repo, aliases: '-r', type: :string, desc: 'Path to repo to run tests on', default: Dir.getwd
|
19
22
|
method_option :hooks, { # rubocop:disable BracesAroundHashParameters
|
20
23
|
type: :array,
|
21
|
-
desc: '
|
24
|
+
desc: 'hooks to attach',
|
22
25
|
enum: Hook::VALID_PHASES,
|
23
26
|
default: Hook::VALID_PHASES
|
24
27
|
}
|
@@ -27,7 +30,7 @@ module GitHooks
|
|
27
30
|
GitHooks.debug = !!options['debug']
|
28
31
|
|
29
32
|
unless options['script'] || options['path']
|
30
|
-
fail ArgumentError, %q
|
33
|
+
fail ArgumentError, %q"Neither 'path' nor 'script' were specified - please provide at least one."
|
31
34
|
end
|
32
35
|
|
33
36
|
Runner.attach(options)
|
@@ -72,9 +75,9 @@ module GitHooks
|
|
72
75
|
method_option :repo, aliases: '-r', type: :string, desc: 'Path to repo to run tests on', default: Dir.getwd
|
73
76
|
method_option :'skip-pre', type: :boolean, desc: 'Skip PreRun Scripts', default: false
|
74
77
|
method_option :'skip-post', type: :boolean, desc: 'Skip PostRun Scripts', default: false
|
75
|
-
method_option :'skip-bundler', type: :boolean, desc: %
|
78
|
+
method_option :'skip-bundler', type: :boolean, desc: %q"Don't load bundler gemfile", default: false
|
76
79
|
method_option :args, type: :array, desc: 'Args to pass to pre/post scripts and main testing script', default: []
|
77
|
-
def execute
|
80
|
+
def execute
|
78
81
|
GitHooks.verbose = !!options['verbose']
|
79
82
|
GitHooks.debug = !!options['debug']
|
80
83
|
|
@@ -82,10 +85,10 @@ module GitHooks
|
|
82
85
|
|
83
86
|
if opts['staged']
|
84
87
|
if opts['tracked']
|
85
|
-
warn
|
88
|
+
warn '--tracked conflicts with --staged. Dropping --tracked...'
|
86
89
|
opts['tracked'] = false
|
87
90
|
elsif opts['untracked']
|
88
|
-
warn
|
91
|
+
warn '--untracked conflicts with --staged. Dropping --untracked...'
|
89
92
|
opts['untracked'] = false
|
90
93
|
end
|
91
94
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'githooks/repository'
|
3
|
+
|
1
4
|
module GitHooks
|
2
5
|
module CLI
|
3
6
|
class Config < Thor
|
@@ -19,26 +22,30 @@ module GitHooks
|
|
19
22
|
}
|
20
23
|
|
21
24
|
desc :get, 'display the value for a configuration option'
|
22
|
-
def get(option_name) # rubocop:disable MethodLength
|
25
|
+
def get(option_name) # rubocop:disable MethodLength, AbcSize
|
23
26
|
unless VALID_CONFIG_OPTIONS.include? option_name
|
24
27
|
puts "Invalid option '#{option_name}': expected one of #{VALID_CONFIG_OPTIONS.join(', ')}"
|
25
28
|
return 1
|
26
29
|
end
|
27
30
|
|
28
|
-
GitHooks.verbose =
|
29
|
-
GitHooks.debug
|
31
|
+
GitHooks.verbose = !!options['verbose']
|
32
|
+
GitHooks.debug = !!options['debug']
|
30
33
|
options['repo'] ||= GitHooks::Repository.root_path
|
31
34
|
|
32
35
|
repo_data = GitHooks::Repository::Config.new.get(
|
33
36
|
option_name,
|
34
|
-
repo_path: options['repo'],
|
37
|
+
repo_path: options['repo'],
|
38
|
+
global: options['global']
|
35
39
|
)
|
40
|
+
|
36
41
|
if repo_data.nil?
|
37
42
|
puts "Repository [#{options['repo']}] option '#{option_name}' is currently not set."
|
38
43
|
return
|
39
44
|
end
|
40
|
-
|
41
|
-
|
45
|
+
|
46
|
+
Array(repo_data).flatten.each do |value|
|
47
|
+
value ||= 'not set'
|
48
|
+
puts "#{option_name}: #{value}"
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
@@ -49,9 +56,9 @@ module GitHooks
|
|
49
56
|
desc: 'overwrite all existing values.',
|
50
57
|
default: false
|
51
58
|
}
|
52
|
-
def set(option_name, option_value)
|
53
|
-
GitHooks.verbose =
|
54
|
-
GitHooks.debug
|
59
|
+
def set(option_name, option_value) # rubocop:disable AbcSize
|
60
|
+
GitHooks.verbose = !!options['verbose']
|
61
|
+
GitHooks.debug = !!options['debug']
|
55
62
|
options['repo'] ||= GitHooks::Repository.root_path
|
56
63
|
|
57
64
|
GitHooks::Repository::Config.new.set(
|
@@ -66,9 +73,9 @@ module GitHooks
|
|
66
73
|
end
|
67
74
|
|
68
75
|
desc :unset, 'Unsets a configuration value'
|
69
|
-
def unset(option_name, option_value = nil)
|
70
|
-
GitHooks.verbose =
|
71
|
-
GitHooks.debug
|
76
|
+
def unset(option_name, option_value = nil) # rubocop:disable AbcSize
|
77
|
+
GitHooks.verbose = !!options['verbose']
|
78
|
+
GitHooks.debug = !!options['debug']
|
72
79
|
options['repo'] ||= GitHooks::Repository.root_path
|
73
80
|
|
74
81
|
GitHooks::Repository::Config.new.unset(
|
@@ -82,25 +89,25 @@ module GitHooks
|
|
82
89
|
end
|
83
90
|
|
84
91
|
desc :list, 'Lists all githooks configuration values'
|
85
|
-
def list
|
86
|
-
|
87
|
-
|
88
|
-
GitHooks.verbose = true if options['verbose']
|
89
|
-
GitHooks.debug = true if options['debug']
|
92
|
+
def list # rubocop:disable AbcSize
|
93
|
+
GitHooks.verbose = !!options['verbose']
|
94
|
+
GitHooks.debug = !!options['debug']
|
90
95
|
|
91
96
|
options['repo'] ||= GitHooks::Repository.root_path
|
92
97
|
config = GitHooks::Repository::Config.new
|
93
98
|
|
94
99
|
githooks = config.list(global: options['global'], repo_path: options['repo'])['githooks']
|
100
|
+
return unless githooks
|
101
|
+
|
95
102
|
githooks.each do |path, data|
|
96
103
|
puts "Repository #{path}:"
|
97
|
-
key_size, value_size = data.keys.collect(&:size).
|
104
|
+
key_size, value_size = data.keys.collect(&:size).maximum, data.values.collect(&:size).maximum
|
98
105
|
data.each do |key, value|
|
99
106
|
[value].flatten.each do |v|
|
100
107
|
printf " %-#{key_size}s : %-#{value_size}s\n", key, v
|
101
108
|
end
|
102
109
|
end
|
103
|
-
end
|
110
|
+
end
|
104
111
|
end
|
105
112
|
end
|
106
113
|
end
|