Skip to content

Commit 1fc521c

Browse files
jlogsdontrotzig
authored andcommitted
Improve performance of Gemfile.lock ignore check for BundleAudit hook (sds#531)
* Improve performance of Gemfile.lock ignore check Listing ignored files in repositories with a lot of ignored files (such as build artifcats) can take a long time. * Split Gemfile.lock check over multiple lines
1 parent 5b14615 commit 1fc521c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/overcommit/hook/pre_commit/bundle_audit.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class BundleAudit < Base
77

88
def run
99
# Ignore if Gemfile.lock is not tracked by git
10-
ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n")
10+
ignored_files = execute(%W[git ls-files -o -i --exclude-standard -- #{LOCK_FILE}]).
11+
stdout.split("\n")
1112
return :pass if ignored_files.include?(LOCK_FILE)
1213

1314
result = execute(command)

spec/overcommit/hook/pre_commit/bundle_audit_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
end
2828

2929
before do
30-
subject.stub(:execute).with(%w[git ls-files -o -i --exclude-standard]).
30+
subject.stub(:execute).with(%w[git ls-files -o -i --exclude-standard -- Gemfile.lock]).
3131
and_return(double(stdout: ''))
3232
subject.stub(:execute).with(%w[bundle-audit]).and_return(result)
3333
end

0 commit comments

Comments
 (0)