kintsugi 0.7.1 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/kintsugi.gemspec +1 -1
- data/lib/kintsugi/apply_change_to_project.rb +54 -32
- data/lib/kintsugi/version.rb +1 -1
- data/lib/kintsugi/xcodeproj_extensions.rb +12 -0
- data/spec/kintsugi_apply_change_to_project_spec.rb +21 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b91e9f248374504482055ac67da839cd50a808dc6127f5c248a219cd6dfaa50
|
4
|
+
data.tar.gz: 57792bfd58532ecd09aba7e248b8614761202fd51ba1975537ecd337247e7028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 557bd57300f1320b986f4d017dde29779464d528b082ac8552ffbb67353f5d6569ed69861f6c3585ee150b93cb4fa760e1ba3babc32a91010b6cd24c792a3e5f
|
7
|
+
data.tar.gz: '0902141e6cb1342c97e3821f4c47e3a5a9bf6e5ef8ce6c0c60b95055c372087c553d4442a279ddfa9698a9ca74ada829025ef16556035fa2455da28497f55c4d'
|
data/kintsugi.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_dependency "tty-prompt", "~> 0"
|
26
|
-
spec.add_dependency "xcodeproj", ">= 1.19.0", "<= 1.
|
26
|
+
spec.add_dependency "xcodeproj", ">= 1.19.0", "<= 1.23.0"
|
27
27
|
|
28
28
|
spec.add_development_dependency "git", "~> 1.11"
|
29
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
@@ -281,7 +281,8 @@ module Kintsugi
|
|
281
281
|
end
|
282
282
|
|
283
283
|
if change["isa"]
|
284
|
-
component = replace_component_with_new_type(parent_component, attribute_name, change
|
284
|
+
component = replace_component_with_new_type(parent_component, attribute_name, change,
|
285
|
+
change_path)
|
285
286
|
change = change_for_component_of_new_type(component, change)
|
286
287
|
else
|
287
288
|
component = child_component(parent_component, change_name)
|
@@ -340,8 +341,9 @@ module Kintsugi
|
|
340
341
|
else
|
341
342
|
parent_component
|
342
343
|
end
|
344
|
+
parent_change_path = change_path.split("/")[0...-1].join("/")
|
343
345
|
add_child_to_component(non_object_list_parent, source_project_component.to_tree_hash,
|
344
|
-
|
346
|
+
parent_change_path)
|
345
347
|
component_at_path(non_object_list_parent.project, change_path)
|
346
348
|
end
|
347
349
|
|
@@ -381,9 +383,10 @@ module Kintsugi
|
|
381
383
|
end
|
382
384
|
end
|
383
385
|
|
384
|
-
def replace_component_with_new_type(parent_component, name_in_parent_component, change
|
386
|
+
def replace_component_with_new_type(parent_component, name_in_parent_component, change,
|
387
|
+
change_path)
|
385
388
|
old_component = parent_component.send(name_in_parent_component)
|
386
|
-
new_component = component_of_new_type(parent_component, change, old_component)
|
389
|
+
new_component = component_of_new_type(parent_component, change, old_component, change_path)
|
387
390
|
|
388
391
|
copy_attributes_to_new_component(old_component, new_component)
|
389
392
|
|
@@ -391,18 +394,32 @@ module Kintsugi
|
|
391
394
|
new_component
|
392
395
|
end
|
393
396
|
|
394
|
-
def component_of_new_type(parent_component, change, old_component)
|
397
|
+
def component_of_new_type(parent_component, change, old_component, change_path)
|
395
398
|
if change["isa"][:added] == "PBXFileReference"
|
396
|
-
|
399
|
+
source_project_component =
|
400
|
+
component_at_path(@change_source_project, change_path.split("/")[0...-1].join("/"))
|
401
|
+
if source_project_component.nil?
|
402
|
+
raise MergeError, "Couldn't find file reference in the project where the file should " \
|
403
|
+
"reside. The file's change is #{change}. Change path is #{change_path}"
|
404
|
+
end
|
405
|
+
|
397
406
|
case parent_component
|
398
407
|
when Xcodeproj::Project::XCBuildConfiguration
|
399
|
-
parent_component.base_configuration_reference =
|
408
|
+
parent_component.base_configuration_reference =
|
409
|
+
parent_component.project.group_or_file_at_path(
|
410
|
+
source_project_component.base_configuration_reference.hierarchy_path
|
411
|
+
.delete_prefix("/")
|
412
|
+
)
|
400
413
|
return parent_component.base_configuration_reference
|
401
414
|
when Xcodeproj::Project::PBXNativeTarget
|
402
|
-
parent_component.product_reference =
|
415
|
+
parent_component.product_reference = parent_component.project.group_or_file_at_path(
|
416
|
+
source_project_component.product_reference.hierarchy_path.delete_prefix("/")
|
417
|
+
)
|
403
418
|
return parent_component.product_reference
|
404
419
|
when Xcodeproj::Project::PBXBuildFile
|
405
|
-
parent_component.file_ref =
|
420
|
+
parent_component.file_ref = parent_component.project.group_or_file_at_path(
|
421
|
+
source_project_component.file_ref.hierarchy_path.delete_prefix("/")
|
422
|
+
)
|
406
423
|
return parent_component.file_ref
|
407
424
|
end
|
408
425
|
end
|
@@ -891,14 +908,19 @@ module Kintsugi
|
|
891
908
|
end
|
892
909
|
return if !Settings.allow_duplicates && !existing_subproject.nil?
|
893
910
|
|
894
|
-
|
911
|
+
source_project_subproject_reference = component_at_path(@change_source_project, change_path)
|
912
|
+
if source_project_subproject_reference.nil?
|
913
|
+
raise MergeError, "Project reference with change #{project_reference_change} doesn't " \
|
914
|
+
"exist in the source project. Change path is #{change_path}"
|
915
|
+
end
|
916
|
+
|
917
|
+
subproject_reference = root_object.project.files.find do |file_reference|
|
918
|
+
file_reference.hierarchy_path ==
|
919
|
+
source_project_subproject_reference.project_ref.hierarchy_path &&
|
895
920
|
root_object.project_references.find do |project_reference|
|
896
921
|
project_reference.project_ref.uuid == file_reference.uuid
|
897
922
|
end.nil?
|
898
923
|
end
|
899
|
-
subproject_reference =
|
900
|
-
find_file(root_object.project, project_reference_change["ProjectRef"]["path"],
|
901
|
-
file_filter: filter_subproject_without_project_references)
|
902
924
|
|
903
925
|
unless subproject_reference
|
904
926
|
raise MergeError, "No file reference was found for project reference with change " \
|
@@ -941,17 +963,29 @@ module Kintsugi
|
|
941
963
|
end
|
942
964
|
|
943
965
|
def add_file_reference(containing_component, change, change_path)
|
944
|
-
|
945
|
-
|
966
|
+
source_project_component =
|
967
|
+
component_at_path(@change_source_project, change_path.split("/")[0...-1].join("/"))
|
968
|
+
if source_project_component.nil?
|
969
|
+
raise MergeError, "Couldn't find file reference in the project where the file should " \
|
970
|
+
"reside. The file's change is #{change}. Change path is #{change_path}"
|
971
|
+
end
|
972
|
+
|
946
973
|
case containing_component
|
947
974
|
when Xcodeproj::Project::XCBuildConfiguration
|
948
975
|
containing_component.base_configuration_reference =
|
949
|
-
|
976
|
+
containing_component.project.group_or_file_at_path(
|
977
|
+
source_project_component.base_configuration_reference.hierarchy_path.delete_prefix("/")
|
978
|
+
)
|
950
979
|
when Xcodeproj::Project::PBXNativeTarget
|
951
980
|
containing_component.product_reference =
|
952
|
-
|
981
|
+
containing_component.project.group_or_file_at_path(
|
982
|
+
source_project_component.product_reference.hierarchy_path.delete_prefix("/")
|
983
|
+
)
|
953
984
|
when Xcodeproj::Project::PBXBuildFile
|
954
|
-
containing_component.file_ref =
|
985
|
+
containing_component.file_ref =
|
986
|
+
containing_component.project.group_or_file_at_path(
|
987
|
+
source_project_component.file_ref.hierarchy_path.delete_prefix("/")
|
988
|
+
)
|
955
989
|
when Xcodeproj::Project::PBXGroup
|
956
990
|
# Adding files to groups is handled by another part of the code.
|
957
991
|
else
|
@@ -1002,7 +1036,8 @@ module Kintsugi
|
|
1002
1036
|
add_child_to_component(component, change_value, change_path)
|
1003
1037
|
when Array
|
1004
1038
|
change_value.each do |added_attribute_element|
|
1005
|
-
add_child_to_component(component, added_attribute_element,
|
1039
|
+
add_child_to_component(component, added_attribute_element,
|
1040
|
+
"#{change_path}/#{change_name}")
|
1006
1041
|
end
|
1007
1042
|
else
|
1008
1043
|
raise MergeError, "Trying to add attribute of unsupported type '#{change_value.class}' " \
|
@@ -1017,19 +1052,6 @@ module Kintsugi
|
|
1017
1052
|
end.default_value
|
1018
1053
|
end
|
1019
1054
|
|
1020
|
-
def find_file(project, path, file_filter: ->(_) { true })
|
1021
|
-
file_references = project.files.select do |file_reference|
|
1022
|
-
file_reference.path == path && file_filter.call(file_reference)
|
1023
|
-
end
|
1024
|
-
if file_references.length > 1
|
1025
|
-
puts "Debug: Found more than one matching file with path '#{path}'. Using the first one."
|
1026
|
-
elsif file_references.empty?
|
1027
|
-
return
|
1028
|
-
end
|
1029
|
-
|
1030
|
-
file_references.first
|
1031
|
-
end
|
1032
|
-
|
1033
1055
|
def find_reference_proxy(project, change, reference_filter: ->(_) { true })
|
1034
1056
|
reference_proxies = project.root_object.project_references.map do |project_ref_and_products|
|
1035
1057
|
project_ref_and_products[:product_group].children.find do |reference_proxy|
|
data/lib/kintsugi/version.rb
CHANGED
@@ -113,6 +113,18 @@ module Xcodeproj
|
|
113
113
|
string.scan(/ *((['"]?).*?[^\\]\2)(?=( |\z))/).map(&:first)
|
114
114
|
end
|
115
115
|
end
|
116
|
+
|
117
|
+
# Modifies `PBXTargetDependency`'s `to_tree_hash` to not crash if `target_proxy` is `nil`.
|
118
|
+
# The same fix was done in https://github.com/CocoaPods/Xcodeproj/pull/915/.
|
119
|
+
class PBXTargetDependency
|
120
|
+
def to_tree_hash
|
121
|
+
hash = {}
|
122
|
+
hash['displayName'] = display_name
|
123
|
+
hash['isa'] = isa
|
124
|
+
hash['targetProxy'] = target_proxy.to_tree_hash if target_proxy
|
125
|
+
hash
|
126
|
+
end
|
127
|
+
end
|
116
128
|
end
|
117
129
|
end
|
118
130
|
|
@@ -585,6 +585,26 @@ describe Kintsugi, :apply_change_to_project do
|
|
585
585
|
expect(base_project).to be_equivalent_to_project(theirs_project)
|
586
586
|
end
|
587
587
|
|
588
|
+
it "keeps different files with the same name in their respective targets" do
|
589
|
+
file_reference = base_project.main_group.new_reference("file1.swift")
|
590
|
+
base_project.targets[0].source_build_phase.add_file_reference(file_reference)
|
591
|
+
|
592
|
+
base_project.new_target("com.apple.product-type.library.static", "bar", :ios)
|
593
|
+
base_project.main_group.find_subpath("new_group", true).new_reference("file1.swift")
|
594
|
+
base_project.save
|
595
|
+
|
596
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
597
|
+
second_target = theirs_project.targets[1]
|
598
|
+
second_file_reference = theirs_project.main_group.find_subpath("new_group/file1.swift")
|
599
|
+
second_target.source_build_phase.add_file_reference(second_file_reference)
|
600
|
+
|
601
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
602
|
+
|
603
|
+
described_class.apply_change_to_project(base_project, changes_to_apply, theirs_project)
|
604
|
+
expect(base_project).to be_equivalent_to_project(theirs_project)
|
605
|
+
expect(base_project.main_group.find_subpath("new_group/file1.swift").build_files).not_to be_empty
|
606
|
+
end
|
607
|
+
|
588
608
|
it "moves file that is referenced by a target from a group to the main group" do
|
589
609
|
file_reference = base_project.main_group.find_subpath("new_group", true).new_reference("bar")
|
590
610
|
base_project.targets[0].source_build_phase.add_file_reference(file_reference)
|
@@ -1764,7 +1784,7 @@ describe Kintsugi, :apply_change_to_project do
|
|
1764
1784
|
end
|
1765
1785
|
end
|
1766
1786
|
|
1767
|
-
describe "
|
1787
|
+
describe "resolving conflicts interactively" do
|
1768
1788
|
let(:test_prompt) { TTY::Prompt::Test.new }
|
1769
1789
|
|
1770
1790
|
before do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kintsugi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Yohay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 1.19.0
|
34
34
|
- - "<="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.
|
36
|
+
version: 1.23.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.19.0
|
44
44
|
- - "<="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.23.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: git
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
|
-
rubygems_version: 3.4.
|
187
|
+
rubygems_version: 3.4.20
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: pbxproj files git conflicts solver
|