@@ -34,6 +34,8 @@ def test_unextract_an_extraction
34
34
]
35
35
36
36
refute Dir . exist? "foo"
37
+ refute File . exist? "README.md"
38
+
37
39
assert File . exist? "qux"
38
40
assert File . exist? "lib/foo/bar"
39
41
assert File . exist? "lib/foo/baz"
@@ -129,6 +131,68 @@ def test_reinsert_when_code_extractor_was_not_used
129
131
]
130
132
131
133
refute Dir . exist? "foo"
134
+ refute File . exist? "README.md"
135
+
136
+ assert File . exist? "qux"
137
+ assert File . exist? "lib/foo/bar"
138
+ assert File . exist? "lib/foo/baz"
139
+ end
140
+ end
141
+
142
+ # Basically, a test to ensure we are using a rebase and not a cherry-pick
143
+ # method, since `git cherry-pick` doesn't handle merge commits well.
144
+ def test_reinsert_when_there_is_a_merge_commit
145
+ # original extraction to work off of, in which we "un-extract" this later
146
+ create_base_repo
147
+ set_extractions [ "foo" ]
148
+ run_extraction
149
+
150
+ # Perform updates to extracted repo to simulate changes since extraction
151
+ perform_merges_of_extracted_code
152
+ apply_new_commits_on_extracted_repo do
153
+ checkout_b 'master' , 'origin/master'
154
+
155
+ update_file "foo/bar" , "Updated Bar Content"
156
+ commit "update bar content"
157
+
158
+ checkout_b 'add_baz' , 'master'
159
+
160
+ update_file "foo/baz" , "Baz Content"
161
+ commit "add new baz"
162
+
163
+ checkout 'master'
164
+ merge 'add_baz'
165
+
166
+ add_file "README.md" , "READ ME!"
167
+ commit "add README"
168
+ end
169
+ update_extraction_hash
170
+
171
+ # Run new extraction, with some extra commits added to the new repo that
172
+ # has been extracted previously
173
+ #
174
+ # This next line will run the actual extraction we are testing
175
+ #
176
+ # aka: updated commits and puts 'lib/foo' back into the original repo
177
+ run_extraction
178
+
179
+ in_git_dir do
180
+ assert_commits [
181
+ "Move foo/ into lib/" ,
182
+ "Merged branch 'add_baz' into master" ,
183
+ "add new baz" ,
184
+ "update bar content" ,
185
+ "Re-insert extractions from MyOrg/extracted_repo" ,
186
+ "Merged branch 'extract_my_extractions' into master" ,
187
+ "Extract my_extractions" ,
188
+ "Commit #3" ,
189
+ "add Bar content" ,
190
+ "Initial Commit"
191
+ ]
192
+
193
+ refute Dir . exist? "foo"
194
+ refute File . exist? "README.md"
195
+
132
196
assert File . exist? "qux"
133
197
assert File . exist? "lib/foo/bar"
134
198
assert File . exist? "lib/foo/baz"
@@ -170,6 +234,9 @@ def apply_new_commits_on_extracted_repo &block
170
234
171
235
update_file "foo/baz" , "Baz Content"
172
236
commit "add new baz"
237
+
238
+ add_file "README.md" , "READ ME!"
239
+ commit "add README"
173
240
end
174
241
end
175
242
0 commit comments