From 53f7bef15a637bed21dab039366b2502369fcb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 28 Nov 2019 16:13:39 +0100 Subject: Extract git check logic to a method --- spec/support/path.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spec/support/path.rb b/spec/support/path.rb index 4b3941b70f..de08847ba9 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -30,23 +30,20 @@ module Spec end def tracked_files - if root != `git rev-parse --show-toplevel` - skip "not in git working directory" - end + skip "not in git working directory" unless git_root_dir? + @tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z` end def shipped_files - if root != `git rev-parse --show-toplevel` - skip "not in git working directory" - end + skip "not in git working directory" unless git_root_dir? + @shipped_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*` : `git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec` end def lib_tracked_files - if root != `git rev-parse --show-toplevel` - skip "not in git working directory" - end + skip "not in git working directory" unless git_root_dir? + @lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` end @@ -182,5 +179,11 @@ module Spec end extend self + + private + + def git_root_dir? + root == `git rev-parse --show-toplevel` + end end end -- cgit v1.2.1 From bb1981b1022f810af23653507071520ee1dd4520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 28 Nov 2019 16:14:49 +0100 Subject: Fix condition to verify root is a git directory --- spec/support/path.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/path.rb b/spec/support/path.rb index de08847ba9..3e42589f4d 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -183,7 +183,7 @@ module Spec private def git_root_dir? - root == `git rev-parse --show-toplevel` + root.to_s == `git rev-parse --show-toplevel`.chomp end end end -- cgit v1.2.1