Smarter way of finding out if a file/folder was being tracked by the xcodeproj or not. Way less efficient, but doesn't fail like the old way did.

This commit is contained in:
Mark Larsen
2014-06-23 13:12:04 -07:00
parent a998a04b04
commit 8210321301
3 changed files with 26 additions and 9 deletions

View File

@@ -35,7 +35,7 @@ module Xcodeproj
Synx::Tabber.increase
Dir[real_path.to_s + "/{*,.*}"].each do |entry|
entry_pathname = real_path + entry
unless has_entry?(entry_pathname)
unless project.has_object_for_pathname?(entry_pathname)
handle_unused_entry(entry_pathname)
end
end
@@ -50,13 +50,6 @@ module Xcodeproj
end
private :sync_path
def has_entry?(entry_pathname)
%W(. ..).include?(entry_pathname.basename.to_s) || children.any? do |child|
child.real_path.cleanpath == entry_pathname.realpath.cleanpath
end
end
private :has_entry?
def all_groups
groups | version_groups | variant_groups
end
@@ -73,7 +66,7 @@ module Xcodeproj
work_entry_pathname = project.pathname_to_work_pathname(entry_pathname)
# The directory may have already been created for one of two reasons
# 1. It was created as a piece of another path, ie, /this/middle/directory.mkdir got called.
# 2. OS X has case insensitive folder names, so has_entry may have failed to notice it had the folder.
# 2. OS X has case insensitive folder names, so has_object_for_pathname? may have failed to notice it had the folder.
work_entry_pathname.mkdir unless work_entry_pathname.exist?
# recurse
Synx::Tabber.puts entry_pathname.basename.to_s.green

View File

@@ -108,6 +108,11 @@ module Synx
@group_exclusions = new_exclusions
end
def has_object_for_pathname?(pathname)
@unmodified_project ||= Synx::Project.open(path)
@unmodified_project.objects.any? { |o| begin o.real_path.cleanpath == pathname.cleanpath rescue false end }
end
end
end

View File

@@ -89,6 +89,7 @@
8C848C65190DB9B300E9727B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
8C848C67190DB9B300E9727B /* dummyTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = dummyTests.m; sourceTree = "<group>"; };
8CADDD3A19354F120076033B /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = "<group>"; };
8CD2ABF219558D7800341C58 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizable.strings; sourceTree = "<group>"; };
8CDA046319374F35004435A1 /* data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = data.json; path = FolderWithGroupNotLinked/data.json; sourceTree = "<group>"; };
8CE2DA1D19220F7B00D06F5E /* dummyTests-prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dummyTests-prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -206,6 +207,7 @@
8C848C4E190DB9B300E9727B /* Supporting Files */ = {
isa = PBXGroup;
children = (
8CD2ABF019558D4100341C58 /* en.lproj */,
8C848C4F190DB9B300E9727B /* dummy-Prefix.pch */,
);
name = "Supporting Files";
@@ -247,6 +249,14 @@
name = Resources;
sourceTree = "<group>";
};
8CD2ABF019558D4100341C58 /* en.lproj */ = {
isa = PBXGroup;
children = (
8CD2ABF119558D7800341C58 /* Localizable.strings */,
);
path = en.lproj;
sourceTree = "<group>";
};
8CDA046219374F15004435A1 /* FolderWithGroupNotLinked */ = {
isa = PBXGroup;
children = (
@@ -375,6 +385,14 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
8CD2ABF119558D7800341C58 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
8CD2ABF219558D7800341C58 /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
@@ -557,6 +575,7 @@
8CDA046C1937DDAA004435A1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */