overcommit 0.74.0 → 0.75.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: 429fa7e31530c84fe84b624201dfb77296f31fd34be4e1fb10a354b3dc4ce9ff
4
- data.tar.gz: ab2319699f8e677cab7ed3dc24854e12a7b6cfe7a911b9bcab3b8c2a82bead10
3
+ metadata.gz: 825a9ffd0ad7bacf35ecb3901ead1f1249085cad5536314434e89ce5ff802d15
4
+ data.tar.gz: f4d3ea4ecbc7d2fe7d2c35e1dd4d44f86e30a2e31ba241366735937952a95c30
5
5
  SHA512:
6
- metadata.gz: 3d7967d9579fb937a29a851157f4d74d620fe7e4fc3841b63a33bff84809038a49326a1d148fbe57872b1e90e42558b04027901d0193968626d74e72230ba3f5
7
- data.tar.gz: a21c06966bdf3817034b98f4d7f06a0810a522d9234534402fc3ec77abbf26d22278e25fc42741c88d9a693ef27d0fab8c7d029e6a979e596710d7cf1952abd6
6
+ metadata.gz: 590bcf4bdb5bb506425bbc41050adaa16311baa45f37071d1ffc0a9d96412f508f552eeea2278946bbab622af3aa0a6d216d388c520e41804a4f4dc7ee69e381
7
+ data.tar.gz: 73222064a9fcc44930ae9c027c19bb851004d5d1000303854b52c2650ef52ef29177f783e9faa5e064717be3ea03e676512a1dd631ddf68f459acbeb46e08df4
@@ -163,10 +163,10 @@ module Overcommit
163
163
  end
164
164
 
165
165
  merge_mode_file = Overcommit::Utils.git_path('MERGE_MODE')
166
- @merge_mode = File.open(merge_mode_file).read if File.exist?(merge_mode_file)
166
+ @merge_mode = File.read(merge_mode_file) if File.exist?(merge_mode_file)
167
167
 
168
168
  merge_msg_file = Overcommit::Utils.git_path('MERGE_MSG')
169
- @merge_msg = File.open(merge_msg_file).read if File.exist?(merge_msg_file)
169
+ @merge_msg = File.read(merge_msg_file) if File.exist?(merge_msg_file)
170
170
  end
171
171
 
172
172
  # Store any relevant files that are present when repo is in the middle of a
@@ -1,70 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'overcommit/os'
4
- require 'overcommit/subprocess'
5
-
6
3
  module Overcommit::Utils
7
4
  # Utility functions for file IO.
8
5
  module FileUtils
9
6
  class << self
10
- # When the host OS is Windows, uses the `mklink` command to create an
11
- # NTFS symbolic link from `new_name` to `old_name`. Otherwise delegates
12
- # to `File.symlink`
13
7
  def symlink(old_name, new_name)
14
- return File.symlink(old_name, new_name) unless Overcommit::OS.windows?
15
-
16
- result = win32_mklink_cmd(old_name, new_name)
17
- result.status
8
+ File.symlink(old_name, new_name)
18
9
  end
19
10
 
20
- # When the host OS is Windows, uses the `dir` command to check whether
21
- # `file_name` is an NTFS symbolic link. Otherwise delegates to
22
- # `File.symlink`.
23
11
  def symlink?(file_name)
24
- return File.symlink?(file_name) unless Overcommit::OS.windows?
25
-
26
- result = win32_dir_cmd(file_name)
27
- win32_symlink?(result.stdout)
12
+ File.symlink?(file_name)
28
13
  end
29
14
 
30
- # When the host OS is Windows, uses the `dir` command to check whether
31
- # `link_name` is an NTFS symbolic link. If so, it parses the target from
32
- # the command output. Otherwise raises an `ArgumentError`. Delegates to
33
- # `File.readlink` if the host OS is not Windows.
34
15
  def readlink(link_name)
35
- return File.readlink(link_name) unless Overcommit::OS.windows?
36
-
37
- result = win32_dir_cmd(link_name)
38
-
39
- unless win32_symlink?(result.stdout)
40
- raise ArgumentError, "#{link_name} is not a symlink"
41
- end
42
-
43
- # Extract symlink target from output, which looks like:
44
- # 11/13/2012 12:53 AM <SYMLINK> mysymlink [C:\Windows\Temp\somefile.txt]
45
- result.stdout[/\[(.+)\]/, 1]
46
- end
47
-
48
- private
49
-
50
- def win32_dir_cmd(file_name)
51
- Overcommit::Subprocess.spawn(
52
- %W[cmd.exe /c dir #{win32_fix_pathsep(file_name)}]
53
- )
54
- end
55
-
56
- def win32_mklink_cmd(old_name, new_name)
57
- Overcommit::Subprocess.spawn(
58
- %W[cmd.exe /c mklink #{win32_fix_pathsep(new_name)} #{win32_fix_pathsep(old_name)}]
59
- )
60
- end
61
-
62
- def win32_fix_pathsep(path)
63
- path.tr(File::SEPARATOR, Overcommit::OS::SEPARATOR)
64
- end
65
-
66
- def win32_symlink?(dir_output)
67
- !(dir_output =~ /<SYMLINK>/).nil?
16
+ File.readlink(link_name)
68
17
  end
69
18
  end
70
19
  end
@@ -166,9 +166,12 @@ module Overcommit
166
166
  return if Process.ppid.zero?
167
167
 
168
168
  if OS.windows?
169
- `wmic process where ProcessId=#{Process.ppid} get CommandLine /FORMAT:VALUE`.
170
- strip.
171
- slice(/(?<=CommandLine=).+/)
169
+ result = execute([
170
+ 'powershell.exe', '-NoProfile', '-NonInteractive', '-Command',
171
+ "(Get-CimInstance Win32_Process -Filter 'ProcessId = #{Process.ppid}').CommandLine",
172
+ ])
173
+ command = result.stdout.strip
174
+ command if result.success? && !command.empty?
172
175
  elsif OS.cygwin?
173
176
  # Cygwin's `ps` command behaves differently than the traditional
174
177
  # Linux version, but a comparable `procps` is provided to compensate.
@@ -176,7 +179,7 @@ module Overcommit
176
179
  else
177
180
  `ps -ocommand= -p #{Process.ppid}`.chomp
178
181
  end
179
- rescue Errno::EPERM, Errno::ENOENT
182
+ rescue Errno::EPERM, Errno::ENOENT, ChildProcess::LaunchError
180
183
  # Process information may not be available, such as inside sandboxed environments
181
184
  nil
182
185
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.74.0'
5
+ VERSION = '0.75.0'
6
6
  end
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
@@ -27,7 +27,7 @@ if hook_type == 'overcommit-hook'
27
27
  end
28
28
 
29
29
  # Check if Overcommit should invoke a Bundler context for loading gems
30
- File.read('.overcommit.yml') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
30
+ File.read('.overcommit.yml', encoding: 'UTF-8') =~ /gemfile: (?:false|['"]?(.*)['"]?)/
31
31
  gemfile = Regexp.last_match(1)
32
32
 
33
33
  if gemfile
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.74.0
4
+ version: 0.75.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva