Track makes entries in .manifest

When a user tracks a file or directory that is in
a nested folder, Homesick creates a .manifest in the
user's castle (if there isn't one already) and adds
an entry listing the file or directory's parent
directory (if it isn't already listed).
This commit is contained in:
Eric West
2013-05-24 07:52:54 -05:00
parent 7332aa4acd
commit b93eea0e24
2 changed files with 38 additions and 0 deletions

View File

@@ -134,6 +134,15 @@ class Homesick < Thor
inside castle_path do
git_add absolute_path
end
# are we tracking something nested? Add the parent dir to the manifest unless its already listed
unless relative_dir.eql?(Pathname.new('.'))
manifest_path = Pathname.new(repos_dir.join(castle, '.manifest'))
File.open(manifest_path, 'a+') do |manifest|
manifest.puts relative_dir unless manifest.readlines.inject(false) { |memo, line| line.eql?("#{relative_dir.to_s}\n") || memo }
end
end
end
desc "list", "List cloned castles"