From 02791d3e6514abb41407c4cc42f75e32339a8cca Mon Sep 17 00:00:00 2001 From: James Logsdon Date: Mon, 11 Dec 2017 14:11:04 -0500 Subject: [PATCH 1/2] 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. --- lib/overcommit/hook/pre_commit/bundle_audit.rb | 2 +- spec/overcommit/hook/pre_commit/bundle_audit_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/overcommit/hook/pre_commit/bundle_audit.rb b/lib/overcommit/hook/pre_commit/bundle_audit.rb index 73b79199..582e2b55 100644 --- a/lib/overcommit/hook/pre_commit/bundle_audit.rb +++ b/lib/overcommit/hook/pre_commit/bundle_audit.rb @@ -7,7 +7,7 @@ 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 From 2461583155cb975e34bf7a8db67a26bebf8ec357 Mon Sep 17 00:00:00 2001 From: James Logsdon Date: Mon, 11 Dec 2017 14:36:17 -0500 Subject: [PATCH 2/2] Split Gemfile.lock check over multiple lines --- lib/overcommit/hook/pre_commit/bundle_audit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/overcommit/hook/pre_commit/bundle_audit.rb b/lib/overcommit/hook/pre_commit/bundle_audit.rb index 582e2b55..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 -- #{LOCK_FILE}]).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)