Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for .git submodule files #7

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions lib/health_inspector/checklists/cookbooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def validate_changes_on_the_server_not_in_the_repo
path = cookbook_path.join("#{manifest_record["path"]}")

if path.exist?
checksum = checksum_cookbook_file(path)
messages << "#{manifest_record['path']}" if checksum != manifest_record['checksum']
if path.basename.to_s != '.git'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not make the first if a compound condition test a là if path.exist? && path.basename.to_s != '.git'? </nit>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to reproduce that submodule bug, but if you move the condition you end up in the else branch and it's probably not what you want.

In that case I would use a guard clause instead:

if path.exist?
  next if path.basename.to_s == '.git'

  checksum = checksum_cookbook_file(path)
  messages << "#{manifest_record['path']}" if checksum != manifest_record['checksum']
else

checksum = checksum_cookbook_file(path)
messages << "#{manifest_record['path']}" if checksum != manifest_record['checksum']
end
else
messages << "#{manifest_record['path']} does not exist in the repo"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/health_inspector/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module HealthInspector
VERSION = "0.6.2"
VERSION = "0.6.3"
end