overcommit 0.38.0 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6acb06db375fab15a3e54993b9dce2027bb50a4e
4
- data.tar.gz: 4738cd572e644f626e42100ff6e147e2d2f217fb
3
+ metadata.gz: 6e248dab5322fa00f20964aba130b5d37c4b9572
4
+ data.tar.gz: e67e895aad71be1c47474edf5a37f30100a5378a
5
5
  SHA512:
6
- metadata.gz: 18b93d2fca87325466f71ba3109852734549bf4f5126b430fa2d8a01cac5ed0b7b7c47e22cea709fc5cc80c2843ce86fcf2cfbc29ecca42b5a01546827493a37
7
- data.tar.gz: 9ceca9e9ae9e08ac83fcd9f50e869c6549f67468643bfbfdaec6ff82575c47d8caba9f99bff5a96a8146cd981a2df9cbc7e22192d4e5f3eb573fe8ce62103a27
6
+ metadata.gz: d01920e348b991fe2675a92d5f6b54ce3fc2691f9ffca7f22344be10c5ee3116a03e9137838c3944c01a5cc73b8a5f256a979e8b56214c202aa24d751e853796
7
+ data.tar.gz: e2fae65ea2dd8f37ffa1dfcf9ade533f74069413ca05aeb9382c1233400441fa95738cb302547a0f7fd7ce60e371ae9b1e2003ef4d671a241ad6221f6f724171
data/config/default.yml CHANGED
@@ -906,6 +906,12 @@ PrePush:
906
906
  required_executable: 'pytest'
907
907
  install_command: 'pip install -U pytest'
908
908
 
909
+ PythonNose:
910
+ enabled: false
911
+ description: 'Run nose test suite'
912
+ required_executable: 'nosetests'
913
+ install_command: 'pip install -U nose'
914
+
909
915
  RSpec:
910
916
  enabled: false
911
917
  description: 'Run RSpec test suite'
@@ -939,6 +945,10 @@ PrePush:
939
945
  flags: ['--exit-on-warn', '--quiet', '--summary']
940
946
  install_command: 'gem install brakeman'
941
947
 
948
+ GitLfs:
949
+ enabled: false
950
+ description: 'Upload files tracked by Git LFS'
951
+
942
952
  # Hooks that run during `git rebase`, before any commits are rebased.
943
953
  # If a hook fails, the rebase is aborted.
944
954
  PreRebase:
@@ -106,7 +106,8 @@ module Overcommit
106
106
  # @return [Array<String>] list of absolute file paths
107
107
  def list_files(paths = [], options = {})
108
108
  ref = options[:ref] || 'HEAD'
109
- `git ls-tree --name-only #{ref} "#{paths.join('" "')}"`.
109
+ path_list = paths.empty? ? '' : "\"#{paths.join('" "')}\""
110
+ `git ls-tree --name-only #{ref} #{path_list}`.
110
111
  split(/\n/).
111
112
  map { |relative_file| File.expand_path(relative_file) }.
112
113
  reject { |file| File.directory?(file) } # Exclude submodule directories
@@ -17,11 +17,13 @@ module Overcommit::Hook::CommitMsg
17
17
  expected_pattern_message = config['expected_pattern_message']
18
18
  sample_message = config['sample_message']
19
19
 
20
- [
21
- 'Commit message pattern mismatch.',
22
- "Expected : #{expected_pattern_message}",
23
- "Sample : #{sample_message}"
24
- ].join("\n") unless message =~ /#{pattern}/
20
+ unless message =~ /#{pattern}/
21
+ [
22
+ 'Commit message pattern mismatch.',
23
+ "Expected : #{expected_pattern_message}",
24
+ "Sample : #{sample_message}"
25
+ ].join("\n")
26
+ end
25
27
  end
26
28
  end
27
29
  end
@@ -19,12 +19,15 @@ module Overcommit::Hook::PreCommit
19
19
  def run
20
20
  result = execute(command, args: applicable_files)
21
21
  output = result.stdout.chomp
22
+ messages = output.split("\n").grep(/Warning|Error/)
23
+
24
+ return [:fail, result.stderr] if messages.empty? && !result.success?
22
25
  return :pass if result.success? && output.empty?
23
26
 
24
27
  # example message:
25
28
  # path/to/file.js: line 1, col 0, Error - Error message (ruleName)
26
29
  extract_messages(
27
- output.split("\n").grep(/Warning|Error/),
30
+ messages,
28
31
  /^(?<file>(?:\w:)?[^:]+):[^\d]+(?<line>\d+).*?(?<type>Error|Warning)/,
29
32
  lambda { |type| type.downcase.to_sym }
30
33
  )
@@ -0,0 +1,20 @@
1
+ module Overcommit::Hook::PrePush
2
+ # Invokes Git LFS command that uploads files tracked by Git LFS to the LFS storage
3
+ #
4
+ # @see https://git-lfs.github.com/
5
+ class GitLfs < Base
6
+ def run
7
+ unless in_path?('git-lfs')
8
+ return :warn, 'This repository is configured for Git LFS but \'git-lfs\' ' \
9
+ "was not found on your path.\nIf you no longer wish to use Git LFS, " \
10
+ 'disable this hook by removing or setting \'enabled: false\' for GitLFS ' \
11
+ 'hook in your .overcommit.yml file'
12
+ end
13
+
14
+ result = execute(['git', 'lfs', 'pre-push', remote_name, remote_url])
15
+ return :fail, result.stderr unless result.success?
16
+
17
+ :pass
18
+ end
19
+ end
20
+ end
@@ -21,6 +21,7 @@ module Overcommit::Hook::PrePush
21
21
 
