esr-rim 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +40 -0
  3. data/README.md +3 -0
  4. data/Rakefile +56 -0
  5. data/bin/rim +3 -0
  6. data/lib/rim/command/command.rb +37 -0
  7. data/lib/rim/command/status.rb +110 -0
  8. data/lib/rim/command/sync.rb +69 -0
  9. data/lib/rim/command/upload.rb +33 -0
  10. data/lib/rim/command_helper.rb +119 -0
  11. data/lib/rim/dirty_check.rb +111 -0
  12. data/lib/rim/file_helper.rb +58 -0
  13. data/lib/rim/file_logger.rb +21 -0
  14. data/lib/rim/git.rb +339 -0
  15. data/lib/rim/manifest/helper.rb +82 -0
  16. data/lib/rim/manifest/json_reader.rb +40 -0
  17. data/lib/rim/manifest/manifest.json +7 -0
  18. data/lib/rim/manifest/model.rb +33 -0
  19. data/lib/rim/manifest/repo_reader.rb +61 -0
  20. data/lib/rim/module_helper.rb +52 -0
  21. data/lib/rim/module_info.rb +30 -0
  22. data/lib/rim/processor.rb +126 -0
  23. data/lib/rim/rev_status.rb +61 -0
  24. data/lib/rim/rim.rb +93 -0
  25. data/lib/rim/rim_exception.rb +15 -0
  26. data/lib/rim/rim_info.rb +129 -0
  27. data/lib/rim/status_builder.rb +219 -0
  28. data/lib/rim/sync_helper.rb +121 -0
  29. data/lib/rim/sync_module_helper.rb +115 -0
  30. data/lib/rim/upload_helper.rb +67 -0
  31. data/lib/rim/upload_module_helper.rb +152 -0
  32. data/lib/rim/version.rb +10 -0
  33. data/test/dirty_check_test.rb +210 -0
  34. data/test/file_helper_test.rb +132 -0
  35. data/test/git_test.rb +49 -0
  36. data/test/manifest_helper_test.rb +29 -0
  37. data/test/manifest_test_dir/manifest.rim +9 -0
  38. data/test/manifest_test_dir/subdir/only_to_keep_folder_in_git.txt +0 -0
  39. data/test/processor_test.rb +32 -0
  40. data/test/rim_info_test.rb +93 -0
  41. data/test/status_builder_test.rb +488 -0
  42. data/test/sync_helper_test.rb +193 -0
  43. data/test/sync_module_helper_test.rb +96 -0
  44. data/test/test_helper.rb +39 -0
  45. data/test/unit_tests.rb +14 -0
  46. data/test/upload_helper_test.rb +338 -0
  47. data/test/upload_module_helper_test.rb +92 -0
  48. metadata +110 -0
