aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2017-02-27 08:18:11 +0000
committerGitHub2017-02-27 08:18:11 +0000
commit3d0d5d631e1c8c57a96c2515e0e61f6c6d9c7e46 (patch)
treec08fd030cca960e74bab72b59ce057684e554334 /Library
parente3f4701f385c286a2cc72c5d07870cc9a6ce0bf4 (diff)
parent928eaca26720fd38b07c1e7df3f9f567477d48db (diff)
downloadbrew-3d0d5d631e1c8c57a96c2515e0e61f6c6d9c7e46.tar.bz2
Merge pull request #2106 from naoty/exclude-executable-metafiles
Exclude executables from metafiles
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/pathname.rb4
-rw-r--r--Library/Homebrew/keg.rb4
-rw-r--r--Library/Homebrew/test/keg_spec.rb4
-rw-r--r--Library/Homebrew/test/pathname_spec.rb7
4 files changed, 17 insertions, 2 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 9f6861a9a..eb254c624 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -457,6 +457,10 @@ class Pathname
end
end
+ def ds_store?
+ basename.to_s == ".DS_Store"
+ end
+
# https://bugs.ruby-lang.org/issues/9915
if RUBY_VERSION == "2.0.0"
prepend Module.new {
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 94e3ff55b..9ebfc3bc3 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -207,8 +207,8 @@ class Keg
alias eql? ==
def empty_installation?
- Pathname.glob("#{path}/**/*") do |file|
- next if file.directory?
+ Pathname.glob("#{path}/*") do |file|
+ return false if file.directory? && !file.children.reject(&:ds_store?).empty?
basename = file.basename.to_s
next if Metafiles.copy?(basename)
next if %w[.DS_Store INSTALL_RECEIPT.json].include?(basename)
diff --git a/Library/Homebrew/test/keg_spec.rb b/Library/Homebrew/test/keg_spec.rb
index f40002dd2..3bf1257e6 100644
--- a/Library/Homebrew/test/keg_spec.rb
+++ b/Library/Homebrew/test/keg_spec.rb
@@ -60,6 +60,10 @@ describe Keg do
(keg/"bin").rmtree
expect(keg).to be_an_empty_installation
+
+ (keg/"bin").mkpath
+ touch keg.join("bin", "todo")
+ expect(keg).not_to be_an_empty_installation
end
specify "#oldname_opt_record" do
diff --git a/Library/Homebrew/test/pathname_spec.rb b/Library/Homebrew/test/pathname_spec.rb
index 6e7dc34aa..21e14479f 100644
--- a/Library/Homebrew/test/pathname_spec.rb
+++ b/Library/Homebrew/test/pathname_spec.rb
@@ -284,6 +284,13 @@ describe Pathname do
expect(dst/dir.basename).to be_a_directory
end
end
+
+ describe "#ds_store?" do
+ it "returns whether a file is .DS_Store or not" do
+ expect(file).not_to be_ds_store
+ expect(file/".DS_Store").to be_ds_store
+ end
+ end
end
describe FileUtils do