Fix overly defensive handling of src parameter in make_relative_symlink
This method is for internal use only. It is unsuitable for use in formulae, which should use install_symlink to create relative symlinks. Thus callers are required to pass a Pathname, not a string, and we can remove this conditional. Further, if src is not absolute, then src.relative_path_from(dirname) will fail. All callers currently pass absolute pathnames. Therefore we don't need to call expand_path when printing it.
This commit is contained in:
parent
02a1d71871
commit
ed0be26c77
@ -291,8 +291,6 @@ class Pathname
|
|||||||
# perhaps confusingly, this Pathname object becomes the symlink pointing to
|
# perhaps confusingly, this Pathname object becomes the symlink pointing to
|
||||||
# the src paramter.
|
# the src paramter.
|
||||||
def make_relative_symlink src
|
def make_relative_symlink src
|
||||||
src = Pathname.new(src) unless src.kind_of? Pathname
|
|
||||||
|
|
||||||
self.dirname.mkpath
|
self.dirname.mkpath
|
||||||
Dir.chdir self.dirname do
|
Dir.chdir self.dirname do
|
||||||
# NOTE only system ln -s will create RELATIVE symlinks
|
# NOTE only system ln -s will create RELATIVE symlinks
|
||||||
@ -300,7 +298,7 @@ class Pathname
|
|||||||
if not $?.success?
|
if not $?.success?
|
||||||
if symlink? && exist?
|
if symlink? && exist?
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
Could not symlink file: #{src.expand_path}
|
Could not symlink file: #{src}
|
||||||
Target #{self} already exists as a symlink to #{readlink}.
|
Target #{self} already exists as a symlink to #{readlink}.
|
||||||
If this file is from another formula, you may need to
|
If this file is from another formula, you may need to
|
||||||
`brew unlink` it. Otherwise, you may want to delete it.
|
`brew unlink` it. Otherwise, you may want to delete it.
|
||||||
@ -312,7 +310,7 @@ class Pathname
|
|||||||
EOS
|
EOS
|
||||||
elsif exist?
|
elsif exist?
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
Could not symlink file: #{src.expand_path}
|
Could not symlink file: #{src}
|
||||||
Target #{self} already exists. You may need to delete it.
|
Target #{self} already exists. You may need to delete it.
|
||||||
To force the link and overwrite all other conflicting files, do:
|
To force the link and overwrite all other conflicting files, do:
|
||||||
brew link --overwrite formula_name
|
brew link --overwrite formula_name
|
||||||
@ -325,12 +323,12 @@ class Pathname
|
|||||||
make_relative_symlink(src)
|
make_relative_symlink(src)
|
||||||
elsif !dirname.writable_real?
|
elsif !dirname.writable_real?
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
Could not symlink file: #{src.expand_path}
|
Could not symlink file: #{src}
|
||||||
#{dirname} is not writable. You should change its permissions.
|
#{dirname} is not writable. You should change its permissions.
|
||||||
EOS
|
EOS
|
||||||
else
|
else
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
Could not symlink file: #{src.expand_path}
|
Could not symlink file: #{src}
|
||||||
#{self} may already exist.
|
#{self} may already exist.
|
||||||
#{dirname} may not be writable.
|
#{dirname} may not be writable.
|
||||||
EOS
|
EOS
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user