kintsugi 0.4.3 → 0.5.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/.github/workflows/release.yml +33 -0
- data/.github/workflows/{ci.yml → tests.yml} +2 -1
- data/.rubocop.yml +3 -0
- data/bin/kintsugi +3 -29
- data/kintsugi.gemspec +1 -0
- data/lib/kintsugi/apply_change_to_project.rb +264 -132
- data/lib/kintsugi/cli.rb +2 -1
- data/lib/kintsugi/merge.rb +146 -0
- data/lib/kintsugi/version.rb +1 -1
- data/lib/kintsugi/xcodeproj_extensions.rb +122 -0
- data/lib/kintsugi.rb +29 -148
- data/spec/kintsugi_apply_change_to_project_spec.rb +549 -52
- data/spec/kintsugi_integration_spec.rb +148 -0
- data/spec/spec_helper.rb +3 -0
- metadata +22 -5
@@ -0,0 +1,148 @@
|
|
1
|
+
# Copyright (c) 2021 Lightricks. All rights reserved.
|
2
|
+
# Created by Ben Yohay.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "git"
|
6
|
+
require "json"
|
7
|
+
require "rspec"
|
8
|
+
require "tempfile"
|
9
|
+
require "tmpdir"
|
10
|
+
|
11
|
+
require "kintsugi"
|
12
|
+
|
13
|
+
shared_examples "tests" do |git_command, project_name|
|
14
|
+
let(:temporary_directories_paths) { [] }
|
15
|
+
let(:git_directory_path) { make_temp_directory }
|
16
|
+
let(:git) { Git.init(git_directory_path) }
|
17
|
+
|
18
|
+
before do
|
19
|
+
git.config("user.email", "you@example.com")
|
20
|
+
git.config("user.name", "Your Name")
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
temporary_directories_paths.each do |directory_path|
|
25
|
+
FileUtils.remove_entry(directory_path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "running 'git #{git_command}' with project name '#{project_name}'" do
|
30
|
+
it "resolves conflicts with root command" do
|
31
|
+
File.write(File.join(git_directory_path, ".gitattributes"), "*.pbxproj merge=Unset")
|
32
|
+
|
33
|
+
project = create_new_project_at_path(File.join(git_directory_path, project_name))
|
34
|
+
|
35
|
+
git.add(File.join(git_directory_path, ".gitattributes"))
|
36
|
+
git.add(project.path)
|
37
|
+
git.commit("Initial project")
|
38
|
+
|
39
|
+
project.new_target("com.apple.product-type.library.static", "foo", :ios)
|
40
|
+
project.save
|
41
|
+
|
42
|
+
git.add(all: true)
|
43
|
+
git.commit("Add target foo")
|
44
|
+
first_commit_hash = git.revparse("HEAD")
|
45
|
+
|
46
|
+
git.checkout("HEAD^")
|
47
|
+
project = Xcodeproj::Project.open(project.path)
|
48
|
+
project.new_target("com.apple.product-type.library.static", "bar", :ios)
|
49
|
+
project.save
|
50
|
+
git.add(all: true)
|
51
|
+
git.commit("Add target bar")
|
52
|
+
|
53
|
+
`git -C #{git_directory_path} #{git_command} #{first_commit_hash} &> /dev/null`
|
54
|
+
Kintsugi.run([File.join(project.path, "project.pbxproj")])
|
55
|
+
|
56
|
+
project = Xcodeproj::Project.open(project.path)
|
57
|
+
expect(project.targets.map(&:display_name)).to contain_exactly("foo", "bar")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "resolves conflicts automatically with driver" do
|
61
|
+
git.config("merge.kintsugi.name", "Kintsugi driver")
|
62
|
+
git.config("merge.kintsugi.driver", "#{__dir__}/../bin/kintsugi driver %O %A %B %P")
|
63
|
+
File.write(File.join(git_directory_path, ".gitattributes"), "*.pbxproj merge=kintsugi")
|
64
|
+
|
65
|
+
project = create_new_project_at_path(File.join(git_directory_path, project_name))
|
66
|
+
|
67
|
+
git.add(File.join(git_directory_path, ".gitattributes"))
|
68
|
+
git.add(project.path)
|
69
|
+
git.commit("Initial project")
|
70
|
+
|
71
|
+
project.new_target("com.apple.product-type.library.static", "foo", :ios)
|
72
|
+
project.save
|
73
|
+
|
74
|
+
git.add(all: true)
|
75
|
+
git.commit("Add target foo")
|
76
|
+
first_commit_hash = git.revparse("HEAD")
|
77
|
+
|
78
|
+
git.checkout("HEAD^")
|
79
|
+
project = Xcodeproj::Project.open(project.path)
|
80
|
+
project.new_target("com.apple.product-type.library.static", "bar", :ios)
|
81
|
+
project.save
|
82
|
+
git.add(all: true)
|
83
|
+
git.commit("Add target bar")
|
84
|
+
|
85
|
+
`git -C #{git_directory_path} #{git_command} #{first_commit_hash} &> /dev/null`
|
86
|
+
|
87
|
+
project = Xcodeproj::Project.open(project.path)
|
88
|
+
expect(project.targets.map(&:display_name)).to contain_exactly("foo", "bar")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "keeps conflicts if failed to resolve conflicts" do
|
92
|
+
File.write(File.join(git_directory_path, ".gitattributes"), "*.pbxproj merge=Unset")
|
93
|
+
|
94
|
+
project = create_new_project_at_path(File.join(git_directory_path, project_name))
|
95
|
+
project.new_target("com.apple.product-type.library.static", "foo", :ios)
|
96
|
+
project.save
|
97
|
+
|
98
|
+
git.add(File.join(git_directory_path, ".gitattributes"))
|
99
|
+
git.add(project.path)
|
100
|
+
git.commit("Initial project")
|
101
|
+
|
102
|
+
project.targets[0].build_configurations.each do |configuration|
|
103
|
+
configuration.build_settings["PRODUCT_NAME"] = "bar"
|
104
|
+
end
|
105
|
+
project.save
|
106
|
+
git.add(all: true)
|
107
|
+
git.commit("Change target product name to bar")
|
108
|
+
first_commit_hash = git.revparse("HEAD")
|
109
|
+
|
110
|
+
git.checkout("HEAD^")
|
111
|
+
project = Xcodeproj::Project.open(project.path)
|
112
|
+
project.targets[0].build_configurations.each do |configuration|
|
113
|
+
configuration.build_settings["PRODUCT_NAME"] = "baz"
|
114
|
+
end
|
115
|
+
project.save
|
116
|
+
git.add(all: true)
|
117
|
+
git.commit("Change target product name to baz")
|
118
|
+
|
119
|
+
`git -C #{git_directory_path} #{git_command} #{first_commit_hash} &> /dev/null`
|
120
|
+
|
121
|
+
expect {
|
122
|
+
Kintsugi.run([File.join(project.path, "project.pbxproj")])
|
123
|
+
}.to raise_error(Kintsugi::MergeError)
|
124
|
+
expect(`git -C #{git_directory_path} diff --name-only --diff-filter=U`.chomp)
|
125
|
+
.to eq("#{project_name}/project.pbxproj")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def make_temp_directory
|
130
|
+
directory_path = Dir.mktmpdir
|
131
|
+
temporary_directories_paths << directory_path
|
132
|
+
directory_path
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def create_new_project_at_path(path)
|
137
|
+
project = Xcodeproj::Project.new(path)
|
138
|
+
project.save
|
139
|
+
project
|
140
|
+
end
|
141
|
+
|
142
|
+
describe Kintsugi, :kintsugi do
|
143
|
+
%w[rebase cherry-pick merge].each do |git_command|
|
144
|
+
["foo.xcodeproj", "foo with space.xcodeproj"].each do |project_name|
|
145
|
+
it_behaves_like("tests", git_command, project_name)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -44,6 +44,9 @@ RSpec.configure do |config|
|
|
44
44
|
mocks.verify_partial_doubles = true
|
45
45
|
end
|
46
46
|
|
47
|
+
config.filter_run focus: true
|
48
|
+
config.run_all_when_everything_filtered = true
|
49
|
+
|
47
50
|
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
48
51
|
# have no way to turn it off -- the option exists only for backwards
|
49
52
|
# compatibility in RSpec 3). It causes shared context metadata to be
|
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.
|
4
|
+
version: 0.5.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-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.21.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: git
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.11'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.11'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: rake
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +123,8 @@ executables:
|
|
109
123
|
extensions: []
|
110
124
|
extra_rdoc_files: []
|
111
125
|
files:
|
112
|
-
- ".github/workflows/
|
126
|
+
- ".github/workflows/release.yml"
|
127
|
+
- ".github/workflows/tests.yml"
|
113
128
|
- ".gitignore"
|
114
129
|
- ".rspec"
|
115
130
|
- ".rubocop.yml"
|
@@ -124,12 +139,14 @@ files:
|
|
124
139
|
- lib/kintsugi/apply_change_to_project.rb
|
125
140
|
- lib/kintsugi/cli.rb
|
126
141
|
- lib/kintsugi/error.rb
|
142
|
+
- lib/kintsugi/merge.rb
|
127
143
|
- lib/kintsugi/utils.rb
|
128
144
|
- lib/kintsugi/version.rb
|
129
145
|
- lib/kintsugi/xcodeproj_extensions.rb
|
130
146
|
- logo/kintsugi.png
|
131
147
|
- spec/be_equivalent_to_project.rb
|
132
148
|
- spec/kintsugi_apply_change_to_project_spec.rb
|
149
|
+
- spec/kintsugi_integration_spec.rb
|
133
150
|
- spec/spec_helper.rb
|
134
151
|
homepage: https://github.com/Lightricks/Kintsugi
|
135
152
|
licenses:
|
@@ -150,12 +167,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
167
|
- !ruby/object:Gem::Version
|
151
168
|
version: '0'
|
152
169
|
requirements: []
|
153
|
-
|
154
|
-
rubygems_version: 2.7.6.3
|
170
|
+
rubygems_version: 3.3.15
|
155
171
|
signing_key:
|
156
172
|
specification_version: 4
|
157
173
|
summary: pbxproj files git conflicts solver
|
158
174
|
test_files:
|
159
175
|
- spec/be_equivalent_to_project.rb
|
160
176
|
- spec/kintsugi_apply_change_to_project_spec.rb
|
177
|
+
- spec/kintsugi_integration_spec.rb
|
161
178
|
- spec/spec_helper.rb
|