@@ -0,0 +1,93 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+ $:.unshift File.join(File.dirname(__FILE__))
3
+
4
+ require 'minitest/autorun'
5
+ require 'fileutils'
6
+ require 'test_helper'
7
+ require 'rim/rim_info'
8
+
9
+ class RimInfoTest < MiniTest::Test
10
+
11
+ include FileUtils
12
+ include TestHelper
13
+
14
+ def test_empty
15
+ d = empty_test_dir("rim_info")
16
+ ri = RIM::RimInfo.from_dir(d)
17
+ assert_nil ri.remote_url
18
+ end
19
+
20
+ def test_write
21
+ d = empty_test_dir("rim_info")
22
+ ri = RIM::RimInfo.new
23
+ ri.remote_url = "ssh://gerrit"
24
+ ri.to_dir(d)
25
+ # some whitebox testing here
26
+ ri_file = d+"/.riminfo"
27
+ assert File.exist?(ri_file)
28
+ assert File.read(ri_file) =~ /remote_url\s+:\s+ssh:\/\/gerrit/
29
+ end
30
+
31
+ def test_read
32
+ d = empty_test_dir("rim_info")
33
+ create_rim_info(d, :remote_url => "ssh://gerrit")
34
+ ri = RIM::RimInfo.from_dir(d)
35
+ assert_equal "ssh://gerrit", ri.remote_url
36
+ end
37
+
38
+ def test_tamper
39
+ d = empty_test_dir("rim_info")
40
+ create_rim_info(d, :remote_url => "ssh://gerrit")
41
+ # before
42
+ ri = RIM::RimInfo.from_dir(d)
43
+ assert_equal "ssh://gerrit", ri.remote_url
44
+ # modify
45
+ File.open(d+"/.riminfo", "a") do |f|
46
+ f.write "one more line\n"
47
+ end
48
+ # after
49
+ ri = RIM::RimInfo.from_dir(d)
50
+ assert_nil ri.remote_url
51
+ end
52
+
53
+ def test_line_ending_change
54
+ d = empty_test_dir("rim_info")
55
+ create_rim_info(d, :remote_url => "ssh://gerrit")
56
+ # modify
57
+ fn = d+"/.riminfo"
58
+ content = nil
59
+ File.open(fn, "rb") do |f|
60
+ content = f.read
61
+ end
62
+ # unix to windows
63
+ File.open(fn, "wb") do |f|
64
+ f.write(content.sub("\n", "\r\n"))
65
+ end
66
+ # still valid
67
+ ri = RIM::RimInfo.from_dir(d)
68
+ assert_equal "ssh://gerrit", ri.remote_url
69
+ end
70
+
71
+ def test_attributes
72
+ attrs = {
73
+ :remote_url => "ssh://somehost/dir1/dir2",
74
+ :revision_sha1 => "8347982374198379842984562095637243593092",
75
+ :target_revision => "trunk",
76
+ :ignores => "CMakeLists.txt,*.arxml"
77
+ }
78
+ d = empty_test_dir("rim_info")
79
+ create_rim_info(d, attrs)
80
+ ri = RIM::RimInfo.from_dir(d)
81
+ #puts File.read(d+"/.riminfo")
82
+ attrs.each_pair do |k,v|
83
+ assert_equal v, ri.send(k)
84
+ end
85
+ end
86
+
87
+ def teardown
88
+ # clean up test dirs created during last test
89
+ remove_test_dirs
90
+ end
91
+
92
+ end
93
+
@@ -0,0 +1,488 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+ $:.unshift File.join(File.dirname(__FILE__))
3
+
4
+ require 'minitest/autorun'
5
+ require 'fileutils'
6
+ require 'test_helper'
7
+ require 'rim/git'
8
+ require 'rim/dirty_check'
9
+ require 'rim/status_builder'
10
+
11
+ class StatusBuilderTest < MiniTest::Test
12
+
13
+ include FileUtils
14
+ include TestHelper
15
+
16
+ def setup
17
+ logger = Logger.new($stdout)
18
+ logger.level = Logger::ERROR unless ARGV.include? "debug"
19
+ RIM::GitSession.logger = logger
20
+ end
21
+
22
+ def test_fs_status
23
+ d = empty_test_dir("rim_info")
24
+ setup_clean_test_module("#{d}/mod1")
25
+ setup_clean_test_module("#{d}/subdir/mod2")
26
+
27
+ rs = RIM::StatusBuilder.new.fs_status(d)
28
+
29
+ assert_equal 2, rs.modules.size
30
+ assert_equal [], rs.parents
31
+ assert_nil rs.git_rev
32
+ assert rs.modules.all?{|m| !m.dirty?}
33
+
34
+ ms = rs.modules.find{|m| m.dir == "mod1"}
35
+ assert ms
36
+ assert_equal "ssh://gerrit-test/mod1", ms.rim_info.remote_url
37
+
38
+ ms = rs.modules.find{|m| m.dir == "subdir/mod2"}
39
+ assert ms
40
+ assert_equal "ssh://gerrit-test/mod2", ms.rim_info.remote_url
41
+ end
42
+
43
+ def test_fs_status_dirty
44
+ d = empty_test_dir("rim_info")
45
+ setup_clean_test_module("#{d}/mod1")
46
+ write_file "#{d}/mod1/unwanted", "content"
47
+
48
+ rs = RIM::StatusBuilder.new.fs_status(d)
49
+ assert rs.modules.first.dirty?
50
+ end
51
+
52
+ def test_rev_status
53
+ d = empty_test_dir("rim_info")
54
+
55
+ RIM.git_session(d) do |s|
56
+ test_git_setup(s, d)
57
+
58
+ rs = RIM::StatusBuilder.new.rev_status(s, "mod1~1")
59
+ assert_equal s.rev_sha1("mod1~1"), rs.git_rev
60
+ assert_equal [], rs.parents
61
+ assert_equal [], rs.modules
62
+
63
+ rs = RIM::StatusBuilder.new.rev_status(s, "mod1")
64
+ assert_equal s.rev_sha1("mod1"), rs.git_rev
65
+ assert_equal [], rs.parents
66
+ assert_equal 1, rs.modules.size
67
+ assert rs.modules.all?{|m| !m.dirty?}
68
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
69
+
70
+ rs = RIM::StatusBuilder.new.rev_status(s, "mod2~1")
71
+ assert_equal s.rev_sha1("mod2~1"), rs.git_rev
72
+ assert_equal [], rs.parents
73
+ assert_equal 1, rs.modules.size
74
+ assert rs.modules.all?{|m| !m.dirty?}
75
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
76
+
77
+ rs = RIM::StatusBuilder.new.rev_status(s, "mod2")
78
+ assert_equal s.rev_sha1("mod2"), rs.git_rev
79
+ assert_equal [], rs.parents
80
+ assert_equal 2, rs.modules.size
81
+ assert rs.modules.all?{|m| !m.dirty?}
82
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
83
+ assert_equal "ssh://gerrit-test/mod2", rs.modules.find{|m| m.dir == "mod2"}.rim_info.remote_url
84
+ end
85
+ end
86
+
87
+ def test_rev_module_status
88
+ d = empty_test_dir("rim_info")
89
+
90
+ RIM.git_session(d) do |s|
91
+ test_git_setup(s, d)
92
+
93
+ ms = RIM::StatusBuilder.new.rev_module_status(s, "mod1~1", "mod1")
94
+ assert !ms
95
+
96
+ ms = RIM::StatusBuilder.new.rev_module_status(s, "mod1", "mod1")
97
+ assert ms
98
+ assert !ms.dirty?
99
+ assert_equal "ssh://gerrit-test/mod1", ms.rim_info.remote_url
100
+ end
101
+
102
+ end
103
+
104
+ def test_rev_history_status(fast=false)
105
+ d = empty_test_dir("rim_info")
106
+
107
+ RIM.git_session(d) do |s|
108
+ test_git_setup(s, d)
109
+
110
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "mod2", :fast => fast)
111
+ assert_equal 4, all_status_objects(rs).size
112
+
113
+ assert_equal s.rev_sha1("mod2"), rs.git_rev
114
+ assert_equal 1, rs.parents.size
115
+ assert_equal 2, rs.modules.size
116
+ assert rs.modules.all?{|m| !m.dirty?}
117
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
118
+ assert_equal "ssh://gerrit-test/mod2", rs.modules.find{|m| m.dir == "mod2"}.rim_info.remote_url
119
+
120
+ rs = rs.parents.first
121
+ assert_equal s.rev_sha1("mod2~1"), rs.git_rev
122
+ assert_equal 1, rs.parents.size
123
+ assert_equal 1, rs.modules.size
124
+ assert rs.modules.all?{|m| !m.dirty?}
125
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
126
+
127
+ rs = rs.parents.first
128
+ assert_equal s.rev_sha1("mod2~2"), rs.git_rev
129
+ assert_equal 1, rs.parents.size
130
+ assert_equal 1, rs.modules.size
131
+ assert rs.modules.all?{|m| !m.dirty?}
132
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
133
+
134
+ rs = rs.parents.first
135
+ assert_equal s.rev_sha1("mod2~3"), rs.git_rev
136
+ assert_equal 0, rs.parents.size
137
+ assert_equal 0, rs.modules.size
138
+ end
139
+ end
140
+
141
+ def test_rev_history_status_fast
142
+ test_rev_history_status(true)
143
+ end
144
+
145
+ def test_rev_history_status_until_remote(fast=false)
146
+ d = empty_test_dir("rim_info")
147
+
148
+ RIM.git_session(d) do |s|
149
+ test_git_setup(s, d)
150
+
151
+ # fake remote branch
152
+ write_file "#{d}/.git/refs/remotes/origin/master", s.rev_sha1('master~1')
153
+
154
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "master", :fast => fast)
155
+ assert_equal 2, all_status_objects(rs).size
156
+
157
+ assert_equal 1, rs.parents.size
158
+ assert_equal 2, rs.modules.size
159
+ assert rs.modules.all?{|m| !m.dirty?}
160
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
161
+ assert_equal "ssh://gerrit-test/mod2", rs.modules.find{|m| m.dir == "mod2"}.rim_info.remote_url
162
+
163
+ rs = rs.parents.first
164
+ assert_equal 0, rs.parents.size
165
+ assert_equal 1, rs.modules.size
166
+ assert rs.modules.all?{|m| !m.dirty?}
167
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
168
+ end
169
+ end
170
+
171
+ def test_rev_history_status_until_remote_fast
172
+ test_rev_history_status_until_remote(true)
173
+ end
174
+
175
+ # if the commit we request history for has already been pushed to remote
176
+ # we just return the status for that commit but don't build up any history
177
+ def test_rev_history_status_until_remote_no_local_commit(fast=false)
178
+ d = empty_test_dir("rim_info")
179
+
180
+ RIM.git_session(d) do |s|
181
+ test_git_setup(s, d)
182
+
183
+ # fake remote branch
184
+ write_file "#{d}/.git/refs/remotes/origin/master", s.rev_sha1('master')
185
+
186
+ # head of remote branch
187
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "master", :fast => fast)
188
+ assert_equal 1, all_status_objects(rs).size
189
+
190
+ # ancestor of remote branch
191
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "master~1", :fast => fast)
192
+ assert_equal 1, all_status_objects(rs).size
193
+ end
194
+ end
195
+
196
+ def test_rev_history_status_until_remote_no_local_commit_fast
197
+ test_rev_history_status_until_remote_no_local_commit(true)
198
+ end
199
+
200
+ def test_rev_history_status_merge_commit(fast=false)
201
+ d = empty_test_dir("rim_info")
202
+
203
+ RIM.git_session(d) do |s|
204
+ test_git_setup(s, d)
205
+ test_git_add_merge_commit(s, d)
206
+
207
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "devel", :fast => fast)
208
+ assert_equal 6, all_status_objects(rs).size
209
+
210
+ assert_equal 2, rs.parents.size
211
+ assert_equal 3, rs.modules.size
212
+ assert rs.modules.all?{|m| !m.dirty?}
213
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
214
+ assert_equal "ssh://gerrit-test/mod2", rs.modules.find{|m| m.dir == "mod2"}.rim_info.remote_url
215
+ assert_equal "ssh://gerrit-test/mod3", rs.modules.find{|m| m.dir == "mod3"}.rim_info.remote_url
216
+
217
+ mod2_branch_status = rs.parents.find{|p| p.modules.any?{|m| m.dir == "mod2"}}
218
+ mod3_branch_status = rs.parents.find{|p| p.modules.any?{|m| m.dir == "mod3"}}
219
+
220
+ # there is one single status object where devel and master branch join
221
+ assert mod2_branch_status.parents[0].parents[0].object_id ==
222
+ mod3_branch_status.parents[0].object_id
223
+ end
224
+ end
225
+
226
+ def test_rev_history_status_merge_commit_fast
227
+ test_rev_history_status_merge_commit(true)
228
+ end
229
+
230
+ #
231
+ # o <- devel
232
+ # |\
233
+ # master -> o o <- origin/devel
234
+ # | |
235
+ # origin/master -> o |
236
+ # |/
237
+ # o
238
+ # |
239
+ # o
240
+ #
241
+ def test_rev_history_status_merge_commit_until_remote(fast=false)
242
+ d = empty_test_dir("rim_info")
243
+
244
+ RIM.git_session(d) do |s|
245
+ test_git_setup(s, d)
246
+ test_git_add_merge_commit(s, d)
247
+
248
+ # fake remote branch
249
+ write_file "#{d}/.git/refs/remotes/origin/master", s.rev_sha1('master~1')
250
+ write_file "#{d}/.git/refs/remotes/origin/devel", s.rev_sha1('devel~1')
251
+
252
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "devel", :fast => fast)
253
+ assert_equal 4, all_status_objects(rs).size
254
+ end
255
+ end
256
+
257
+ def test_rev_history_status_merge_commit_until_remote_fast
258
+ test_rev_history_status_merge_commit_until_remote(true)
259
+ end
260
+
261
+ # in this case we only have a remote branch on master but not on devel;
262
+ # when following devel back to the root, we don't hit any remote branch;
263
+ # nevertheless, the history must be cut off at commits which have already
264
+ # been pushed to some remote
265
+ #
266
+ # o <- devel
267
+ # master |\
268
+ # origin/master -> o o <= no remote branch here
269
+ # | |
270
+ # o |
271
+ # |/
272
+ # o <= status for devel branch must stop here
273
+ # |
274
+ # o
275
+ #
276
+ def test_rev_history_status_merge_commit_bypass_remote_branch(fast=false)
277
+ d = empty_test_dir("rim_info")
278
+
279
+ RIM.git_session(d) do |s|
280
+ test_git_setup(s, d)
281
+ test_git_add_merge_commit(s, d)
282
+
283
+ # fake remote branch
284
+ write_file "#{d}/.git/refs/remotes/origin/master", s.rev_sha1('master')
285
+
286
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "devel", :fast => fast)
287
+ assert_equal 4, all_status_objects(rs).size
288
+ end
289
+ end
290
+
291
+ def test_rev_history_status_merge_commit_bypass_remote_branch_fast
292
+ test_rev_history_status_merge_commit_bypass_remote_branch(true)
293
+ end
294
+
295
+ # o <- mod1 deleted
296
+ # |
297
+ # master -> o
298
+ # /mod2 |
299
+ # o
300
+ # |
301
+ # mod1 -> o
302
+ # |
303
+ # o
304
+ #
305
+ def test_rev_history_status_module_removed(fast=false)
306
+ d = empty_test_dir("rim_info")
307
+
308
+ RIM.git_session(d) do |s|
309
+ test_git_setup(s, d)
310
+ s.execute "git rm -r mod1"
311
+ s.execute "git commit -m \"removed mod1\""
312
+
313
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "master", :fast => fast)
314
+ assert_equal 5, all_status_objects(rs).size
315
+
316
+ assert_equal 1, rs.modules.size
317
+ assert_equal 2, rs.parents.first.modules.size
318
+ end
319
+ end
320
+
321
+ def test_rev_history_status_module_removed_fast
322
+ test_rev_history_status_module_removed(true)
323
+ end
324
+
325
+ # o <- mod1 made dirty
326
+ # |
327
+ # master -> o
328
+ # /mod2 |
329
+ # o
330
+ # |
331
+ # mod1 -> o
332
+ # |
333
+ # o
334
+ #
335
+ def test_rev_history_status_module_modified_dirty(fast=false)
336
+ d = empty_test_dir("rim_info")
337
+
338
+ RIM.git_session(d) do |s|
339
+ test_git_setup(s, d)
340
+ write_file("#{d}/mod1/newfile", "nothing")
341
+ s.execute "git add ."
342
+ s.execute "git commit -m \"new file making mod1 dirty\""
343
+
344
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "master", :fast => fast)
345
+ assert_equal 5, all_status_objects(rs).size
346
+
347
+ assert_equal 2, rs.modules.size
348
+ ms = rs.modules.find{|m| m.dir == "mod1"}
349
+ assert ms.dirty?
350
+ ms = rs.modules.find{|m| m.dir == "mod2"}
351
+ assert !ms.dirty?
352
+ end
353
+ end
354
+
355
+ def test_rev_history_status_module_modified_dirty_fast
356
+ test_rev_history_status_module_modified_dirty(true)
357
+ end
358
+
359
+ # o <- mod1 modified but clean
360
+ # |
361
+ # master -> o
362
+ # /mod2 |
363
+ # o
364
+ # |
365
+ # mod1 -> o
366
+ # |
367
+ # o
368
+ #
369
+ def test_rev_history_status_module_modified_clean(fast=false)
370
+ d = empty_test_dir("rim_info")
371
+
372
+ RIM.git_session(d) do |s|
373
+ test_git_setup(s, d)
374
+ write_file("#{d}/mod1/newfile", "nothing")
375
+ RIM::DirtyCheck.mark_clean("#{d}/mod1")
376
+ s.execute "git add ."
377
+ s.execute "git commit -m \"new file making mod1 dirty\""
378
+
379
+ rs = RIM::StatusBuilder.new.rev_history_status(s, "master", :fast => fast)
380
+ assert_equal 5, all_status_objects(rs).size
381
+
382
+ assert_equal 2, rs.modules.size
383
+ ms = rs.modules.find{|m| m.dir == "mod1"}
384
+ assert !ms.dirty?
385
+ ms = rs.modules.find{|m| m.dir == "mod2"}
386
+ assert !ms.dirty?
387
+ end
388
+ end
389
+
390
+ def test_rev_history_status_module_modified_clean_fast
391
+ test_rev_history_status_module_modified_clean(true)
392
+ end
393
+
394
+ def test_status_works_on_bare_repository
395
+ src = empty_test_dir("rim_info")
396
+ RIM.git_session(src) do |s|
397
+ test_git_setup(s, src)
398
+ end
399
+ d = empty_test_dir("rim_info_bare")
400
+ RIM.git_session(d) do |s|
401
+ s.execute("git clone --bare file://#{src} .")
402
+ rs = RIM::StatusBuilder.new.rev_status(s, "mod1")
403
+ assert_equal s.rev_sha1("mod1"), rs.git_rev
404
+ assert_equal [], rs.parents
405
+ assert_equal 1, rs.modules.size
406
+ assert rs.modules.all?{|m| !m.dirty?}
407
+ assert_equal "ssh://gerrit-test/mod1", rs.modules.find{|m| m.dir == "mod1"}.rim_info.remote_url
408
+ end
409
+ end
410
+
411
+ def teardown
412
+ # clean up test dirs created during last test
413
+ remove_test_dirs
414
+ end
415
+
416
+ private
417
+
418
+ def all_status_objects(rs)
419
+ [rs] | rs.parents.collect{|p| all_status_objects(p)}.flatten
420
+ end
421
+
422
+ # master -> o
423
+ # /mod2 |
424
+ # o
425
+ # |
426
+ # mod1 -> o
427
+ # |
428
+ # o
429
+ #
430
+ def test_git_setup(gs, dir)
431
+ gs.execute "git init"
432
+
433
+ write_file "#{dir}/unrelated_file", "anything"
434
+ gs.execute "git add ."
435
+ gs.execute "git commit -m \"initial\""
436
+
437
+ setup_clean_test_module("#{dir}/mod1")
438
+ gs.execute "git add ."
439
+ gs.execute "git commit -m \"added mod1\""
440
+ gs.execute "git tag mod1"
441
+
442
+ write_file "#{dir}/unrelated_file", "anything changes"
443
+ gs.execute "git add ."
444
+ gs.execute "git commit -m \"some unrelated change\""
445
+
446
+ setup_clean_test_module("#{dir}/mod2")
447
+ gs.execute "git add ."
448
+ gs.execute "git commit -m \"added mod2\""
449
+ gs.execute "git tag mod2"
450
+ end
451
+
452
+ # creates devel branch branching of at tag mod1
453
+ # creates a merge commit on branch "devel"
454
+ # to be called after test_git_setup
455
+ #
456
+ # o <- devel
457
+ # |\
458
+ # master -> o o <- mod3
459
+ # /mod2 | |
460
+ # o |
461
+ # |/
462
+ # mod1 -> o
463
+ # |
464
+ # o
465
+ #
466
+ def test_git_add_merge_commit(gs, dir)
467
+ gs.execute "git checkout -b devel mod1"
468
+ setup_clean_test_module("#{dir}/mod3")
469
+ gs.execute "git add ."
470
+ gs.execute "git commit -m \"added mod3\""
471
+ gs.execute "git tag mod3"
472
+ gs.execute "git merge master"
473
+ end
474
+
475
+ # create a module in dir complete with rim info
476
+ def setup_clean_test_module(dir)
477
+ create_rim_info(dir, {
478
+ :remote_url => "ssh://gerrit-test/#{File.basename(dir)}",
479
+ :revision_sha1 => "12345"
480
+ })
481
+ write_file "#{dir}/file1", "some content"
482
+ write_file "#{dir}/dir1/file2", "some other content"
483
+ RIM::DirtyCheck.mark_clean(dir)
484
+ assert !RIM::DirtyCheck.dirty?(dir)
485
+ end
486
+
487
+ end
488
+