22
22
  def protected?(remote_ref)
23
23
  ref_name = remote_ref[%r{refs/heads/(.*)}, 1]
24
+ return false if ref_name.nil?
24
25
  protected_branch_patterns.any? do |pattern|
25
26
  File.fnmatch(pattern, ref_name)
26
27
  end
@@ -0,0 +1,14 @@
1
+ module Overcommit::Hook::PrePush
2
+ # Runs `nose` test suite before push
3
+ #
4
+ # @see https://nose.readthedocs.io/en/latest/
5
+ class PythonNose < Base
6
+ def run
7
+ result = execute(command)
8
+ return :pass if result.success?
9
+
10
+ output = result.stdout + result.stderr
11
+ [:fail, output]
12
+ end
13
+ end
14
+ end
@@ -126,6 +126,12 @@ module Overcommit::HookContext
126
126
  @modified_lines[file]
127
127
  end
128
128
 
129
+ # Returns whether the current git branch is empty (has no commits).
130
+ def initial_commit?
131
+ return @initial_commit unless @initial_commit.nil?
132
+ @initial_commit = Overcommit::GitRepo.initial_commit?
133
+ end
134
+
129
135
  private
130
136
 
131
137
  # Clears the working tree so that the stash can be applied.
@@ -170,12 +176,6 @@ module Overcommit::HookContext
170
176
  modified_files.any?
171
177
  end
172
178
 
173
- # Returns whether the current git branch is empty (has no commits).
174
- def initial_commit?
175
- return @initial_commit unless @initial_commit.nil?
176
- @initial_commit = Overcommit::GitRepo.initial_commit?
177
- end
178
-
179
179
  # Stores the modification times for all modified files to make it appear like
180
180
  # they never changed.
181
181
  #
@@ -17,7 +17,7 @@ module Overcommit::HookContext
17
17
  end
18
18
  end
19
19
 
20
- PushedRef = Struct.new(:local_ref, :local_sha1, :remote_ref, :remote_sha1) do # rubocop:disable Metrics/BlockLength, Metrics/LineLength
20
+ PushedRef = Struct.new(:local_ref, :local_sha1, :remote_ref, :remote_sha1) do
21
21
  def forced?
22
22
  !(created? || deleted? || overwritten_commits.empty?)
23
23
  end
@@ -107,6 +107,9 @@ module Overcommit
107
107
 
108
108
  # Wait for a signal from another thread to try again
109
109
  @resource.wait(@lock)
110
+ else
111
+ # Otherwise there are not slots left, so just wait for signal
112
+ @resource.wait(@lock)
110
113
  end
111
114
  end
112
115
  end
@@ -36,6 +36,9 @@ module Overcommit
36
36
  install_hook_files
37
37
  install_starter_config
38
38
 
39
+ # Auto-sign configuration file on install
40
+ config(verify: false).update_signature!
41
+
39
42
  log.success "Successfully installed hooks into #{@target}"
40
43
  end
41
44
 
@@ -180,5 +183,10 @@ module Overcommit
180
183
  # doesn't exist. Standardize the behavior to return false.
181
184
  false
182
185
  end
186
+
187
+ # Returns the configuration for this repository.
188
+ def config(options = {})
189
+ Overcommit::ConfigurationLoader.new(log, options).load_repo_config
190
+ end
183
191
  end
184
192
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.38.0'.freeze
5
+ VERSION = '0.39.0'.freeze
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.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-24 00:00:00.000000000 Z
12
+ date: 2017-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.5.8
20
+ version: 0.6.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.5.8
27
+ version: 0.6.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: iniparse
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -172,9 +172,11 @@ files:
172
172
  - lib/overcommit/hook/pre_commit/yaml_syntax.rb
173
173
  - lib/overcommit/hook/pre_push/base.rb
174
174
  - lib/overcommit/hook/pre_push/brakeman.rb
175
+ - lib/overcommit/hook/pre_push/git_lfs.rb
175
176
  - lib/overcommit/hook/pre_push/minitest.rb
176
177
  - lib/overcommit/hook/pre_push/protected_branches.rb
177
178
  - lib/overcommit/hook/pre_push/pytest.rb
179
+ - lib/overcommit/hook/pre_push/python_nose.rb
178
180
  - lib/overcommit/hook/pre_push/r_spec.rb
179
181
  - lib/overcommit/hook/pre_push/rake_target.rb
180
182
  - lib/overcommit/hook/pre_push/test_unit.rb
@@ -244,9 +246,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
246
  version: '0'
245
247
  requirements: []
246
248
  rubyforge_project:
247
- rubygems_version: 2.4.5.1
249
+ rubygems_version: 2.6.11
248
250
  signing_key:
249
251
  specification_version: 4
250
252
  summary: Git hook manager
251
253
  test_files: []
252
- has_rdoc: