deal with edge case: the parent and descendant are both listed in the manifest
This commit is contained in:
@@ -306,7 +306,7 @@ class Homesick < Thor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def symlink_each(castle, basedir, subdirs)
|
def symlink_each(castle, basedir, subdirs)
|
||||||
basedir = Pathname.new(basedir).expand_path
|
absolute_basedir = Pathname.new(basedir).expand_path
|
||||||
inside basedir do
|
inside basedir do
|
||||||
files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)}
|
files = Pathname.glob('{.*,*}').reject{|a| [".", ".."].include?(a.to_s)}
|
||||||
files.each do |path|
|
files.each do |path|
|
||||||
@@ -319,25 +319,23 @@ class Homesick < Thor
|
|||||||
# make ignore dirs
|
# make ignore dirs
|
||||||
ignore_dirs = []
|
ignore_dirs = []
|
||||||
subdirs.each do |subdir|
|
subdirs.each do |subdir|
|
||||||
splited_subdir = Pathname.new(subdir).split
|
# ignore all parent of each line in subdir file
|
||||||
ignore_dir = splited_subdir[0].to_s
|
Pathname.new(subdir).ascend do |p|
|
||||||
if ignore_dir == "." then
|
ignore_dirs.push(p)
|
||||||
ignore_dir = splited_subdir[1].to_s
|
|
||||||
end
|
end
|
||||||
ignore_dirs.push(ignore_dir)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# ignore dirs written in subdir file
|
# ignore dirs written in subdir file
|
||||||
matched = false
|
matched = false
|
||||||
ignore_dirs.each do |ignore_dir|
|
ignore_dirs.uniq.each do |ignore_dir|
|
||||||
if absolute_path == castle_home.join(ignore_dir)
|
if absolute_path == castle_home.join(ignore_dir)
|
||||||
matched = true
|
matched = true
|
||||||
next
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
next if matched
|
next if matched
|
||||||
|
|
||||||
relative_dir = basedir.relative_path_from(castle_home)
|
relative_dir = absolute_basedir.relative_path_from(castle_home)
|
||||||
home_path = home_dir.join(relative_dir).join(path)
|
home_path = home_dir.join(relative_dir).join(path)
|
||||||
ln_s absolute_path, home_path
|
ln_s absolute_path, home_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -148,6 +148,25 @@ describe "homesick" do
|
|||||||
home_dotdir.join(".some_dotfile").readlink.should == dotfile
|
home_dotdir.join(".some_dotfile").readlink.should == dotfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with '.config' and '.config/appA' in .homesick_subdir" do
|
||||||
|
let(:castle) { given_castle("glencairn", [".config", ".config/appA"]) }
|
||||||
|
it "can symlink under both of .config and .config/appA" do
|
||||||
|
config_dir = castle.directory(".config")
|
||||||
|
config_dotfile = config_dir.file(".some_dotfile")
|
||||||
|
appA_dir = config_dir.directory("appA")
|
||||||
|
appA_dotfile = appA_dir.file(".some_appfile")
|
||||||
|
|
||||||
|
homesick.symlink("glencairn")
|
||||||
|
|
||||||
|
home_config_dir = home.join(".config")
|
||||||
|
home_appA_dir = home_config_dir.join("appA")
|
||||||
|
home_config_dir.symlink?.should == false
|
||||||
|
home_config_dir.join(".some_dotfile").readlink.should == config_dotfile
|
||||||
|
home_appA_dir.symlink?.should == false
|
||||||
|
home_appA_dir.join(".some_appfile").readlink.should == appA_dotfile
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "list" do
|
describe "list" do
|
||||||
|
|||||||
Reference in New Issue
Block a user