braid 1.0.22 → 1.1.0

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/README.md +48 -0
  4. data/_config.yml +1 -0
  5. data/bin/braid +44 -7
  6. data/braid.gemspec +4 -0
  7. data/config_versions.md +58 -0
  8. data/lib/braid.rb +7 -0
  9. data/lib/braid/command.rb +7 -7
  10. data/lib/braid/commands/add.rb +3 -3
  11. data/lib/braid/commands/diff.rb +7 -14
  12. data/lib/braid/commands/push.rb +10 -4
  13. data/lib/braid/commands/setup.rb +5 -1
  14. data/lib/braid/commands/status.rb +5 -1
  15. data/lib/braid/commands/update.rb +6 -15
  16. data/lib/braid/commands/upgrade_config.rb +56 -0
  17. data/lib/braid/config.rb +166 -27
  18. data/lib/braid/mirror.rb +111 -11
  19. data/lib/braid/operations.rb +51 -35
  20. data/lib/braid/version.rb +1 -1
  21. data/spec/config_spec.rb +2 -2
  22. data/spec/fixtures/shiny-conf-1.0.9-lock/.braids.json +10 -0
  23. data/spec/fixtures/shiny-conf-1.0.9-lock/expected.braids.json +9 -0
  24. data/spec/fixtures/shiny-conf-1.0.9-lock/skit1/layouts/layout.liquid +219 -0
  25. data/spec/fixtures/shiny-conf-1.0.9-lock/skit1/preview.png +0 -0
  26. data/spec/fixtures/shiny-conf-breaking-changes/.braids +14 -0
  27. data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/README.md +9 -0
  28. data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/index.html +20 -0
  29. data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/styles.css +17 -0
  30. data/spec/fixtures/shiny-conf-breaking-changes/expected.braids.json +10 -0
  31. data/spec/fixtures/shiny-conf-breaking-changes/skit1/layouts/layout.liquid +219 -0
  32. data/spec/fixtures/shiny-conf-breaking-changes/skit1/preview.png +0 -0
  33. data/spec/fixtures/shiny-conf-future/.braids.json +10 -0
  34. data/spec/fixtures/shiny-conf-future/skit1/layouts/layout.liquid +219 -0
  35. data/spec/fixtures/shiny-conf-future/skit1/preview.png +0 -0
  36. data/spec/fixtures/shiny-conf-json-old-name/.braids +9 -0
  37. data/spec/fixtures/shiny-conf-json-old-name/expected.braids.json +10 -0
  38. data/spec/fixtures/shiny-conf-json-old-name/skit1/layouts/layout.liquid +219 -0
  39. data/spec/fixtures/shiny-conf-json-old-name/skit1/preview.png +0 -0
  40. data/spec/fixtures/shiny-conf-yaml/.braids +8 -0
  41. data/spec/fixtures/shiny-conf-yaml/expected.braids.json +10 -0
  42. data/spec/fixtures/shiny-conf-yaml/skit1/layouts/layout.liquid +219 -0
  43. data/spec/fixtures/shiny-conf-yaml/skit1/preview.png +0 -0
  44. data/spec/fixtures/shiny/skit-layout.liquid.test +2 -0
  45. data/spec/fixtures/shiny/skit1.test +2 -0
  46. data/spec/fixtures/skit1.1x/layouts/layout.liquid +219 -0
  47. data/spec/integration/adding_spec.rb +82 -34
  48. data/spec/integration/config_versioning_spec.rb +222 -0
  49. data/spec/integration/diff_spec.rb +173 -9
  50. data/spec/integration/integration_helper.rb +23 -5
  51. data/spec/integration/push_spec.rb +57 -4
  52. data/spec/integration/remove_spec.rb +27 -5
  53. data/spec/integration/updating_spec.rb +104 -19
  54. metadata +73 -2
@@ -110,10 +110,9 @@ BANNER
110
110
  base_revision = /^skit1 \(([0-9a-f]{40})\)/.match(status_out)[1]
111
111
  # Make sure the base revision is in the repository as a sanity check.
112
112
  run_command("git rev-parse --verify --quiet #{base_revision}^{commit}")
113
- run_command("git gc --quiet --prune=all")
113
+ run_command('git gc --quiet --prune=all')
114
114
  # Make sure it's gone now so we know we're actually testing Braid's fetch behavior.
