overcommit 0.64.0 → 0.67.0
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/lib/overcommit/cli.rb +22 -1
- data/lib/overcommit/git_config.rb +1 -1
- data/lib/overcommit/hook_context/base.rb +3 -1
- data/lib/overcommit/hook_context/diff.rb +37 -0
- data/lib/overcommit/hook_context.rb +2 -2
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/commit-msg +2 -8
- data/template-dir/hooks/overcommit-hook +2 -8
- data/template-dir/hooks/post-checkout +2 -8
- data/template-dir/hooks/post-commit +2 -8
- data/template-dir/hooks/post-merge +2 -8
- data/template-dir/hooks/post-rewrite +2 -8
- data/template-dir/hooks/pre-commit +2 -8
- data/template-dir/hooks/pre-push +2 -8
- data/template-dir/hooks/pre-rebase +2 -8
- data/template-dir/hooks/prepare-commit-msg +2 -8
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5294dbf6a9c2979b0cc06483c7db55887ad4e62095f14258cbfdd2efadecdee
|
4
|
+
data.tar.gz: 0cda279207d7551cc87b89f4e8c928f5041463996b9ea77f2feebd64dcb2da3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 471264205b4f078dfe3453cedc209f3723cd31a1139cd9da7c30a36740730eceba813fbb69364e08e03ecb4ec25dd8e19109b41556b8df58fd0e9cd361ac40d2
|
7
|
+
data.tar.gz: 72bec31dcc6cea0510dd21bf6371997c88e591b7330b4e5ff985cc8c8616f1cbe5a674d5201a3a4c435ce23de3afbfa221eb96a3e2c51f984ff524b70068176d
|
data/lib/overcommit/cli.rb
CHANGED
@@ -9,6 +9,7 @@ module Overcommit
|
|
9
9
|
class CLI # rubocop:disable Metrics/ClassLength
|
10
10
|
def initialize(arguments, input, logger)
|
11
11
|
@arguments = arguments
|
12
|
+
@cli_options = {}
|
12
13
|
@input = input
|
13
14
|
@log = logger
|
14
15
|
@options = {}
|
@@ -28,6 +29,8 @@ module Overcommit
|
|
28
29
|
sign
|
29
30
|
when :run_all
|
30
31
|
run_all
|
32
|
+
when :diff
|
33
|
+
diff
|
31
34
|
end
|
32
35
|
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => e
|
33
36
|
puts e
|
@@ -45,7 +48,7 @@ module Overcommit
|
|
45
48
|
@parser = create_option_parser
|
46
49
|
|
47
50
|
begin
|
48
|
-
@parser.parse!(@arguments)
|
51
|
+
@parser.parse!(@arguments, into: @cli_options)
|
49
52
|
|
50
53
|
# Default action is to install
|
51
54
|
@options[:action] ||= :install
|
@@ -98,6 +101,11 @@ module Overcommit
|
|
98
101
|
@options[:action] = :run_all
|
99
102
|
@options[:hook_to_run] = arg ? arg.to_s : 'run-all'
|
100
103
|
end
|
104
|
+
|
105
|
+
opts.on('--diff [ref]', 'Run pre_commit hooks against the diff between a given ref. Defaults to `main`.') do |arg| # rubocop:disable Layout/LineLength
|
106
|
+
@options[:action] = :diff
|
107
|
+
arg
|
108
|
+
end
|
101
109
|
end
|
102
110
|
|
103
111
|
def add_other_options(opts)
|
@@ -209,6 +217,19 @@ module Overcommit
|
|
209
217
|
halt(status ? 0 : 65)
|
210
218
|
end
|
211
219
|
|
220
|
+
def diff
|
221
|
+
empty_stdin = File.open(File::NULL) # pre-commit hooks don't take input
|
222
|
+
context = Overcommit::HookContext.create('diff', config, @arguments, empty_stdin, **@cli_options) # rubocop:disable Layout/LineLength
|
223
|
+
config.apply_environment!(context, ENV)
|
224
|
+
|
225
|
+
printer = Overcommit::Printer.new(config, log, context)
|
226
|
+
runner = Overcommit::HookRunner.new(config, log, context, printer)
|
227
|
+
|
228
|
+
status = runner.run
|
229
|
+
|
230
|
+
halt(status ? 0 : 65)
|
231
|
+
end
|
232
|
+
|
212
233
|
# Used for ease of stubbing in tests
|
213
234
|
def halt(status = 0)
|
214
235
|
exit status
|
@@ -18,10 +18,12 @@ module Overcommit::HookContext
|
|
18
18
|
# @param config [Overcommit::Configuration]
|
19
19
|
# @param args [Array<String>]
|
20
20
|
# @param input [IO] standard input stream
|
21
|
-
|
21
|
+
# @param options [Hash] cli options
|
22
|
+
def initialize(config, args, input, **options)
|
22
23
|
@config = config
|
23
24
|
@args = args
|
24
25
|
@input = input
|
26
|
+
@options = options
|
25
27
|
end
|
26
28
|
|
27
29
|
# Executes a command as if it were a regular git hook, passing all
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'overcommit/git_repo'
|
4
|
+
|
5
|
+
module Overcommit::HookContext
|
6
|
+
# Simulates a pre-commit context based on the diff with another git ref.
|
7
|
+
#
|
8
|
+
# This results in pre-commit hooks running against the changes between the current
|
9
|
+
# and another ref, which is useful for automated CI scripts.
|
10
|
+
class Diff < Base
|
11
|
+
def modified_files
|
12
|
+
@modified_files ||= Overcommit::GitRepo.modified_files(refs: @options[:diff])
|
13
|
+
end
|
14
|
+
|
15
|
+
def modified_lines_in_file(file)
|
16
|
+
@modified_lines ||= {}
|
17
|
+
@modified_lines[file] ||= Overcommit::GitRepo.extract_modified_lines(file,
|
18
|
+
refs: @options[:diff])
|
19
|
+
end
|
20
|
+
|
21
|
+
def hook_class_name
|
22
|
+
'PreCommit'
|
23
|
+
end
|
24
|
+
|
25
|
+
def hook_type_name
|
26
|
+
'pre_commit'
|
27
|
+
end
|
28
|
+
|
29
|
+
def hook_script_name
|
30
|
+
'pre-commit'
|
31
|
+
end
|
32
|
+
|
33
|
+
def initial_commit?
|
34
|
+
@initial_commit ||= Overcommit::GitRepo.initial_commit?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
# Utility module which manages the creation of {HookContext}s.
|
4
4
|
module Overcommit::HookContext
|
5
|
-
def self.create(hook_type, config, args, input)
|
5
|
+
def self.create(hook_type, config, args, input, **cli_options)
|
6
6
|
hook_type_class = Overcommit::Utils.camel_case(hook_type)
|
7
7
|
underscored_hook_type = Overcommit::Utils.snake_case(hook_type)
|
8
8
|
|
9
9
|
require "overcommit/hook_context/#{underscored_hook_type}"
|
10
10
|
|
11
|
-
Overcommit::HookContext.const_get(hook_type_class).new(config, args, input)
|
11
|
+
Overcommit::HookContext.const_get(hook_type_class).new(config, args, input, **cli_options)
|
12
12
|
rescue LoadError, NameError => e
|
13
13
|
# Could happen when a symlink was created for a hook type Overcommit does
|
14
14
|
# not yet support.
|
data/lib/overcommit/version.rb
CHANGED
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
data/template-dir/hooks/pre-push
CHANGED
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -27,14 +27,8 @@ if hook_type == 'overcommit-hook'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
30
|
-
|
31
|
-
|
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
|
30
|
+
File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
|
31
|
+
gemfile = Regexp.last_match(1)
|
38
32
|
|
39
33
|
if gemfile
|
40
34
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.67.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-16 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: childprocess
|
@@ -48,16 +47,16 @@ dependencies:
|
|
48
47
|
name: rexml
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
50
49
|
requirements:
|
51
|
-
- - "
|
50
|
+
- - ">="
|
52
51
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
52
|
+
version: 3.3.9
|
54
53
|
type: :runtime
|
55
54
|
prerelease: false
|
56
55
|
version_requirements: !ruby/object:Gem::Requirement
|
57
56
|
requirements:
|
58
|
-
- - "
|
57
|
+
- - ">="
|
59
58
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
59
|
+
version: 3.3.9
|
61
60
|
description: Utility to install, configure, and extend Git hooks
|
62
61
|
email:
|
63
62
|
- shane@dasilva.io
|
@@ -262,6 +261,7 @@ files:
|
|
262
261
|
- lib/overcommit/hook_context.rb
|
263
262
|
- lib/overcommit/hook_context/base.rb
|
264
263
|
- lib/overcommit/hook_context/commit_msg.rb
|
264
|
+
- lib/overcommit/hook_context/diff.rb
|
265
265
|
- lib/overcommit/hook_context/helpers/file_modifications.rb
|
266
266
|
- lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb
|
267
267
|
- lib/overcommit/hook_context/post_checkout.rb
|
@@ -322,8 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
322
|
- !ruby/object:Gem::Version
|
323
323
|
version: '0'
|
324
324
|
requirements: []
|
325
|
-
rubygems_version: 3.
|
326
|
-
signing_key:
|
325
|
+
rubygems_version: 3.6.2
|
327
326
|
specification_version: 4
|
328
327
|
summary: Git hook manager
|
329
328
|
test_files: []
|