kintsugi 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kintsugi/apply_change_to_project.rb +20 -3
- data/lib/kintsugi/version.rb +1 -1
- data/spec/kintsugi_apply_change_to_project_spec.rb +151 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9f20babc40a6ddf7228d2455e23d165a2d696929f5507fc8de0a9878353280f
|
4
|
+
data.tar.gz: 8ffd34dd7f504193c0a35d1347fa92c6edde6976602b5e62658ba9a637b6bc81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8477aaafe2a4afed13fce37f5a5963b79ab2d3e26e4816abf4cd7b082b5a9a09cd189260713bbd5f82eaf9f8f8227b92bcd5dc79ad90acf1c0cc5d4ee9e8971
|
7
|
+
data.tar.gz: d63cf3848b727c894a9c294b75023c46e12b5672f03144bb7068477edc7765372b2e5e586c03bc69560f71a8145b7c2b3074a5246a4726a965b98a87050a59cb
|
@@ -103,6 +103,12 @@ module Kintsugi
|
|
103
103
|
group_type = Module.const_get("Xcodeproj::Project::#{change["isa"]}")
|
104
104
|
containing_group = path.empty? ? project.main_group : project[path]
|
105
105
|
|
106
|
+
if containing_group.nil?
|
107
|
+
raise MergeError, "Trying to add or move a group with change #{change} to a group that " \
|
108
|
+
"no longer exists with path '#{path}'. This is considered a conflict that should be " \
|
109
|
+
"resolved manually."
|
110
|
+
end
|
111
|
+
|
106
112
|
next if !Settings.allow_duplicates &&
|
107
113
|
!find_group_in_group(containing_group, group_type, change).nil?
|
108
114
|
|
@@ -144,6 +150,12 @@ module Kintsugi
|
|
144
150
|
containing_group = path.empty? ? project.main_group : project[path]
|
145
151
|
change_key = file_reference_key(change)
|
146
152
|
|
153
|
+
if containing_group.nil?
|
154
|
+
raise MergeError, "Trying to add or move a file with change #{change} to a group that " \
|
155
|
+
"no longer exists with path '#{path}'. This is considered a conflict that should be " \
|
156
|
+
"resolved manually."
|
157
|
+
end
|
158
|
+
|
147
159
|
if (removal_keys_to_references[change_key] || []).empty?
|
148
160
|
apply_file_addition(containing_group, change, "rootObject/mainGroup/#{path}")
|
149
161
|
elsif addition_keys_to_paths[change_key].length == 1 &&
|
@@ -195,12 +207,17 @@ module Kintsugi
|
|
195
207
|
end
|
196
208
|
|
197
209
|
def apply_group_removals(project, removals)
|
198
|
-
removals.each do |change, path|
|
210
|
+
removals.sort_by(&:last).reverse.each do |change, path|
|
199
211
|
next unless %w[PBXGroup PBXVariantGroup].include?(change["isa"])
|
200
212
|
|
201
213
|
group_path = join_path(path, change["displayName"])
|
202
214
|
|
203
|
-
|
215
|
+
# by now we've deleted all of this group's children in the project, so we need to adapt the
|
216
|
+
# change to the expected current state of the group, that is, without any children.
|
217
|
+
change_without_children = change.dup
|
218
|
+
change_without_children["children"] = []
|
219
|
+
|
220
|
+
remove_component(project[group_path], change_without_children)
|
204
221
|
end
|
205
222
|
end
|
206
223
|
|
@@ -687,7 +704,7 @@ module Kintsugi
|
|
687
704
|
end
|
688
705
|
|
689
706
|
existing_build_file = build_phase.files.find do |build_file|
|
690
|
-
build_file.file_ref.path == change["fileRef"]["path"]
|
707
|
+
build_file.file_ref && build_file.file_ref.path == change["fileRef"]["path"]
|
691
708
|
end
|
692
709
|
return if !Settings.allow_duplicates && !existing_build_file.nil?
|
693
710
|
|
data/lib/kintsugi/version.rb
CHANGED
@@ -159,6 +159,59 @@ describe Kintsugi, :apply_change_to_project do
|
|
159
159
|
expect(base_project).to be_equivalent_to_project(theirs_project)
|
160
160
|
end
|
161
161
|
|
162
|
+
it "raises if trying to move file to another group that no longer exists" do
|
163
|
+
base_project.main_group.find_subpath("new_group", true)
|
164
|
+
base_project.save
|
165
|
+
|
166
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
167
|
+
new_group = theirs_project.main_group.find_subpath("new_group")
|
168
|
+
file_reference = theirs_project.main_group.find_file_by_path(filepath)
|
169
|
+
file_reference.move(new_group)
|
170
|
+
|
171
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
172
|
+
|
173
|
+
base_project.main_group.find_subpath("new_group").remove_from_project
|
174
|
+
|
175
|
+
expect {
|
176
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
177
|
+
}.to raise_error(Kintsugi::MergeError)
|
178
|
+
end
|
179
|
+
|
180
|
+
it "raises if trying to add file to a group that no longer exists" do
|
181
|
+
base_project.main_group.find_subpath("new_group", true)
|
182
|
+
base_project.save
|
183
|
+
|
184
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
185
|
+
theirs_project.main_group.find_subpath("new_group").new_reference("foo")
|
186
|
+
|
187
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
188
|
+
|
189
|
+
base_project.main_group.find_subpath("new_group").remove_from_project
|
190
|
+
|
191
|
+
expect {
|
192
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
193
|
+
}.to raise_error(Kintsugi::MergeError)
|
194
|
+
end
|
195
|
+
|
196
|
+
it "does nothing if trying to remove a file from a group that no longer exists" do
|
197
|
+
base_project.main_group.find_subpath("new_group", true).new_reference("foo")
|
198
|
+
base_project.save
|
199
|
+
|
200
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
201
|
+
theirs_project.main_group.find_subpath("new_group/foo").remove_from_project
|
202
|
+
|
203
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
204
|
+
|
205
|
+
base_project.main_group.find_subpath("new_group").remove_from_project
|
206
|
+
|
207
|
+
base_project.save
|
208
|
+
expected_project = create_copy_of_project(base_project.path, "expected")
|
209
|
+
|
210
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
211
|
+
|
212
|
+
expect(base_project).to be_equivalent_to_project(expected_project)
|
213
|
+
end
|
214
|
+
|
162
215
|
it "raises when a file is split into two" do
|
163
216
|
base_project.main_group.find_subpath("new_group", true)
|
164
217
|
base_project.main_group.find_subpath("new_group2", true)
|
@@ -203,6 +256,88 @@ describe Kintsugi, :apply_change_to_project do
|
|
203
256
|
expect(base_project).to be_equivalent_to_project(theirs_project)
|
204
257
|
end
|
205
258
|
|
259
|
+
it "moves a group with files in it" do
|
260
|
+
new_group = base_project.main_group.find_subpath("new_group", true)
|
261
|
+
new_group.new_reference("new_file")
|
262
|
+
base_project.save
|
263
|
+
|
264
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
265
|
+
new_group2 = theirs_project.main_group.find_subpath("new_group2", true)
|
266
|
+
theirs_project["new_group"].move(new_group2)
|
267
|
+
|
268
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
269
|
+
|
270
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
271
|
+
|
272
|
+
expect(base_project).to be_equivalent_to_project(theirs_project)
|
273
|
+
end
|
274
|
+
|
275
|
+
it "raises when trying to add a group to a group that no longer exists" do
|
276
|
+
base_project.main_group.find_subpath("new_group", true)
|
277
|
+
base_project.save
|
278
|
+
|
279
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
280
|
+
theirs_project["new_group"].find_subpath("sub_group", true)
|
281
|
+
|
282
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
283
|
+
|
284
|
+
base_project.main_group.find_subpath("new_group").remove_from_project
|
285
|
+
|
286
|
+
expect {
|
287
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
288
|
+
}.to raise_error(Kintsugi::MergeError)
|
289
|
+
end
|
290
|
+
|
291
|
+
it "raises when trying to move a group to a group that no longer exists" do
|
292
|
+
base_project.main_group.find_subpath("new_group", true)
|
293
|
+
base_project.main_group.find_subpath("other_group", true)
|
294
|
+
base_project.save
|
295
|
+
|
296
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
297
|
+
theirs_project["other_group"].move(theirs_project["new_group"])
|
298
|
+
|
299
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
300
|
+
|
301
|
+
base_project.main_group.find_subpath("new_group").remove_from_project
|
302
|
+
|
303
|
+
expect {
|
304
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
305
|
+
}.to raise_error(Kintsugi::MergeError)
|
306
|
+
end
|
307
|
+
|
308
|
+
it "moves a group with a group in it" do
|
309
|
+
new_group = base_project.main_group.find_subpath("new_group", true)
|
310
|
+
new_group.find_subpath("sub_group", true)
|
311
|
+
base_project.save
|
312
|
+
|
313
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
314
|
+
new_group2 = theirs_project.main_group.find_subpath("new_group2", true)
|
315
|
+
theirs_project["new_group"].move(new_group2)
|
316
|
+
|
317
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
318
|
+
|
319
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
320
|
+
|
321
|
+
expect(base_project).to be_equivalent_to_project(theirs_project)
|
322
|
+
end
|
323
|
+
|
324
|
+
it "moves a group with a group with a file in it" do
|
325
|
+
new_group = base_project.main_group.find_subpath("new_group", true)
|
326
|
+
sub_group = new_group.find_subpath("sub_group", true)
|
327
|
+
sub_group.new_reference("new_file")
|
328
|
+
base_project.save
|
329
|
+
|
330
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
331
|
+
new_group2 = theirs_project.main_group.find_subpath("new_group2", true)
|
332
|
+
theirs_project["new_group"].move(new_group2)
|
333
|
+
|
334
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
335
|
+
|
336
|
+
described_class.apply_change_to_project(base_project, changes_to_apply)
|
337
|
+
|
338
|
+
expect(base_project).to be_equivalent_to_project(theirs_project)
|
339
|
+
end
|
340
|
+
|
206
341
|
it "adds file with include in index and last known file type as nil" do
|
207
342
|
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
208
343
|
file_reference = theirs_project.main_group.new_reference("#{filepath}.h")
|
@@ -595,6 +730,22 @@ describe Kintsugi, :apply_change_to_project do
|
|
595
730
|
expect(base_project).to be_equivalent_to_project(theirs_project, ignore_keys: ["containerPortal"])
|
596
731
|
end
|
597
732
|
|
733
|
+
it "adds build when there is a build file without file ref" do
|
734
|
+
target = base_project.new_target("com.apple.product-type.library.static", "foo", :ios)
|
735
|
+
target.frameworks_build_phase.add_file_reference(nil)
|
736
|
+
base_project.save
|
737
|
+
|
738
|
+
theirs_project = create_copy_of_project(base_project.path, "theirs")
|
739
|
+
file_reference = theirs_project.main_group.new_reference("bar")
|
740
|
+
theirs_project.targets[0].frameworks_build_phase.add_file_reference(file_reference)
|
741
|
+
|
742
|
+
changes_to_apply = get_diff(theirs_project, base_project)
|
743
|
+
other_project = create_copy_of_project(base_project.path, "theirs")
|
744
|
+
described_class.apply_change_to_project(other_project, changes_to_apply)
|
745
|
+
|
746
|
+
expect(other_project).to be_equivalent_to_project(theirs_project)
|
747
|
+
end
|
748
|
+
|
598
749
|
it "adds product ref to build file" do
|
599
750
|
base_project.main_group.new_reference("bar")
|
600
751
|
base_project.save
|
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.6.
|
4
|
+
version: 0.6.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: 2022-
|
11
|
+
date: 2022-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.3.
|
171
|
+
rubygems_version: 3.3.26
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: pbxproj files git conflicts solver
|