115
- `git rev-parse --verify --quiet #{base_revision}^{commit}`
116
- raise "'git gc' did not delete the base revision from the repository." if $?.success?
115
+ run_command_expect_failure("git rev-parse --verify --quiet #{base_revision}^{commit}")
117
116
 
118
117
  diff = run_command("#{BRAID_BIN} diff skit1")
119
118
 
@@ -285,7 +284,7 @@ PATCH
285
284
  describe 'braided subdirectory into' do
286
285
  before do
287
286
  in_dir(@repository_dir) do
288
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
287
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts skit-layouts")
289
288
  end
290
289
  end
291
290
 
@@ -293,7 +292,7 @@ PATCH
293
292
  it 'with the mirror specified should emit no output' do
294
293
  diff = nil
295
294
  in_dir(@repository_dir) do
296
- diff = run_command("#{BRAID_BIN} diff skit1")
295
+ diff = run_command("#{BRAID_BIN} diff skit-layouts")
297
296
  end
298
297
 
299
298
  expect(diff).to eq('')
@@ -305,14 +304,14 @@ PATCH
305
304
  diff = run_command("#{BRAID_BIN} diff")
306
305
  end
307
306
 
308
- expect(diff).to eq("=======================================================\nBraid: Diffing skit1\n=======================================================\n")
307
+ expect(diff).to eq("=======================================================\nBraid: Diffing skit-layouts\n=======================================================\n")
309
308
  end
310
309
  end
311
310
 
312
311
 
313
312
  describe 'with changes' do
314
313
  before do
315
- FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/layouts/.', "#{@repository_dir}/skit1")
314
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/layouts/.', "#{@repository_dir}/skit-layouts")
316
315
  in_dir(@repository_dir) do
317
316
  run_command('git add *')
318
317
  run_command('git commit -m "Some local changes"')
@@ -322,7 +321,7 @@ PATCH
322
321
  it 'with the mirror specified should emit diff' do
323
322
  diff = nil
324
323
  in_dir(@repository_dir) do
325
- diff = run_command("#{BRAID_BIN} diff skit1")
324
+ diff = run_command("#{BRAID_BIN} diff skit-layouts")
326
325
  end
327
326
 
328
327
  expect(diff).to eq(<<PATCH)
@@ -350,7 +349,7 @@ PATCH
350
349
 
351
350
  expect(diff).to eq(<<PATCH)
352
351
  =======================================================
353
- Braid: Diffing skit1
352
+ Braid: Diffing skit-layouts
354
353
  =======================================================
355
354
  diff --git a/layout.liquid b/layout.liquid
356
355
  index 9f75009..25a4b32 100644
@@ -360,6 +359,171 @@ index 9f75009..25a4b32 100644
360
359
  <![endif]-->
361
360
  </head>
362
361
 
