Minor fixes to prevent cookstyle running on too large of scope by mattlqx · Pull Request #8 · mattlqx/pre-commit-ruby · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pre-commit-hooks.yaml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To check Chef cookbook version bumps, use the `chef-cookbook-version` hook. Each
To unit test Ruby changes in your repo, use the `rspec` hook. Each path in your repo with a `spec` directory should have a `Gemfile` that includes your desired version of rspec (or a derivative library). It will be installed via Bundler prior to testing. Rspec will only be run against the closest directory in a changed file's path with a spec dir.

- repo: https://github.com/mattlqx/pre-commit-ruby
rev: v1.3.0
rev: v1.3.1
hooks:
- id: rubocop
- id: foodcritic
Expand Down
5 changes: 3 additions & 2 deletions bin/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def bump_required?(file)
end == true
end

def changed_cookbooks(bump_check: true)
def changed_cookbooks(paths = nil, bump_check: true)
changed_cookbooks = []
ARGV.each do |file|
paths ||= ARGV
paths.each do |file|
cookbook, type = metadata_walk(file)
next if cookbook == false || changed_cookbooks.map(&:first).include?(cookbook) || file.include?('/test/')

Expand Down
2 changes: 1 addition & 1 deletion bin/cookstyle-wrapper.rb