overcommit 0.71.0 → 0.72.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5826d552313c4de8f5ee1f3f322e16d9193be5be215f4a1203deebd67e8b9333
4
- data.tar.gz: 1e013ca830726957ede05edefbeef7e2133851ea039bf819bdd0a22e506b94cb
3
+ metadata.gz: 05ab1b76d85aa96c6aac3359e74970e7dc186f2ca6ad72ef63c9cef40a0565da
4
+ data.tar.gz: 863bcdc512b59ddd25c6a03bf6b1f04a6337b00d74607476d0fa6cc1e09090f0
5
5
  SHA512:
6
- metadata.gz: 7ba0463239dcab4fc78aa972f17d374e205e261ad86bf4eebcbdf4e7bc08af0b8b3b1b601276e25d98f9b22c2cf2835e87ca007cfad50dbe54bbdf996f311a56
7
- data.tar.gz: 3c5338c547754f27157ee427ac1c25eed520b036e91e8f901ea31919b5278a9dc99909d10268f8da54e27a1fcdb76fca8c7f1b10e419b0512a2b9eba5ea976e6
6
+ metadata.gz: 2f5f4eb08a01da2c757bf7c2b1d1add5416aa9b8d7f79e3ac897986d1711b8ee2d0669d1b73cd644eb4d484b468c88cb7e21a0f3973d0535c347b3a1df4728f0
7
+ data.tar.gz: 7f17b6ae21fd95a05c31715c3d9d055f4ee6059f6a027ad144e1f4e128d6179fdc40c35666821287081be839c32be35109804065aa1e1074059690a38a029113
@@ -160,7 +160,10 @@ module Overcommit
160
160
  @merge_head = merge_head
161
161
  end
162
162
 
163
- merge_msg_file = File.expand_path('MERGE_MSG', Overcommit::Utils.git_dir)
163
+ merge_mode_file = Overcommit::Utils.git_path('MERGE_MODE')
164
+ @merge_mode = File.open(merge_mode_file).read if File.exist?(merge_mode_file)
165
+
166
+ merge_msg_file = Overcommit::Utils.git_path('MERGE_MSG')
164
167
  @merge_msg = File.open(merge_msg_file).read if File.exist?(merge_msg_file)
165
168
  end
166
169
 
@@ -182,17 +185,22 @@ module Overcommit
182
185
  # of a merge.
183
186
  def restore_merge_state
184
187
  if @merge_head
185
- FileUtils.touch(File.expand_path('MERGE_MODE', Overcommit::Utils.git_dir))
188
+ if @merge_mode
189
+ File.open(Overcommit::Utils.git_path('MERGE_MODE'), 'w') do |f|
190
+ f.write(@merge_mode)
191
+ end
192
+ @merge_mode = nil
193
+ end
186
194
 
187
- File.open(File.expand_path('MERGE_HEAD', Overcommit::Utils.git_dir), 'w') do |f|
195
+ File.open(Overcommit::Utils.git_path('MERGE_HEAD'), 'w') do |f|
188
196
  f.write(@merge_head)
189
197
  end
190
198
  @merge_head = nil
191
199
  end
192
200
 
193
201
  if @merge_msg
194
- File.open(File.expand_path('MERGE_MSG', Overcommit::Utils.git_dir), 'w') do |f|
195
- f.write("#{@merge_msg}\n")
202
+ File.open(Overcommit::Utils.git_path('MERGE_MSG'), 'w') do |f|
203
+ f.write(@merge_msg)
196
204
  end
197
205
  @merge_msg = nil
198
206
  end
@@ -202,8 +210,7 @@ module Overcommit
202
210
  # of a cherry-pick.
203
211
  def restore_cherry_pick_state
204
212
  if @cherry_head
205
- File.open(File.expand_path('CHERRY_PICK_HEAD',
206
- Overcommit::Utils.git_dir), 'w') do |f|
213
+ File.open(Overcommit::Utils.git_path('CHERRY_PICK_HEAD'), 'w') do |f|
207
214
  f.write(@cherry_head)
208
215
  end
209
216
  @cherry_head = nil
@@ -24,6 +24,14 @@ module Overcommit::Hook::PreCommit
24
24
  # Run the command for each file
25
25
  applicable_files.each do |file|
26
26
  result = execute(command, args: [file])
27
+ # flay exits non-zero both when it finds duplication (with output on
28
+ # stdout) and when it crashes internally. A crash leaves stdout empty
29
+ # and writes a backtrace to stderr, so treat that as an error instead
30
+ # of silently passing.
31
+ if !result.success? && result.stdout.strip.empty?
32
+ return :fail, result.stderr
33
+ end
34
+
27
35
  results = result.stdout.split("\n\n")
28
36
  results.shift
29
37
  unless results.empty?
@@ -10,7 +10,7 @@ module Overcommit
10
10
  #
11
11
  # @see https://github.com/castwide/solargraph
12
12
  class Solargraph < Base
13
- MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+)( -|:) /.freeze
13
+ MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+)(?: -|:) /.freeze
14
14
 
15
15
  def run
16
16
  result = execute(command, args: applicable_files)
@@ -74,6 +74,31 @@ module Overcommit
74
74
  end
75
75
  end
76
76
 
77
+ # Returns an absolute path to a file in the current worktree's Git
78
+ # directory.
79
+ #
80
+ # @param path [String]
81
+ # @return [String]
82
+ def git_path(path)
83
+ cmd = %w[git rev-parse]
84
+ if GIT_VERSION < '2.5'
85
+ cmd << '--git-dir'
86
+ else
87
+ cmd += ['--git-path', path]
88
+ end
89
+
90
+ result = execute(cmd)
91
+ unless result.success?
92
+ raise Overcommit::Exceptions::InvalidGitRepo,
93
+ 'Unable to determine Git path. ' \
94
+ 'Not a recognizable Git repository!'
95
+ end
96
+
97
+ resolved_path = result.stdout.chomp("\n")
98
+ resolved_path = File.join(resolved_path, path) if GIT_VERSION < '2.5'
99
+ File.expand_path(resolved_path, Dir.pwd)
100
+ end
101
+
77
102
  # Remove ANSI escape sequences from a string.
78
103
  #
79
104
  # This is useful for stripping colorized output from external tools.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.71.0'
5
+ VERSION = '0.72.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.71.0
4
+ version: 0.72.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 3.3.9
52
+ version: 3.4.2
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 3.3.9
59
+ version: 3.4.2
60
60
  description: Utility to install, configure, and extend Git hooks
61
61
  email:
62
62
  - shane@dasilva.io