-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apply_change_to_project: Fix adding subproject that already exist. #21
apply_change_to_project: Fix adding subproject that already exist. #21
Conversation
byohay
commented
Aug 3, 2021
- apply_change_to_project: Differentiate find file and reference proxy.
- apply_change_to_project: Fix adding existing subproject.
- Kintsugi: Fix adding build file to a file with multiple references.
Since the caller knows whether they need to find a file or a reference proxy it doesn't make sense to have all functions call the same methods.
6af0035
to
011552c
Compare
def find_file(project, file_reference_change) | ||
project.files.find do |file_reference| | ||
next file_reference.path == file_reference_change["path"] | ||
def find_file(project, file_reference_change, filter_file: ->(_) { true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe filter
or filter_with
or filter_closure
instead of filter_file
since it sounds like the parameter is a file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to file_filter
.
raise "Unsupported file reference change of type #{file_reference["isa"]}." | ||
def find_file(project, file_reference_change, filter_file: ->(_) { true }) | ||
file_references = project.files.select do |file_reference| | ||
next file_reference.path == file_reference_change["path"] && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is next
necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
end | ||
|
||
def find_reference_proxy(project, container_item_proxy_change) | ||
def find_reference_proxy(project, container_item_proxy_change, filter_reference: ->(_) { true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter_reference
is also confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
04ca906
to
0c6c1df
Compare
@ashdnazg squashed. |
When a subproject is added, its file reference is used in several places: - It's added to a `PBXGroup`. - It's added to the dictionary of project references under `projectRef`. - A new `PBXContainerItemProxy` is added and it refers to it under `containerPortal`. Beforehand, when a subproject that already exists was added, `find_file` would not be able to distinguish between the existing and new reference, and it might refer to it in all places mentioned above, which would make an invalid project file. To distinguish between them, the file reference that is used is the one that doesn't exist in the project references.
0c6c1df
to
4e5f7a6
Compare
# the other one without, this method will prefer to take the one without the build file. | ||
# This assumes that it's preferred to have a file reference with build file than a file | ||
# reference without/with two build files. | ||
filter_files_without_build_files = lambda do |reference| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not filter_reference_without_build_files
?
Previously, if two file references that refer to the same file existed, a build file's reference won't prefer one over the other. Even though it is legal, a 1:1 relationship between build file and file reference usually exist. Therefore the logic of adding a build file changes to prefer a file reference that has no build files.
4e5f7a6
to
ffb9654
Compare
@ashdnazg done. |