362
+ -<body class="fixed orange">
363
+ +<body class="fixed green">
364
+ <script type="text/javascript">loadPreferences()</script>
365
+
366
+ <div id="wrapper">
367
+ PATCH
368
+ end
369
+ end
370
+ end
371
+
372
+ describe 'braided from a single file' do
373
+ before do
374
+ in_dir(@repository_dir) do
375
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts/layout.liquid skit-layout.liquid")
376
+ end
377
+ end
378
+
379
+ describe 'with no changes' do
380
+ it 'with the mirror specified should emit no output' do
381
+ diff = nil
382
+ in_dir(@repository_dir) do
383
+ diff = run_command("#{BRAID_BIN} diff skit-layout.liquid")
384
+ end
385
+
386
+ expect(diff).to eq('')
387
+ end
388
+
389
+ it 'without specifying a mirror should emit only banners' do
390
+ diff = nil
391
+ in_dir(@repository_dir) do
392
+ diff = run_command("#{BRAID_BIN} diff")
393
+ end
394
+
395
+ expect(diff).to eq("=======================================================\nBraid: Diffing skit-layout.liquid\n=======================================================\n")
396
+ end
397
+ end
398
+
399
+
400
+ describe 'with changes' do
401
+ before do
402
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/layouts/layout.liquid', "#{@repository_dir}/skit-layout.liquid",
403
+ {preserve: true})
404
+ in_dir(@repository_dir) do
405
+ run_command('git add *')
406
+ run_command('git commit -m "Some local changes"')
407
+ end
408
+ end
409
+
410
+ it 'with the mirror specified should emit diff' do
411
+ diff = nil
412
+ in_dir(@repository_dir) do
413
+ diff = run_command("#{BRAID_BIN} diff skit-layout.liquid")
414
+ end
415
+
416
+ expect(diff).to eq(<<PATCH)
417
+ diff --git a/layout.liquid b/skit-layout.liquid
418
+ index 9f75009..25a4b32 100644
419
+ --- a/layout.liquid
420
+ +++ b/skit-layout.liquid
421
+ @@ -22,7 +22,7 @@
422
+ <![endif]-->
423
+ </head>
424
+
425
+ -<body class="fixed orange">
426
+ +<body class="fixed green">
427
+ <script type="text/javascript">loadPreferences()</script>
428
+
429
+ <div id="wrapper">
430
+ PATCH
431
+ end
432
+
433
+ it 'without specifying a mirror should emit diff and banners' do
434
+ diff = nil
435
+ in_dir(@repository_dir) do
436
+ diff = run_command("#{BRAID_BIN} diff")
437
+ end
438
+
439
+ expect(diff).to eq(<<PATCH)
440
+ =======================================================
441
+ Braid: Diffing skit-layout.liquid
442
+ =======================================================
443
+ diff --git a/layout.liquid b/skit-layout.liquid
444
+ index 9f75009..25a4b32 100644
445
+ --- a/layout.liquid
446
+ +++ b/skit-layout.liquid
447
+ @@ -22,7 +22,7 @@
448
+ <![endif]-->
449
+ </head>
450
+
451
+ -<body class="fixed orange">
452
+ +<body class="fixed green">
453
+ <script type="text/javascript">loadPreferences()</script>
454
+
455
+ <div id="wrapper">
456
+ PATCH
457
+ end
458
+ end
459
+
460
+ describe 'with changes including a mode change' do
461
+ before do
462
+ in_dir(@repository_dir) do
463
+ @filemode_enabled = filemode_enabled
464
+ end
465
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1x') + '/layouts/layout.liquid', "#{@repository_dir}/skit-layout.liquid",
466
+ {preserve: true})
467
+ in_dir(@repository_dir) do
468
+ run_command('git add *')
469
+ run_command('git commit -m "Some local changes"')
470
+ end
471
+ end
472
+
473
+ it 'with the mirror specified should emit diff' do
474
+ # Right way to do this? See
475
+ # https://github.com/cucumber/aruba/issues/301 . It's unclear what
476
+ # we'd have to do to get the information in time to use :unless. If
477
+ # we don't do that, a success seems less bad than a known
478
+ # failure ("pending").
479
+ next unless @filemode_enabled
480
+
481
+ diff = nil
482
+ in_dir(@repository_dir) do
483
+ diff = run_command("#{BRAID_BIN} diff skit-layout.liquid")
484
+ end
485
+
486
+ expect(diff).to eq(<<PATCH)
487
+ diff --git a/layout.liquid b/skit-layout.liquid
488
+ old mode 100644
489
+ new mode 100755
490
+ index 9f75009..25a4b32
491
+ --- a/layout.liquid
492
+ +++ b/skit-layout.liquid
493
+ @@ -22,7 +22,7 @@
494
+ <![endif]-->
495
+ </head>
496
+
497
+ -<body class="fixed orange">
498
+ +<body class="fixed green">
499
+ <script type="text/javascript">loadPreferences()</script>
500
+
501
+ <div id="wrapper">
502
+ PATCH
503
+ end
504
+
505
+ it 'without specifying a mirror should emit diff and banners' do
506
+ next unless @filemode_enabled
507
+
508
+ diff = nil
509
+ in_dir(@repository_dir) do
510
+ diff = run_command("#{BRAID_BIN} diff")
511
+ end
512
+
513
+ expect(diff).to eq(<<PATCH)
514
+ =======================================================
515
+ Braid: Diffing skit-layout.liquid
516
+ =======================================================
517
+ diff --git a/layout.liquid b/skit-layout.liquid
518
+ old mode 100644
519
+ new mode 100755
520
+ index 9f75009..25a4b32
521
+ --- a/layout.liquid
522
+ +++ b/skit-layout.liquid
523
+ @@ -22,7 +22,7 @@
524
+ <![endif]-->
525
+ </head>
526
+
363
527
  -<body class="fixed orange">
364
528
  +<body class="fixed green">
365
529
  <script type="text/javascript">loadPreferences()</script>
