Skip to content
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 removal of simple value that's nil already. #16

Merged
merged 1 commit into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/kintsugi/apply_change_to_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,15 @@ def apply_removal_to_simple_attribute(old_value, change)
(old_value || {}).reject do |key, value|
if value != change[key]
raise "Trying to remove value #{change[key]} of hash with key #{key} but it changed " \
"to #{value}."
"to #{value}. This is considered a conflict that should be resolved manually."
end

change.key?(key)
end
when String
if old_value != change
raise "Value changed from #{old_value} to #{change}."
if old_value != change && !old_value.nil?
raise "Trying to remove value #{change}, but the existing value is #{old_value}. This " \
"is considered a conflict that should be resolved manually."
end

nil
Expand Down
19 changes: 19 additions & 0 deletions spec/kintsugi_apply_change_to_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,25 @@
expect(base_project).to be_equivalent_to_project(theirs_project)
end

it "removes attribute target changes from a project it was removed from already" do
base_project.root_object.attributes["TargetAttributes"] =
{"foo" => {"LastSwiftMigration" => "1140"}}
base_project.save

theirs_project = create_copy_of_project(base_project.path, "theirs")
theirs_project.root_object.attributes["TargetAttributes"]["foo"] = {}

ours_project = create_copy_of_project(base_project.path, "ours")
ours_project.root_object.attributes["TargetAttributes"]["foo"] = {}

changes_to_apply = get_diff(theirs_project, base_project)

described_class.apply_change_to_project(ours_project, changes_to_apply)
ours_project.save

expect(ours_project).to be_equivalent_to_project(theirs_project)
end

it "identifies subproject added in separate times" do
framework_filename = "baz"

Expand Down