diff --git a/lib/overcommit/hook/pre_commit/bundle_audit.rb b/lib/overcommit/hook/pre_commit/bundle_audit.rb index 73b79199..2840a536 100644 --- a/lib/overcommit/hook/pre_commit/bundle_audit.rb +++ b/lib/overcommit/hook/pre_commit/bundle_audit.rb @@ -7,7 +7,8 @@ class BundleAudit < Base def run # Ignore if Gemfile.lock is not tracked by git - ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n") + ignored_files = execute(%W[git ls-files -o -i --exclude-standard -- #{LOCK_FILE}]). + stdout.split("\n") return :pass if ignored_files.include?(LOCK_FILE) result = execute(command) diff --git a/spec/overcommit/hook/pre_commit/bundle_audit_spec.rb b/spec/overcommit/hook/pre_commit/bundle_audit_spec.rb index 09370ae7..44626412 100644 --- a/spec/overcommit/hook/pre_commit/bundle_audit_spec.rb +++ b/spec/overcommit/hook/pre_commit/bundle_audit_spec.rb @@ -27,7 +27,7 @@ end before do - subject.stub(:execute).with(%w[git ls-files -o -i --exclude-standard]). + subject.stub(:execute).with(%w[git ls-files -o -i --exclude-standard -- Gemfile.lock]). and_return(double(stdout: '')) subject.stub(:execute).with(%w[bundle-audit]).and_return(result) end