Module: Kintsugi
- Defined in:
- lib/kintsugi.rb,
lib/kintsugi/cli.rb,
lib/kintsugi/version.rb,
lib/kintsugi/apply_change_to_project.rb
Defined Under Namespace
Class Method Summary collapse
-
.apply_change_to_project(project, change) ⇒ void
Applies the change specified by
changetoproject. -
.resolve_conflicts(project_file_path, changes_output_path) ⇒ void
Resolves git conflicts of a pbxproj file specified by
project_file_path. -
.three_way_merge(base_project_path, ours_project_path, theirs_project_path, original_project_path) ⇒ void
Merges the changes done between
theirs_project_pathandbase_project_pathto the file atours_project_path.
Class Method Details
.apply_change_to_project(project, change) ⇒ void
This method returns an undefined value.
Applies the change specified by change to project.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kintsugi/apply_change_to_project.rb', line 23 def apply_change_to_project(project, change) # We iterate over the main group and project references first because they might create file # or project references that are referenced in other parts. unless change["rootObject"]["mainGroup"].nil? if project.root_object.main_group.nil? puts "Warning: Main group doesn't exist, ignoring changes to it." else apply_change_to_component(project.root_object, "mainGroup", change["rootObject"]["mainGroup"]) end end unless change["rootObject"]["projectReferences"].nil? apply_change_to_component(project.root_object, "projectReferences", change["rootObject"]["projectReferences"]) end apply_change_to_component(project, "rootObject", change["rootObject"].reject { |key| %w[mainGroup projectReferences].include?(key) }) end |
.resolve_conflicts(project_file_path, changes_output_path) ⇒ void
This method returns an undefined value.
Resolves git conflicts of a pbxproj file specified by project_file_path.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kintsugi.rb', line 30 def resolve_conflicts(project_file_path, changes_output_path) validate_project(project_file_path) project_in_temp_directory = open_project_of_current_commit_in_temporary_directory(project_file_path) change = change_of_conflicting_commit_with_parent(project_file_path) if changes_output_path File.write(changes_output_path, JSON.pretty_generate(change)) end apply_change_and_copy_to_original_path(project_in_temp_directory, change, project_file_path) end |
.three_way_merge(base_project_path, ours_project_path, theirs_project_path, original_project_path) ⇒ void
This method returns an undefined value.
Merges the changes done between theirs_project_path and base_project_path to the file at ours_project_path. The files may not be at the original path, and therefore the original_project_path is required in order for the project metadata to be written properly.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kintsugi.rb', line 65 def three_way_merge(base_project_path, ours_project_path, theirs_project_path, original_project_path) original_directory_name = File.basename(File.dirname(original_project_path)) base_temporary_project = copy_project_to_temporary_path_in_directory_with_name(base_project_path, original_directory_name) ours_temporary_project = copy_project_to_temporary_path_in_directory_with_name(ours_project_path, original_directory_name) theirs_temporary_project = copy_project_to_temporary_path_in_directory_with_name(theirs_project_path, original_directory_name) change = Xcodeproj::Differ.project_diff(theirs_temporary_project, base_temporary_project, :added, :removed) apply_change_and_copy_to_original_path(ours_temporary_project, change, ours_project_path) end |