@@ -20,6 +20,12 @@ FileUtils.mkdir_p(TMP_PATH)
20
20
 
21
21
  BRAID_BIN = ((defined?(JRUBY_VERSION) || Gem.win_platform?) ? 'ruby ' : '') + File.join(BRAID_PATH, 'bin', 'braid')
22
22
 
23
+ # Must run in a git repository, though we expect the setting to be the same for
24
+ # most repositories on a given OS.
25
+ def filemode_enabled
26
+ run_command('git config core.filemode').strip == 'true'
27
+ end
28
+
23
29
  def with_editor_message(message = 'Make some changes')
24
30
  File.write(EDITOR_CMD, <<CMD)
25
31
  #!/usr/bin/env ruby
@@ -31,8 +37,8 @@ CMD
31
37
  end
32
38
  end
33
39
 
34
- def assert_no_diff(file1, file2)
35
- run_command("diff -U 3 #{file1} #{file2}")
40
+ def assert_no_diff(file1, file2, extra_flags = '')
41
+ run_command("diff -U 3 #{extra_flags} #{file1} #{file2}")
36
42
  end
37
43
 
38
44
  def assert_commit_attribute(format_key, value, commit_index = 0)
@@ -54,8 +60,13 @@ def assert_commit_email(value, commit_index = 0)
54
60
  end
55
61
 
56
62
  def in_dir(dir = TMP_PATH)
63
+ orig_wd = Dir.pwd
57
64
  Dir.chdir(dir)
58
- yield
65
+ begin
66
+ yield
67
+ ensure
68
+ Dir.chdir(orig_wd)
69
+ end
59
70
  end
60
71
 
61
72
  # Note: Do not use single quotes to quote spaces in arguments. They do not work
@@ -66,10 +77,16 @@ def run_command(command)
66
77
  output
67
78
  end
68
79
 
80
+ def run_command_expect_failure(command)
81
+ output = `#{command}`
82
+ raise "Expected command to fail but it succeeded: #{command}\nOutput: #{output}" if $?.success?
83
+ output
84
+ end
85
+
69
86
  def update_dir_from_fixture(dir, fixture = dir)
70
87
  to_dir = File.join(TMP_PATH, dir)
71
88
  FileUtils.mkdir_p(to_dir)
72
- FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir)
89
+ FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir, {preserve: true})
73
90
  end
74
91
 
75
92
  def create_git_repo_from_fixture(fixture_name, options = {})
@@ -83,7 +100,8 @@ def create_git_repo_from_fixture(fixture_name, options = {})
83
100
  run_command('git init')
84
101
  run_command("git config --local user.email \"#{email}\"")
85
102
  run_command("git config --local user.name \"#{name}\"")
86
- run_command('git add *')
103
+ run_command('git config --local commit.gpgsign false')
104
+ run_command('git add .')
87
105
  run_command("git commit -m \"initial commit of #{fixture_name}\"")
88
106
  end
89
107
 
@@ -110,14 +110,14 @@ describe 'Pushing to a mirror' do
110
110
  @file_name = 'layouts/layout.liquid'
111
111
 
112
112
  in_dir(@repository_dir) do
113
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
113
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts skit-layouts")
114
114
  end
115
115
 
116
116
  in_dir(@vendor_repository_dir) do
117
117
  run_command('git config receive.denyCurrentBranch updateInstead')
118
118
  end
119
119
 
120
- update_dir_from_fixture('shiny/skit1', 'skit1.1/layouts')
120
+ update_dir_from_fixture('shiny/skit-layouts', 'skit1.1/layouts')
121
121
  in_dir(@repository_dir) do
122
122
  run_command('git add *')
123
123
  run_command('git commit -m "Make some changes to vendored files"')
@@ -130,14 +130,14 @@ describe 'Pushing to a mirror' do
130
130
  commit_message = 'Make some changes'
131
131
  in_dir(@repository_dir) do
132
132
  with_editor_message(commit_message) do
133
- braid_output = run_command("#{BRAID_BIN} push skit1")
133
+ braid_output = run_command("#{BRAID_BIN} push skit-layouts")
134
134
  end
135
135
  end
136
136
  expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
137
137
  expect(braid_output).to match(/Make some changes/)
138
138
  expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
139
139
 
140
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/layout.liquid")
140
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit-layouts/layout.liquid")
141
141
  assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
142
142
 
