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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +86 -168
- data/lib/rails_git_hooks/checks/commit_msg/not_empty.rb +25 -0
- data/lib/rails_git_hooks/checks/commit_msg.rb +1 -0
- data/lib/rails_git_hooks/checks/post_checkout/bundle_install.rb +16 -0
- data/lib/rails_git_hooks/checks/post_checkout/db_migrate.rb +16 -0
- data/lib/rails_git_hooks/checks/post_checkout/npm_install.rb +16 -0
- data/lib/rails_git_hooks/checks/post_checkout/yarn_install.rb +16 -0
- data/lib/rails_git_hooks/checks/post_checkout.rb +13 -0
- data/lib/rails_git_hooks/checks/post_merge/bundle_install.rb +16 -0
- data/lib/rails_git_hooks/checks/post_merge/db_migrate.rb +16 -0
- data/lib/rails_git_hooks/checks/post_merge/npm_install.rb +16 -0
- data/lib/rails_git_hooks/checks/post_merge/yarn_install.rb +16 -0
- data/lib/rails_git_hooks/checks/post_merge.rb +13 -0
- data/lib/rails_git_hooks/checks/pre_commit/erblint.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit/eslint.rb +34 -0
- data/lib/rails_git_hooks/checks/pre_commit/go_vet.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit/golint.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit/haml_lint.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit/jslint.rb +34 -0
- data/lib/rails_git_hooks/checks/pre_commit/php_lint.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit/pylint.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit/rails_best_practices.rb +31 -0
- data/lib/rails_git_hooks/checks/pre_commit/scss_lint.rb +30 -0
- data/lib/rails_git_hooks/checks/pre_commit.rb +10 -0
- data/lib/rails_git_hooks/checks/pre_push/run_go_test.rb +24 -0
- data/lib/rails_git_hooks/checks/pre_push/run_pytest.rb +24 -0
- data/lib/rails_git_hooks/checks/pre_push.rb +2 -0
- data/lib/rails_git_hooks/checks/shared/bundle_install_check.rb +28 -0
- data/lib/rails_git_hooks/checks/shared/db_migrate_check.rb +28 -0
- data/lib/rails_git_hooks/checks/shared/npm_install_check.rb +28 -0
- data/lib/rails_git_hooks/checks/shared/yarn_install_check.rb +28 -0
- data/lib/rails_git_hooks/checks.rb +6 -0
- data/lib/rails_git_hooks/cli.rb +8 -100
- data/lib/rails_git_hooks/config/constants.rb +7 -1
- data/lib/rails_git_hooks/config/defaults.yml +321 -1
- data/lib/rails_git_hooks/install/installer.rb +31 -5
- data/lib/rails_git_hooks/runtime/check_registry.rb +22 -1
- data/lib/rails_git_hooks/runtime/override_config.rb +10 -4
- data/lib/rails_git_hooks/runtime/repository.rb +8 -0
- data/lib/rails_git_hooks/runtime/runner.rb +4 -0
- data/lib/rails_git_hooks/version.rb +1 -1
- data/templates/hooks/post-checkout +13 -0
- data/templates/hooks/post-merge +13 -0
- metadata +31 -44
|
@@ -96,6 +96,160 @@ PreCommit:
|
|
|
96
96
|
file_based: true
|
|
97
97
|
install_hint: Add `gem "rubocop"` to your Gemfile and run bundle install
|
|
98
98
|
|
|
99
|
+
RailsBestPractices:
|
|
100
|
+
enabled: false
|
|
101
|
+
quiet: true
|
|
102
|
+
on_fail: warn
|
|
103
|
+
on_warn: warn
|
|
104
|
+
on_missing_dependency: warn
|
|
105
|
+
include: []
|
|
106
|
+
exclude: []
|
|
107
|
+
dependencies:
|
|
108
|
+
executables: [bundle]
|
|
109
|
+
libraries: [rails_best_practices]
|
|
110
|
+
command: [bundle, exec, rails_best_practices]
|
|
111
|
+
description: Warn on Rails best practices violations
|
|
112
|
+
file_based: true
|
|
113
|
+
install_hint: Add `gem "rails_best_practices"` to your Gemfile and run bundle install
|
|
114
|
+
|
|
115
|
+
ErbLint:
|
|
116
|
+
enabled: false
|
|
117
|
+
quiet: true
|
|
118
|
+
on_fail: fail
|
|
119
|
+
on_warn: warn
|
|
120
|
+
on_missing_dependency: warn
|
|
121
|
+
include: []
|
|
122
|
+
exclude: []
|
|
123
|
+
dependencies:
|
|
124
|
+
executables: [bundle]
|
|
125
|
+
libraries: [erblint]
|
|
126
|
+
command: [bundle, exec, erblint]
|
|
127
|
+
description: Run erblint on staged ERB files
|
|
128
|
+
file_based: true
|
|
129
|
+
install_hint: Add `gem "erblint"` to your Gemfile and run bundle install
|
|
130
|
+
|
|
131
|
+
Eslint:
|
|
132
|
+
enabled: false
|
|
133
|
+
quiet: true
|
|
134
|
+
on_fail: fail
|
|
135
|
+
on_warn: warn
|
|
136
|
+
on_missing_dependency: warn
|
|
137
|
+
include: []
|
|
138
|
+
exclude: []
|
|
139
|
+
dependencies:
|
|
140
|
+
executables: [eslint]
|
|
141
|
+
command: [eslint]
|
|
142
|
+
description: Run eslint on staged JavaScript files
|
|
143
|
+
file_based: true
|
|
144
|
+
install_hint: Install eslint (e.g. npm install -D eslint) or override command in config
|
|
145
|
+
|
|
146
|
+
Golint:
|
|
147
|
+
enabled: false
|
|
148
|
+
quiet: true
|
|
149
|
+
on_fail: fail
|
|
150
|
+
on_warn: warn
|
|
151
|
+
on_missing_dependency: warn
|
|
152
|
+
include: []
|
|
153
|
+
exclude: []
|
|
154
|
+
dependencies:
|
|
155
|
+
executables: [golint]
|
|
156
|
+
command: [golint]
|
|
157
|
+
description: Run golint on staged Go files
|
|
158
|
+
file_based: true
|
|
159
|
+
install_hint: Install golint (e.g. go install golang.org/x/lint/golint@latest) or override command in config
|
|
160
|
+
|
|
161
|
+
HamlLint:
|
|
162
|
+
enabled: false
|
|
163
|
+
quiet: true
|
|
164
|
+
on_fail: fail
|
|
165
|
+
on_warn: warn
|
|
166
|
+
on_missing_dependency: warn
|
|
167
|
+
include: []
|
|
168
|
+
exclude: []
|
|
169
|
+
dependencies:
|
|
170
|
+
executables: [bundle]
|
|
171
|
+
libraries: [haml_lint]
|
|
172
|
+
command: [bundle, exec, haml-lint]
|
|
173
|
+
description: Run haml-lint on staged HAML files
|
|
174
|
+
file_based: true
|
|
175
|
+
install_hint: Add `gem "haml_lint"` to your Gemfile and run bundle install
|
|
176
|
+
|
|
177
|
+
Jslint:
|
|
178
|
+
enabled: false
|
|
179
|
+
quiet: true
|
|
180
|
+
on_fail: fail
|
|
181
|
+
on_warn: warn
|
|
182
|
+
on_missing_dependency: warn
|
|
183
|
+
include: []
|
|
184
|
+
exclude: []
|
|
185
|
+
dependencies:
|
|
186
|
+
executables: [jslint]
|
|
187
|
+
command: [jslint]
|
|
188
|
+
description: Run jslint on staged JavaScript files
|
|
189
|
+
file_based: true
|
|
190
|
+
install_hint: Install jslint (e.g. npm install -D jslint or npm install -g jslint) or override command in config
|
|
191
|
+
|
|
192
|
+
PhpLint:
|
|
193
|
+
enabled: false
|
|
194
|
+
quiet: true
|
|
195
|
+
on_fail: fail
|
|
196
|
+
on_warn: warn
|
|
197
|
+
on_missing_dependency: warn
|
|
198
|
+
include: []
|
|
199
|
+
exclude: []
|
|
200
|
+
dependencies:
|
|
201
|
+
executables: [php]
|
|
202
|
+
command: [php, "-l"]
|
|
203
|
+
description: Run php -l (syntax check) on staged PHP files
|
|
204
|
+
file_based: true
|
|
205
|
+
install_hint: Ensure PHP is installed and on PATH
|
|
206
|
+
|
|
207
|
+
Pylint:
|
|
208
|
+
enabled: false
|
|
209
|
+
quiet: true
|
|
210
|
+
on_fail: fail
|
|
211
|
+
on_warn: warn
|
|
212
|
+
on_missing_dependency: warn
|
|
213
|
+
include: []
|
|
214
|
+
exclude: []
|
|
215
|
+
dependencies:
|
|
216
|
+
executables: [pylint]
|
|
217
|
+
command: [pylint]
|
|
218
|
+
description: Run pylint on staged Python files
|
|
219
|
+
file_based: true
|
|
220
|
+
install_hint: Install pylint (e.g. pip install pylint) or override command in config
|
|
221
|
+
|
|
222
|
+
ScssLint:
|
|
223
|
+
enabled: false
|
|
224
|
+
quiet: true
|
|
225
|
+
on_fail: fail
|
|
226
|
+
on_warn: warn
|
|
227
|
+
on_missing_dependency: warn
|
|
228
|
+
include: []
|
|
229
|
+
exclude: []
|
|
230
|
+
dependencies:
|
|
231
|
+
executables: [bundle]
|
|
232
|
+
libraries: [scss_lint]
|
|
233
|
+
command: [bundle, exec, scss-lint]
|
|
234
|
+
description: Run scss-lint on staged SCSS files
|
|
235
|
+
file_based: true
|
|
236
|
+
install_hint: Add `gem "scss_lint"` to your Gemfile and run bundle install
|
|
237
|
+
|
|
238
|
+
GoVet:
|
|
239
|
+
enabled: false
|
|
240
|
+
quiet: true
|
|
241
|
+
on_fail: fail
|
|
242
|
+
on_warn: warn
|
|
243
|
+
on_missing_dependency: warn
|
|
244
|
+
include: []
|
|
245
|
+
exclude: []
|
|
246
|
+
dependencies:
|
|
247
|
+
executables: [go]
|
|
248
|
+
command: [go, vet]
|
|
249
|
+
description: Run go vet on staged Go files
|
|
250
|
+
file_based: true
|
|
251
|
+
install_hint: Ensure Go toolchain is installed and on PATH
|
|
252
|
+
|
|
99
253
|
CommitMsg:
|
|
100
254
|
JiraPrefix:
|
|
101
255
|
enabled: true
|
|
@@ -110,9 +264,22 @@ CommitMsg:
|
|
|
110
264
|
description: Prefix commit messages with ticket id from branch
|
|
111
265
|
file_based: false
|
|
112
266
|
|
|
267
|
+
NotEmpty:
|
|
268
|
+
enabled: true
|
|
269
|
+
quiet: false
|
|
270
|
+
on_fail: fail
|
|
271
|
+
on_warn: warn
|
|
272
|
+
on_missing_dependency: warn
|
|
273
|
+
include: []
|
|
274
|
+
exclude: []
|
|
275
|
+
dependencies: {}
|
|
276
|
+
command: []
|
|
277
|
+
description: Reject empty commit messages
|
|
278
|
+
file_based: false
|
|
279
|
+
|
|
113
280
|
PrePush:
|
|
114
281
|
RunTests:
|
|
115
|
-
enabled:
|
|
282
|
+
enabled: false
|
|
116
283
|
quiet: false
|
|
117
284
|
on_fail: fail
|
|
118
285
|
on_warn: warn
|
|
@@ -121,7 +288,160 @@ PrePush:
|
|
|
121
288
|
exclude: []
|
|
122
289
|
dependencies:
|
|
123
290
|
executables: [bundle]
|
|
291
|
+
libraries: [rspec]
|
|
124
292
|
command: [bundle, exec, rspec]
|
|
125
293
|
description: Run test suite before push
|
|
126
294
|
file_based: false
|
|
127
295
|
install_hint: Install test dependencies and ensure `bundle exec rspec` runs successfully
|
|
296
|
+
|
|
297
|
+
RunPytest:
|
|
298
|
+
enabled: false
|
|
299
|
+
quiet: false
|
|
300
|
+
on_fail: fail
|
|
301
|
+
on_warn: warn
|
|
302
|
+
on_missing_dependency: warn
|
|
303
|
+
include: []
|
|
304
|
+
exclude: []
|
|
305
|
+
dependencies:
|
|
306
|
+
executables: [pytest]
|
|
307
|
+
command: [pytest]
|
|
308
|
+
description: Run pytest test suite before push
|
|
309
|
+
file_based: false
|
|
310
|
+
install_hint: Install pytest (e.g. pip install pytest) and ensure pytest runs successfully
|
|
311
|
+
|
|
312
|
+
RunGoTest:
|
|
313
|
+
enabled: false
|
|
314
|
+
quiet: false
|
|
315
|
+
on_fail: fail
|
|
316
|
+
on_warn: warn
|
|
317
|
+
on_missing_dependency: warn
|
|
318
|
+
include: []
|
|
319
|
+
exclude: []
|
|
320
|
+
dependencies:
|
|
321
|
+
executables: [go]
|
|
322
|
+
command: [go, test, "./..."]
|
|
323
|
+
description: Run go test suite before push
|
|
324
|
+
file_based: false
|
|
325
|
+
install_hint: Ensure Go toolchain is installed and `go test ./...` runs successfully
|
|
326
|
+
|
|
327
|
+
PostCheckout:
|
|
328
|
+
BundleInstall:
|
|
329
|
+
enabled: false
|
|
330
|
+
quiet: false
|
|
331
|
+
on_fail: fail
|
|
332
|
+
on_warn: warn
|
|
333
|
+
on_missing_dependency: warn
|
|
334
|
+
include: [Gemfile, Gemfile.lock]
|
|
335
|
+
exclude: []
|
|
336
|
+
dependencies:
|
|
337
|
+
executables: [bundle]
|
|
338
|
+
command: [bundle, install]
|
|
339
|
+
description: Run bundle install when Gemfile or Gemfile.lock changed (branch checkout)
|
|
340
|
+
file_based: true
|
|
341
|
+
install_hint: Ensure bundle is available
|
|
342
|
+
|
|
343
|
+
DbMigrate:
|
|
344
|
+
enabled: false
|
|
345
|
+
quiet: false
|
|
346
|
+
on_fail: fail
|
|
347
|
+
on_warn: warn
|
|
348
|
+
on_missing_dependency: warn
|
|
349
|
+
include: [db/migrate/*.rb, db/schema.rb, db/structure.sql]
|
|
350
|
+
exclude: []
|
|
351
|
+
dependencies:
|
|
352
|
+
executables: [bundle]
|
|
353
|
+
command: [bundle, exec, rails, db:migrate]
|
|
354
|
+
description: Run db:migrate when migrations or schema changed (branch checkout)
|
|
355
|
+
file_based: true
|
|
356
|
+
install_hint: Rails app with db:migrate (or override command in config)
|
|
357
|
+
|
|
358
|
+
NpmInstall:
|
|
359
|
+
enabled: false
|
|
360
|
+
quiet: false
|
|
361
|
+
on_fail: fail
|
|
362
|
+
on_warn: warn
|
|
363
|
+
on_missing_dependency: warn
|
|
364
|
+
include: [package.json, package-lock.json]
|
|
365
|
+
exclude: []
|
|
366
|
+
dependencies:
|
|
367
|
+
executables: [npm]
|
|
368
|
+
command: [npm, install]
|
|
369
|
+
description: Run npm install when package.json or package-lock.json changed (branch checkout)
|
|
370
|
+
file_based: true
|
|
371
|
+
install_hint: Ensure npm is available
|
|
372
|
+
|
|
373
|
+
YarnInstall:
|
|
374
|
+
enabled: false
|
|
375
|
+
quiet: false
|
|
376
|
+
on_fail: fail
|
|
377
|
+
on_warn: warn
|
|
378
|
+
on_missing_dependency: warn
|
|
379
|
+
include: [package.json, yarn.lock]
|
|
380
|
+
exclude: []
|
|
381
|
+
dependencies:
|
|
382
|
+
executables: [yarn]
|
|
383
|
+
command: [yarn, install]
|
|
384
|
+
description: Run yarn install when package.json or yarn.lock changed (branch checkout)
|
|
385
|
+
file_based: true
|
|
386
|
+
install_hint: Ensure yarn is available
|
|
387
|
+
|
|
388
|
+
PostMerge:
|
|
389
|
+
BundleInstall:
|
|
390
|
+
enabled: false
|
|
391
|
+
quiet: false
|
|
392
|
+
on_fail: fail
|
|
393
|
+
on_warn: warn
|
|
394
|
+
on_missing_dependency: warn
|
|
395
|
+
include: [Gemfile, Gemfile.lock]
|
|
396
|
+
exclude: []
|
|
397
|
+
dependencies:
|
|
398
|
+
executables: [bundle]
|
|
399
|
+
command: [bundle, install]
|
|
400
|
+
description: Run bundle install when Gemfile or Gemfile.lock changed (after merge)
|
|
401
|
+
file_based: true
|
|
402
|
+
install_hint: Ensure bundle is available
|
|
403
|
+
|
|
404
|
+
DbMigrate:
|
|
405
|
+
enabled: false
|
|
406
|
+
quiet: false
|
|
407
|
+
on_fail: fail
|
|
408
|
+
on_warn: warn
|
|
409
|
+
on_missing_dependency: warn
|
|
410
|
+
include: [db/migrate/*.rb, db/schema.rb, db/structure.sql]
|
|
411
|
+
exclude: []
|
|
412
|
+
dependencies:
|
|
413
|
+
executables: [bundle]
|
|
414
|
+
command: [bundle, exec, rails, db:migrate]
|
|
415
|
+
description: Run db:migrate when migrations or schema changed (after merge)
|
|
416
|
+
file_based: true
|
|
417
|
+
install_hint: Rails app with db:migrate (or override command in config)
|
|
418
|
+
|
|
419
|
+
NpmInstall:
|
|
420
|
+
enabled: false
|
|
421
|
+
quiet: false
|
|
422
|
+
on_fail: fail
|
|
423
|
+
on_warn: warn
|
|
424
|
+
on_missing_dependency: warn
|
|
425
|
+
include: [package.json, package-lock.json]
|
|
426
|
+
exclude: []
|
|
427
|
+
dependencies:
|
|
428
|
+
executables: [npm]
|
|
429
|
+
command: [npm, install]
|
|
430
|
+
description: Run npm install when package.json or package-lock.json changed (after merge)
|
|
431
|
+
file_based: true
|
|
432
|
+
install_hint: Ensure npm is available
|
|
433
|
+
|
|
434
|
+
YarnInstall:
|
|
435
|
+
enabled: false
|
|
436
|
+
quiet: false
|
|
437
|
+
on_fail: fail
|
|
438
|
+
on_warn: warn
|
|
439
|
+
on_missing_dependency: warn
|
|
440
|
+
include: [package.json, yarn.lock]
|
|
441
|
+
exclude: []
|
|
442
|
+
dependencies:
|
|
443
|
+
executables: [yarn]
|
|
444
|
+
command: [yarn, install]
|
|
445
|
+
description: Run yarn install when package.json or yarn.lock changed (after merge)
|
|
446
|
+
file_based: true
|
|
447
|
+
install_hint: Ensure yarn is available
|
|
@@ -5,19 +5,23 @@ require 'fileutils'
|
|
|
5
5
|
module GitHooks
|
|
6
6
|
class Installer
|
|
7
7
|
def initialize(git_dir: nil)
|
|
8
|
-
|
|
8
|
+
if git_dir
|
|
9
|
+
@git_dir = git_dir
|
|
10
|
+
@repo = nil
|
|
11
|
+
else
|
|
12
|
+
@repo = Repository.new
|
|
13
|
+
@git_dir = @repo.git_dir
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
16
|
|
|
11
|
-
def install
|
|
17
|
+
def install
|
|
12
18
|
target_dir = File.join(@git_dir, 'hooks')
|
|
13
19
|
raise GitHooks::Error, "Not a git repository or .git/hooks not found: #{@git_dir}" unless Dir.exist?(target_dir)
|
|
14
20
|
|
|
15
21
|
copy_runtime(target_dir)
|
|
16
22
|
|
|
17
|
-
hooks =
|
|
23
|
+
hooks = hooks_enabled_in_config.select { |name| self.class.available_hook_names.include?(name) }
|
|
18
24
|
hooks.each_with_object([]) do |name, installed|
|
|
19
|
-
next unless self.class.available_hook_names.include?(name)
|
|
20
|
-
|
|
21
25
|
dest = File.join(target_dir, name)
|
|
22
26
|
File.write(dest, File.read(File.join(Constants::HOOKS_DIR, name)))
|
|
23
27
|
File.chmod(0o755, dest)
|
|
@@ -35,6 +39,28 @@ module GitHooks
|
|
|
35
39
|
|
|
36
40
|
private
|
|
37
41
|
|
|
42
|
+
def repo_for_config
|
|
43
|
+
@repo_for_config ||= begin
|
|
44
|
+
root = File.dirname(@git_dir)
|
|
45
|
+
Struct.new(:root, :config_path, :local_config_path).new(
|
|
46
|
+
root,
|
|
47
|
+
File.join(root, Constants::CONFIG_FILE),
|
|
48
|
+
File.join(root, Constants::CONFIG_FILE_LOCAL)
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def hooks_enabled_in_config
|
|
54
|
+
override_config = OverrideConfig.new(repo: repo_for_config)
|
|
55
|
+
effective = override_config.effective_config(CheckRegistry.all)
|
|
56
|
+
effective.each_with_object([]) do |(section_name, check_configs), out|
|
|
57
|
+
hook_name = Constants::SECTION_TO_HOOK[section_name]
|
|
58
|
+
next unless hook_name && self.class.available_hook_names.include?(hook_name)
|
|
59
|
+
|
|
60
|
+
out << hook_name if check_configs.values.any? { |cfg| cfg['enabled'] == true }
|
|
61
|
+
end.uniq
|
|
62
|
+
end
|
|
63
|
+
|
|
38
64
|
def copy_runtime(target_dir)
|
|
39
65
|
runtime_dir = File.join(target_dir, Constants::RUNTIME_DIR_NAME)
|
|
40
66
|
FileUtils.rm_rf(runtime_dir)
|
|
@@ -10,8 +10,29 @@ module GitHooks
|
|
|
10
10
|
Checks::PreCommit::MigrationsCheck,
|
|
11
11
|
Checks::PreCommit::WhitespaceCheck,
|
|
12
12
|
Checks::PreCommit::RuboCop,
|
|
13
|
+
Checks::PreCommit::RailsBestPractices,
|
|
14
|
+
Checks::PreCommit::ErbLint,
|
|
15
|
+
Checks::PreCommit::Eslint,
|
|
16
|
+
Checks::PreCommit::Golint,
|
|
17
|
+
Checks::PreCommit::HamlLint,
|
|
18
|
+
Checks::PreCommit::Jslint,
|
|
19
|
+
Checks::PreCommit::PhpLint,
|
|
20
|
+
Checks::PreCommit::Pylint,
|
|
21
|
+
Checks::PreCommit::ScssLint,
|
|
22
|
+
Checks::PreCommit::GoVet,
|
|
13
23
|
Checks::CommitMsg::JiraPrefix,
|
|
14
|
-
Checks::
|
|
24
|
+
Checks::CommitMsg::NotEmpty,
|
|
25
|
+
Checks::PrePush::RunTests,
|
|
26
|
+
Checks::PrePush::RunPytest,
|
|
27
|
+
Checks::PrePush::RunGoTest,
|
|
28
|
+
Checks::PostCheckout::BundleInstall,
|
|
29
|
+
Checks::PostCheckout::DbMigrate,
|
|
30
|
+
Checks::PostCheckout::NpmInstall,
|
|
31
|
+
Checks::PostCheckout::YarnInstall,
|
|
32
|
+
Checks::PostMerge::BundleInstall,
|
|
33
|
+
Checks::PostMerge::DbMigrate,
|
|
34
|
+
Checks::PostMerge::NpmInstall,
|
|
35
|
+
Checks::PostMerge::YarnInstall
|
|
15
36
|
].freeze
|
|
16
37
|
|
|
17
38
|
def self.all
|
|
@@ -15,9 +15,9 @@ module GitHooks
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def load
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
main = load_file(@repo.config_path)
|
|
19
|
+
local = load_file(@repo.local_config_path)
|
|
20
|
+
deep_merge(main, local)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def config_for(definition)
|
|
@@ -35,7 +35,7 @@ module GitHooks
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def set_option(definition, option, value)
|
|
38
|
-
data =
|
|
38
|
+
data = load_file(@repo.config_path)
|
|
39
39
|
section = data[definition.hook_section] ||= {}
|
|
40
40
|
section[definition.config_name] ||= {}
|
|
41
41
|
|
|
@@ -69,6 +69,12 @@ module GitHooks
|
|
|
69
69
|
|
|
70
70
|
private
|
|
71
71
|
|
|
72
|
+
def load_file(path)
|
|
73
|
+
return {} unless File.exist?(path)
|
|
74
|
+
|
|
75
|
+
deep_stringify(YAML.safe_load(File.read(path), aliases: true) || {})
|
|
76
|
+
end
|
|
77
|
+
|
|
72
78
|
def write(data)
|
|
73
79
|
if data.empty?
|
|
74
80
|
FileUtils.rm_f(@repo.config_path)
|
|
@@ -14,6 +14,10 @@ module GitHooks
|
|
|
14
14
|
File.join(root, Constants::CONFIG_FILE)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def local_config_path
|
|
18
|
+
File.join(root, Constants::CONFIG_FILE_LOCAL)
|
|
19
|
+
end
|
|
20
|
+
|
|
17
21
|
def hook_runtime_dir(hooks_dir)
|
|
18
22
|
File.join(hooks_dir, Constants::RUNTIME_DIR_NAME)
|
|
19
23
|
end
|
|
@@ -38,6 +42,10 @@ module GitHooks
|
|
|
38
42
|
git_output('diff', '--cached', '--name-only').split("\n").map(&:strip).reject(&:empty?)
|
|
39
43
|
end
|
|
40
44
|
|
|
45
|
+
def changed_files(ref1, ref2)
|
|
46
|
+
git_output('diff', '--name-only', ref1.to_s, ref2.to_s).split("\n").map(&:strip).reject(&:empty?)
|
|
47
|
+
end
|
|
48
|
+
|
|
41
49
|
private
|
|
42
50
|
|
|
43
51
|
def resolve_paths(start_dir)
|
|
@@ -52,6 +52,10 @@ module GitHooks
|
|
|
52
52
|
def modified_files
|
|
53
53
|
@modified_files ||= case @hook_name
|
|
54
54
|
when :pre_commit then @repo.staged_files
|
|
55
|
+
when :post_checkout
|
|
56
|
+
@argv[2] == '1' ? @repo.changed_files(@argv[0], @argv[1]) : []
|
|
57
|
+
when :post_merge
|
|
58
|
+
@repo.changed_files('ORIG_HEAD', 'HEAD')
|
|
55
59
|
else []
|
|
56
60
|
end
|
|
57
61
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
hooks_dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
begin
|
|
6
|
+
require 'bundler/setup'
|
|
7
|
+
rescue LoadError, StandardError
|
|
8
|
+
nil
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
require File.join(hooks_dir, 'rails_git_hooks', 'runtime')
|
|
12
|
+
|
|
13
|
+
exit GitHooks::Runtime.execute(:post_checkout, argv: ARGV, stdin: $stdin.read)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
hooks_dir = File.dirname(File.expand_path(__FILE__))
|
|
5
|
+
begin
|
|
6
|
+
require 'bundler/setup'
|
|
7
|
+
rescue LoadError, StandardError
|
|
8
|
+
nil
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
require File.join(hooks_dir, 'rails_git_hooks', 'runtime')
|
|
12
|
+
|
|
13
|
+
exit GitHooks::Runtime.execute(:post_merge, argv: ARGV, stdin: $stdin.read)
|
metadata
CHANGED
|
@@ -1,56 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_git_hooks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nikita Nazarov
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: rake
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - "~>"
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '13.0'
|
|
19
|
-
type: :development
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - "~>"
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '13.0'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: rspec
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '3.0'
|
|
33
|
-
type: :development
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '3.0'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: rubocop
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.0'
|
|
47
|
-
type: :development
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.0'
|
|
11
|
+
dependencies: []
|
|
54
12
|
description: Installs most useful git hooks for Rails and Ruby projects
|
|
55
13
|
email:
|
|
56
14
|
- nikenor11@gmail.com
|
|
@@ -68,16 +26,43 @@ files:
|
|
|
68
26
|
- lib/rails_git_hooks/checks/base.rb
|
|
69
27
|
- lib/rails_git_hooks/checks/commit_msg.rb
|
|
70
28
|
- lib/rails_git_hooks/checks/commit_msg/jira_prefix.rb
|
|
29
|
+
- lib/rails_git_hooks/checks/commit_msg/not_empty.rb
|
|
30
|
+
- lib/rails_git_hooks/checks/post_checkout.rb
|
|
31
|
+
- lib/rails_git_hooks/checks/post_checkout/bundle_install.rb
|
|
32
|
+
- lib/rails_git_hooks/checks/post_checkout/db_migrate.rb
|
|
33
|
+
- lib/rails_git_hooks/checks/post_checkout/npm_install.rb
|
|
34
|
+
- lib/rails_git_hooks/checks/post_checkout/yarn_install.rb
|
|
35
|
+
- lib/rails_git_hooks/checks/post_merge.rb
|
|
36
|
+
- lib/rails_git_hooks/checks/post_merge/bundle_install.rb
|
|
37
|
+
- lib/rails_git_hooks/checks/post_merge/db_migrate.rb
|
|
38
|
+
- lib/rails_git_hooks/checks/post_merge/npm_install.rb
|
|
39
|
+
- lib/rails_git_hooks/checks/post_merge/yarn_install.rb
|
|
71
40
|
- lib/rails_git_hooks/checks/pre_commit.rb
|
|
72
41
|
- lib/rails_git_hooks/checks/pre_commit/debugger_check.rb
|
|
73
42
|
- lib/rails_git_hooks/checks/pre_commit/default_branch.rb
|
|
43
|
+
- lib/rails_git_hooks/checks/pre_commit/erblint.rb
|
|
44
|
+
- lib/rails_git_hooks/checks/pre_commit/eslint.rb
|
|
45
|
+
- lib/rails_git_hooks/checks/pre_commit/go_vet.rb
|
|
46
|
+
- lib/rails_git_hooks/checks/pre_commit/golint.rb
|
|
47
|
+
- lib/rails_git_hooks/checks/pre_commit/haml_lint.rb
|
|
48
|
+
- lib/rails_git_hooks/checks/pre_commit/jslint.rb
|
|
74
49
|
- lib/rails_git_hooks/checks/pre_commit/json_format_check.rb
|
|
75
50
|
- lib/rails_git_hooks/checks/pre_commit/migrations_check.rb
|
|
51
|
+
- lib/rails_git_hooks/checks/pre_commit/php_lint.rb
|
|
52
|
+
- lib/rails_git_hooks/checks/pre_commit/pylint.rb
|
|
53
|
+
- lib/rails_git_hooks/checks/pre_commit/rails_best_practices.rb
|
|
76
54
|
- lib/rails_git_hooks/checks/pre_commit/rubocop.rb
|
|
55
|
+
- lib/rails_git_hooks/checks/pre_commit/scss_lint.rb
|
|
77
56
|
- lib/rails_git_hooks/checks/pre_commit/whitespace_check.rb
|
|
78
57
|
- lib/rails_git_hooks/checks/pre_commit/yaml_format_check.rb
|
|
79
58
|
- lib/rails_git_hooks/checks/pre_push.rb
|
|
59
|
+
- lib/rails_git_hooks/checks/pre_push/run_go_test.rb
|
|
60
|
+
- lib/rails_git_hooks/checks/pre_push/run_pytest.rb
|
|
80
61
|
- lib/rails_git_hooks/checks/pre_push/run_tests.rb
|
|
62
|
+
- lib/rails_git_hooks/checks/shared/bundle_install_check.rb
|
|
63
|
+
- lib/rails_git_hooks/checks/shared/db_migrate_check.rb
|
|
64
|
+
- lib/rails_git_hooks/checks/shared/npm_install_check.rb
|
|
65
|
+
- lib/rails_git_hooks/checks/shared/yarn_install_check.rb
|
|
81
66
|
- lib/rails_git_hooks/cli.rb
|
|
82
67
|
- lib/rails_git_hooks/config/constants.rb
|
|
83
68
|
- lib/rails_git_hooks/config/defaults.yml
|
|
@@ -96,6 +81,8 @@ files:
|
|
|
96
81
|
- lib/rails_git_hooks/runtime/runner.rb
|
|
97
82
|
- lib/rails_git_hooks/version.rb
|
|
98
83
|
- templates/hooks/commit-msg
|
|
84
|
+
- templates/hooks/post-checkout
|
|
85
|
+
- templates/hooks/post-merge
|
|
99
86
|
- templates/hooks/pre-commit
|
|
100
87
|
- templates/hooks/pre-push
|
|
101
88
|
homepage: https://github.com/NikitaNazarov1/rails_git_hooks
|