Skip to content

Commit

Permalink
Merge pull request #4 from mattlqx/cookbook-metadata
Browse files Browse the repository at this point in the history
fix cookbook change stack push
  • Loading branch information
mattlqx authored Mar 22, 2019
2 parents 3174744 + c705ddc commit 7a1971a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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.2.2
rev: v1.2.3
hooks:
- id: rubocop
- id: foodcritic
Expand Down
4 changes: 3 additions & 1 deletion bin/cookbook-wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def file_from_git_history(branch, path)
prefix = path.start_with?('/') ? '' : './'
from_branch = IO.popen("git show origin/#{branch}:#{prefix}#{path}", err: :close, &:read)
return from_branch unless from_branch == ''

IO.popen("git show origin/master:#{prefix}#{path}", err: :close, &:read)
end

Expand Down Expand Up @@ -87,7 +88,8 @@ def method_missing(sym, *args, &_block) # rubocop:disable Metrics/AbcSize, Style
changed_cookbooks = []
ARGV.each do |file|
cookbook, type = metadata_walk(file)
next if changed_cookbooks.include?(cookbook)
next if changed_cookbooks.map(&:first).include?(cookbook)

changed_cookbooks << [cookbook, type] if bump_required?(file)
end

Expand Down

0 comments on commit 7a1971a

Please sign in to comment.