143
143
  in_dir(@vendor_repository_dir) do
@@ -151,6 +151,59 @@ describe 'Pushing to a mirror' do
151
151
  end
152
152
  end
153
153
 
154
+ describe 'from a git repository braided into a single file' do
155
+ before do
156
+ @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
157
+ @vendor_repository_dir = create_git_repo_from_fixture('skit1')
158
+ @file_name = 'layouts/layout.liquid'
159
+
160
+ in_dir(@repository_dir) do
161
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts/layout.liquid skit-layout.liquid")
162
+ end
163
+
164
+ in_dir(@vendor_repository_dir) do
165
+ run_command('git config receive.denyCurrentBranch updateInstead')
166
+ end
167
+
168
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1x') + '/layouts/layout.liquid', "#{@repository_dir}/skit-layout.liquid",
169
+ {preserve: true})
170
+ in_dir(@repository_dir) do
171
+ run_command('git add *')
172
+ run_command('git commit -m "Make some changes to vendored files"')
173
+ end
174
+ end
175
+
176
+ context 'with remote updtodate' do
177
+ it 'should push changes successfully' do
178
+ braid_output = nil
179
+ commit_message = 'Make some changes'
180
+ in_dir(@repository_dir) do
181
+ with_editor_message(commit_message) do
182
+ braid_output = run_command("#{BRAID_BIN} push skit-layout.liquid")
183
+ end
184
+ end
185
+ expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
186
+ expect(braid_output).to match(/Make some changes/)
187
+ expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
188
+
189
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1x/#{@file_name}", "#{@repository_dir}/skit-layout.liquid")
190
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1x/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
191
+
192
+ in_dir(@vendor_repository_dir) do
193
+ run_command('git checkout master 2>&1')
194
+
195
+ if filemode_enabled
196
+ expect(File.stat(@file_name).mode & 0100).to eq(0100)
197
+ end
198
+
199
+ assert_commit_subject(commit_message)
200
+ assert_commit_author('Some body')
201
+ assert_commit_email('somebody@example.com')
202
+ end
203
+ end
204
+ end
205
+ end
206
+
154
207
  describe 'from a git repository braided in as a tag' do
155
208
  before do
156
209
  @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
@@ -38,22 +38,44 @@ describe 'Removing a mirror' do
38
38
  describe 'braiding a subdirectory in' do
39
39
  before do
40
40
  in_dir(@repository_dir) do
41
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
41
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts skit-layouts")
42
42
  end
43
43
  end
44
44
 
45
45
  it 'should remove the files and the remote' do
46
46
 
47
- assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit1/layout.liquid")
47
+ assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit-layouts/layout.liquid")
48
48
 
49
49
  in_dir(@repository_dir) do
50
- run_command("#{BRAID_BIN} remove skit1")
50
+ run_command("#{BRAID_BIN} remove skit-layouts")
51
51
  end
52
52
 
53
- expect(File.exist?("#{@repository_dir}/skit1)")).to eq(false)
53
+ expect(File.exist?("#{@repository_dir}/skit-layouts)")).to eq(false)
54
54
 
55
55
  braids = YAML::load_file("#{@repository_dir}/.braids.json")
56
- expect(braids['skit1']).to be_nil
56
+ expect(braids['skit-layouts']).to be_nil
57
+ end
58
+ end
59
+
60
+ describe 'braiding a single file in' do
61
+ before do
62
+ in_dir(@repository_dir) do
63
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts/layout.liquid skit-layout.liquid")
64
+ end
65
+ end
66
+
67
+ it 'should remove the files and the remote' do
68
+
69
+ assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit-layout.liquid")
70
+
71
+ in_dir(@repository_dir) do
72
+ run_command("#{BRAID_BIN} remove skit-layout.liquid")
73
+ end
74
+
75
+ expect(File.exist?("#{@repository_dir}/skit-layout.liquid)")).to eq(false)
76
+
77
+ braids = YAML::load_file("#{@repository_dir}/.braids.json")
78
+ expect(braids['skit-layout.liquid']).to be_nil
57
79
  end
58
80
  end
59
81
  end
@@ -80,12 +80,18 @@ describe 'Updating a mirror' do
80
80
 
81
81
  assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
82
82
 
