diff options
| author | Jack Nagel | 2014-03-27 09:35:10 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-03-27 09:35:10 -0500 |
| commit | e9ee6400242b6137a627f803897e50b403ea976d (patch) | |
| tree | 149b30cc41b76a8abd805c0166fcb9aad94cb7df /Library/Homebrew | |
| parent | f6b5c83482b9ebbd390831f41767f9dd9b33162f (diff) | |
| download | brew-e9ee6400242b6137a627f803897e50b403ea976d.tar.bz2 | |
Don't let broken symlinks halt linking
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_keg.rb | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 1ec35b9cd..dd95cc789 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -298,7 +298,7 @@ class Pathname # NOTE only system ln -s will create RELATIVE symlinks quiet_system 'ln', '-s', src.relative_path_from(self.dirname), self.basename if not $?.success? - if symlink? && exist? || symlink? + if symlink? && exist? raise <<-EOS.undent Could not symlink file: #{src.expand_path} Target #{self} already exists as a symlink to #{readlink}. @@ -320,6 +320,9 @@ class Pathname To list all files that would be deleted: brew link --overwrite --dry-run formula_name EOS + elsif symlink? + unlink + make_relative_symlink(src) elsif !dirname.writable_real? raise <<-EOS.undent Could not symlink file: #{src.expand_path} diff --git a/Library/Homebrew/test/test_keg.rb b/Library/Homebrew/test/test_keg.rb index d9cce89fa..6d1790ae1 100644 --- a/Library/Homebrew/test/test_keg.rb +++ b/Library/Homebrew/test/test_keg.rb @@ -60,6 +60,11 @@ class LinkTests < Test::Unit::TestCase end end + def test_link_ignores_broken_symlinks_at_target + ln_s "/some/nonexistent/path", HOMEBREW_PREFIX/"bin/helloworld" + shutup { @keg.link } + end + def test_link_overwrite touch HOMEBREW_PREFIX/"bin/helloworld" @mode.overwrite = true |