83
- output = run_command('git log --pretty=oneline').split("\n")
83
+ output = nil
84
+ in_dir(@repository_dir) do
85
+ output = run_command('git log --pretty=oneline').split("\n")
86
+ end
84
87
  expect(output.length).to eq(3)
85
88
  expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
86
89
 
87
90
  # No temporary commits should be added to the reflog.
88
- output = `git log -g --pretty=oneline`.split("\n")
91
+ output = nil
92
+ in_dir(@repository_dir) do
93
+ output = `git log -g --pretty=oneline`.split("\n")
94
+ end
89
95
  expect(output.length).to eq(3)
90
96
  end
91
97
  end
@@ -101,7 +107,10 @@ describe 'Updating a mirror' do
101
107
 
102
108
  assert_no_diff("#{FIXTURE_PATH}/shiny_skit1.2_merged/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
103
109
 
104
- output = run_command('git log --pretty=oneline').split("\n")
110
+ output = nil
111
+ in_dir(@repository_dir) do
112
+ output = run_command('git log --pretty=oneline').split("\n")
113
+ end
105
114
  expect(output.length).to eq(4) # plus 'mergeable change'
106
115
  expect(output[0]).to match(/Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/)
107
116
  end
@@ -158,7 +167,7 @@ describe 'Updating a mirror' do
158
167
  @file_name = 'layouts/layout.liquid'
159
168
 
160
169
  in_dir(@repository_dir) do
161
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
170
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts skit-layouts")
162
171
  end
163
172
 
164
173
  update_dir_from_fixture('skit1', 'skit1.1')
@@ -177,22 +186,68 @@ describe 'Updating a mirror' do
177
186
  context 'with no project-specific changes' do
178
187
  it 'should add the files and commit' do
179
188
  in_dir(@repository_dir) do
180
- run_command("#{BRAID_BIN} update skit1")
189
+ run_command("#{BRAID_BIN} update skit-layouts")
181
190
  end
182
191
 
183
- assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/layout.liquid")
192
+ assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit-layouts/layout.liquid")
184
193
 
185
- output = run_command('git log --pretty=oneline').split("\n")
194
+ output = nil
195
+ in_dir(@repository_dir) do
196
+ output = run_command('git log --pretty=oneline').split("\n")
197
+ end
186
198
  expect(output.length).to eq(3)
187
- expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
199
+ expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit-layouts' to '[0-9a-f]{7}'$/)
188
200
 
189
201
  # No temporary commits should be added to the reflog.
190
- output = `git log -g --pretty=oneline`.split("\n")
202
+ output = nil
203
+ in_dir(@repository_dir) do
204
+ output = `git log -g --pretty=oneline`.split("\n")
205
+ end
191
206
  expect(output.length).to eq(3)
192
207
  end
193
208
  end
194
209
  end
195
210
 
211
+ describe 'from a git repository with a braid of a single file' do
212
+ before do
213
+ @repository_dir = create_git_repo_from_fixture('shiny')
214
+ @vendor_repository_dir = create_git_repo_from_fixture('skit1')
215
+ @file_name = 'layouts/layout.liquid'
216
+
217
+ in_dir(@repository_dir) do
218
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts/layout.liquid skit-layout.liquid")
219
+ end
220
+
221
+ update_dir_from_fixture('skit1', 'skit1.1x')
222
+ in_dir(@vendor_repository_dir) do
223
+ run_command('git add *')
224
+ run_command('git commit -m "change color and file mode"')
225
+ end
226
+ end
227
+
228
+ context 'with no project-specific changes' do
229
+ it 'should add the files and commit' do
230
+ in_dir(@repository_dir) do
231
+ run_command("#{BRAID_BIN} update skit-layout.liquid")
232
+ end
233
+
234
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1x/#{@file_name}", "#{@repository_dir}/skit-layout.liquid")
235
+ in_dir(@repository_dir) do
236
+ if filemode_enabled
237
+ expect(File.stat('skit-layout.liquid').mode & 0100).to eq(0100)
238
+ end
239
+ end
240
+
241
+ output = nil
242
+ in_dir(@repository_dir) do
243
+ output = run_command('git log --pretty=oneline').split("\n")
244
+ end
245
+ expect(output.length).to eq(3)
246
+ expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit-layout.liquid' to '[0-9a-f]{7}'$/)
247
+ end
248
+ end
249
+ end
250
+
196
251
  describe 'from a git repository braided in as a tag' do
197
252
  before do
198
253
  @repository_dir = create_git_repo_from_fixture('shiny')
@@ -228,12 +283,18 @@ describe 'Updating a mirror' do
228
283
 
229
284
  assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
230
285
 
231
- output = run_command('git log --pretty=oneline').split("\n")
286
+ output = nil
287
+ in_dir(@repository_dir) do
288
+ output = run_command('git log --pretty=oneline').split("\n")
289
+ end
232
290
  expect(output.length).to eq(3)
233
291
  expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
234
292
 
235
293
  # No temporary commits should be added to the reflog.
236
- output = `git log -g --pretty=oneline`.split("\n")
294
+ output = nil
295
+ in_dir(@repository_dir) do
296
+ output = `git log -g --pretty=oneline`.split("\n")
297
+ end
237
298
  expect(output.length).to eq(3)
238
299
  end
239
300
  end
@@ -249,7 +310,10 @@ describe 'Updating a mirror' do
249
310
 
250
311
  assert_no_diff("#{FIXTURE_PATH}/shiny_skit1.2_merged/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
251
312
 
252
- output = run_command('git log --pretty=oneline').split("\n")
313
+ output = nil
314
+ in_dir(@repository_dir) do
315
+ output = run_command('git log --pretty=oneline').split("\n")
316
+ end
253
317
  expect(output.length).to eq(4) # plus 'mergeable change'
254
318
  expect(output[0]).to match(/Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/)
255
319
  end
@@ -324,12 +388,18 @@ describe 'Updating a mirror' do
324
388
 
325
389
  assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/layouts/layout.liquid")
326
390
 
327
- output = run_command('git log --pretty=oneline').split("\n")
391
+ output = nil
392
+ in_dir(@repository_dir) do
393
+ output = run_command('git log --pretty=oneline').split("\n")
394
+ end
328
395
  expect(output.length).to eq(3)
329
396
  expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
330
397
 
331
398
  # No temporary commits should be added to the reflog.
332
- output = `git log -g --pretty=oneline`.split("\n")
399
+ output = nil
400
+ in_dir(@repository_dir) do
401
+ output = `git log -g --pretty=oneline`.split("\n")
402
+ end
333
403
  expect(output.length).to eq(3)
334
404
  end
335
405
 
@@ -344,7 +414,10 @@ describe 'Updating a mirror' do
344
414
 
345
415
  assert_no_diff("#{FIXTURE_PATH}/shiny_skit1.2_merged/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
346
416
 
347
- output = run_command('git log --pretty=oneline').split("\n")
417
+ output = nil
418
+ in_dir(@repository_dir) do
419
+ output = run_command('git log --pretty=oneline').split("\n")
420
+ end
348
421
  expect(output.length).to eq(4) # plus 'mergeable change'
349
422
  expect(output[0]).to match(/Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/)
350
423
  end
@@ -357,11 +430,17 @@ describe 'Updating a mirror' do
357
430
 
358
431
  assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
359
432
 
360
- output = run_command('git log --pretty=oneline').split("\n")
433
+ output = nil
434
+ in_dir(@repository_dir) do
435
+ output = run_command('git log --pretty=oneline').split("\n")
436
+ end
361
437
  expect(output.length).to eq(2)
362
438
 
363
439
  # No temporary commits should be added to the reflog.
364
- output = `git log -g --pretty=oneline`.split("\n")
440
+ output = nil
441
+ in_dir(@repository_dir) do
442
+ output = `git log -g --pretty=oneline`.split("\n")
443
+ end
365
444
  expect(output.length).to eq(2)
366
445
  end
367
446
  end
@@ -387,12 +466,18 @@ describe 'Updating a mirror' do
387
466
 
388
467
  assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/layouts/layout.liquid")
389
468
 
390
- output = run_command('git log --pretty=oneline').split("\n")
469
+ output = nil
470
+ in_dir(@repository_dir) do
471
+ output = run_command('git log --pretty=oneline').split("\n")
472
+ end
391
473
  expect(output.length).to eq(3)
392
474
  expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
393
475
 
394
476
  # No temporary commits should be added to the reflog.
395
- output = `git log -g --pretty=oneline`.split("\n")
477
+ output = nil
478
+ in_dir(@repository_dir) do
479
+ output = `git log -g --pretty=oneline`.split("\n")
480
+ end
396
481
  expect(output.length).to eq(3)
397
482
  end
398
483
  end