braid 1.1.4 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/exe/braid +11 -0
  3. data/lib/braid/check_gem.rb +58 -0
  4. data/lib/braid/command.rb +13 -0
  5. data/lib/braid/commands/diff.rb +1 -1
  6. data/lib/braid/config.rb +28 -4
  7. data/{bin/braid → lib/braid/main.rb} +1 -16
  8. data/lib/braid/mirror.rb +110 -23
  9. data/lib/braid/operations.rb +9 -6
  10. data/lib/braid/operations_lite.rb +19 -1
  11. data/lib/braid/sorbet/fake_runtime.rb +68 -0
  12. data/lib/braid/sorbet/setup.rb +18 -0
  13. data/lib/braid/version.rb +1 -1
  14. data/lib/braid.rb +21 -0
  15. metadata +12 -75
  16. data/.gitignore +0 -16
  17. data/.travis.yml +0 -15
  18. data/CONTRIBUTING.md +0 -24
  19. data/Gemfile +0 -3
  20. data/README.md +0 -234
  21. data/Rakefile +0 -12
  22. data/_config.yml +0 -1
  23. data/braid.gemspec +0 -35
  24. data/braids-json.schema.json +0 -91
  25. data/config_versions.md +0 -58
  26. data/spec/config_spec.rb +0 -59
  27. data/spec/fixtures/shiny/README +0 -3
  28. data/spec/fixtures/shiny/other-skit/layout.liquid +0 -219
  29. data/spec/fixtures/shiny/skit-layout.liquid.test +0 -2
  30. data/spec/fixtures/shiny/skit1.test +0 -2
  31. data/spec/fixtures/shiny-conf-1.0.9-lock/.braids.json +0 -10
  32. data/spec/fixtures/shiny-conf-1.0.9-lock/expected.braids.json +0 -9
  33. data/spec/fixtures/shiny-conf-1.0.9-lock/skit1/layouts/layout.liquid +0 -219
  34. data/spec/fixtures/shiny-conf-1.0.9-lock/skit1/preview.png +0 -0
  35. data/spec/fixtures/shiny-conf-breaking-changes/.braids +0 -14
  36. data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/README.md +0 -9
  37. data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/index.html +0 -20
  38. data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/styles.css +0 -17
  39. data/spec/fixtures/shiny-conf-breaking-changes/expected.braids.json +0 -10
  40. data/spec/fixtures/shiny-conf-breaking-changes/skit1/layouts/layout.liquid +0 -219
  41. data/spec/fixtures/shiny-conf-breaking-changes/skit1/preview.png +0 -0
  42. data/spec/fixtures/shiny-conf-future/.braids.json +0 -10
  43. data/spec/fixtures/shiny-conf-future/skit1/layouts/layout.liquid +0 -219
  44. data/spec/fixtures/shiny-conf-future/skit1/preview.png +0 -0
  45. data/spec/fixtures/shiny-conf-json-old-name/.braids +0 -9
  46. data/spec/fixtures/shiny-conf-json-old-name/expected.braids.json +0 -10
  47. data/spec/fixtures/shiny-conf-json-old-name/skit1/layouts/layout.liquid +0 -219
  48. data/spec/fixtures/shiny-conf-json-old-name/skit1/preview.png +0 -0
  49. data/spec/fixtures/shiny-conf-yaml/.braids +0 -8
  50. data/spec/fixtures/shiny-conf-yaml/expected.braids.json +0 -10
  51. data/spec/fixtures/shiny-conf-yaml/skit1/layouts/layout.liquid +0 -219
  52. data/spec/fixtures/shiny-conf-yaml/skit1/preview.png +0 -0
  53. data/spec/fixtures/shiny_skit1.2_merged/layouts/layout.liquid +0 -223
  54. data/spec/fixtures/shiny_skit1.2_merged/preview.png +0 -0
  55. data/spec/fixtures/shiny_skit1_conflicting/layouts/layout.liquid +0 -221
  56. data/spec/fixtures/shiny_skit1_conflicting/preview.png +0 -0
  57. data/spec/fixtures/shiny_skit1_mergeable/layouts/layout.liquid +0 -221
  58. data/spec/fixtures/shiny_skit1_mergeable/preview.png +0 -0
  59. data/spec/fixtures/skit1/layouts/layout.liquid +0 -219
  60. data/spec/fixtures/skit1/preview.png +0 -0
  61. data/spec/fixtures/skit1.1/layouts/layout.liquid +0 -219
  62. data/spec/fixtures/skit1.1_with_filter/.gitattributes +0 -1
  63. data/spec/fixtures/skit1.1_with_filter/layouts/layout.liquid +0 -219
  64. data/spec/fixtures/skit1.1_with_filter/preview.png +0 -0
  65. data/spec/fixtures/skit1.1x/layouts/layout.liquid +0 -219
  66. data/spec/fixtures/skit1.2/layouts/layout.liquid +0 -221
  67. data/spec/fixtures/skit1.3/layouts/README.md +0 -1
  68. data/spec/fixtures/skit1.3/layouts/layout.liquid +0 -221
  69. data/spec/fixtures/skit1_with_filter/.gitattributes +0 -1
  70. data/spec/fixtures/skit1_with_filter/layouts/layout.liquid +0 -219
  71. data/spec/fixtures/skit1_with_filter/preview.png +0 -0
  72. data/spec/integration/adding_spec.rb +0 -230
  73. data/spec/integration/config_versioning_spec.rb +0 -222
  74. data/spec/integration/diff_spec.rb +0 -597
  75. data/spec/integration/integration_helper.rb +0 -126
  76. data/spec/integration/push_spec.rb +0 -402
  77. data/spec/integration/remove_spec.rb +0 -81
  78. data/spec/integration/status_spec.rb +0 -165
  79. data/spec/integration/updating_spec.rb +0 -487
  80. data/spec/mirror_spec.rb +0 -119
  81. data/spec/operations_spec.rb +0 -66
  82. data/spec/test_helper.rb +0 -19
@@ -1,126 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require 'mocha/api'
4
-
5
- require 'tempfile'
6
- require 'fileutils'
7
- require 'pathname'
8
-
9
- require File.dirname(__FILE__) + '/../../lib/braid/operations_lite'
10
-
11
- DEFAULT_NAME = 'Your Name'
12
- DEFAULT_EMAIL = 'you@example.com'
13
-
14
- TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
15
- EDITOR_CMD = "#{TMP_PATH}/editor"
16
- BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.parent.realpath
17
- FIXTURE_PATH = File.join(BRAID_PATH, 'spec', 'fixtures')
18
- FileUtils.rm_rf(TMP_PATH)
19
- FileUtils.mkdir_p(TMP_PATH)
20
-
21
- BRAID_BIN = ((defined?(JRUBY_VERSION) || Gem.win_platform?) ? 'ruby ' : '') + File.join(BRAID_PATH, 'bin', 'braid')
22
-
23
- # Use a separate, clean cache for each test case (because TMP_PATH is deleted
24
- # and recreated for each test case). We don't want to mess with the user's real
25
- # cache, and this ensures that previous cache contents can't affect the behavior
26
- # of the tests.
27
- ENV['BRAID_LOCAL_CACHE_DIR'] = File.join(TMP_PATH, 'braid-cache')
28
-
29
- # Must run in a git repository, though we expect the setting to be the same for
30
- # most repositories on a given OS.
31
- def filemode_enabled
32
- run_command('git config core.filemode').strip == 'true'
33
- end
34
-
35
- def with_editor_message(message = 'Make some changes')
36
- File.write(EDITOR_CMD, <<CMD)
37
- #!/usr/bin/env ruby
38
- File.open(ARGV[0], 'w') { |file| file.write(#{message.inspect}) }
39
- CMD
40
- FileUtils.chmod 0755, EDITOR_CMD
41
- Braid::Operations::with_modified_environment({'GIT_EDITOR' => EDITOR_CMD}) do
42
- yield
43
- end
44
- end
45
-
46
- def assert_no_diff(file1, file2, extra_flags = '')
47
- run_command("diff -U 3 #{extra_flags} #{file1} #{file2}")
48
- end
49
-
50
- def assert_commit_attribute(format_key, value, commit_index = 0)
51
- output = run_command("git log --pretty=format:#{format_key}").split("\n")
52
- regex = value.is_a?(Regexp) ? value : /^#{value}$/
53
- expect(output[commit_index]).to match(regex)
54
- end
55
-
56
- def assert_commit_subject(value, commit_index = 0)
57
- assert_commit_attribute('%s', value, commit_index)
58
- end
59
-
60
- def assert_commit_author(value, commit_index = 0)
61
- assert_commit_attribute('%an', value, commit_index)
62
- end
63
-
64
- def assert_commit_email(value, commit_index = 0)
65
- assert_commit_attribute('%ae', value, commit_index)
66
- end
67
-
68
- def in_dir(dir = TMP_PATH)
69
- orig_wd = Dir.pwd
70
- Dir.chdir(dir)
71
- begin
72
- yield
73
- ensure
74
- Dir.chdir(orig_wd)
75
- end
76
- end
77
-
78
- # Note: Do not use single quotes to quote spaces in arguments. They do not work
79
- # on Windows.
80
- def run_command(command)
81
- output = `#{command}`
82
- raise "Error executing command: #{command}\nOutput: #{output}" unless $?.success?
83
- output
84
- end
85
-
86
- def run_command_expect_failure(command)
87
- output = `#{command}`
88
- raise "Expected command to fail but it succeeded: #{command}\nOutput: #{output}" if $?.success?
89
- output
90
- end
91
-
92
- # Rough equivalent of git.require_version within Braid, but without pulling in a
93
- # bunch of dependencies from Braid::Operations. This small amount of code
94
- # duplication seems like a lesser evil than sorting out all the dependencies.
95
- def git_require_version(required)
96
- actual = run_command('git --version').sub(/^.* version/, '').strip
97
- Gem::Version.new(actual) >= Gem::Version.new(required)
98
- end
99
-
100
- def update_dir_from_fixture(dir, fixture = dir)
101
- to_dir = File.join(TMP_PATH, dir)
102
- FileUtils.mkdir_p(to_dir)
103
- FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir, preserve: true)
104
- end
105
-
106
- def create_git_repo_from_fixture(fixture_name, options = {})
107
- directory = options[:directory] || fixture_name
108
- name = options[:name] || DEFAULT_NAME
109
- email = options[:email] || DEFAULT_EMAIL
110
- git_repo = File.join(TMP_PATH, directory)
111
- update_dir_from_fixture(directory, fixture_name)
112
-
113
- in_dir(git_repo) do
114
- # Avoid a warning emitted by because we use the old default default branch name
115
- run_command('git config --global init.defaultBranch master')
116
-
117
- run_command('git init')
118
- run_command("git config --local user.email \"#{email}\"")
119
- run_command("git config --local user.name \"#{name}\"")
120
- run_command('git config --local commit.gpgsign false')
121
- run_command('git add .')
122
- run_command("git commit -m \"initial commit of #{fixture_name}\"")
123
- end
124
-
125
- git_repo
126
- end
@@ -1,402 +0,0 @@
1
- require File.dirname(__FILE__) + '/integration_helper'
2
-
3
- BRAID_PUSH_USES_SPARSE_CHECKOUT = git_require_version('2.27')
4
-
5
- describe 'Pushing to a mirror' do
6
-
7
- # This code needs to run before the `around` hook in the required-filter test
8
- # that sets up the virtual home directory inside TMP_PATH, but per-example
9
- # `before` hooks always run after `around` hooks. So make this an `around`
10
- # hook just to get it to run at the time we want.
11
- around do |example|
12
- FileUtils.rm_rf(TMP_PATH)
13
- FileUtils.mkdir_p(TMP_PATH)
14
- example.run
15
- end
16
-
17
- describe 'from a git repository' do
18
- before do
19
- @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
20
- @vendor_repository_dir = create_git_repo_from_fixture('skit1')
21
- @file_name = 'layouts/layout.liquid'
22
-
23
- in_dir(@repository_dir) do
24
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir}")
25
- end
26
-
27
- in_dir(@vendor_repository_dir) do
28
- run_command('git config receive.denyCurrentBranch updateInstead')
29
- end
30
-
31
- update_dir_from_fixture('shiny/skit1', 'skit1.1')
32
- in_dir(@repository_dir) do
33
- run_command('git add *')
34
- run_command('git commit -m "Make some changes to vendored files"')
35
- end
36
- end
37
-
38
- context 'with remote updtodate' do
39
- it 'should push changes successfully' do
40
- braid_output = nil
41
- commit_message = 'Make some changes'
42
- in_dir(@repository_dir) do
43
- with_editor_message(commit_message) do
44
- braid_output = run_command("#{BRAID_BIN} push skit1")
45
- end
46
- end
47
- expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
48
- expect(braid_output).to match(/Make some changes/)
49
- expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
50
-
51
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
52
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
53
-
54
- in_dir(@vendor_repository_dir) do
55
- run_command('git checkout master 2>&1')
56
-
57
- assert_commit_subject(commit_message)
58
- assert_commit_author('Some body')
59
- assert_commit_email('somebody@example.com')
60
- end
61
- end
62
-
63
- it 'should push changes to specified branch successfully' do
64
- commit_message = 'Make some changes'
65
- braid_output = nil
66
- in_dir(@repository_dir) do
67
- with_editor_message(commit_message) do
68
- braid_output = run_command("#{BRAID_BIN} push skit1 --branch MyBranch")
69
- end
70
- end
71
- expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
72
- expect(braid_output).to match(/Make some changes/)
73
- expect(braid_output).to match(/Braid: Pushing changes to remote branch MyBranch./)
74
-
75
- assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
76
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
77
-
78
- in_dir(@vendor_repository_dir) do
79
- run_command('git checkout MyBranch 2>&1')
80
-
81
- assert_commit_subject(commit_message)
82
- assert_commit_author('Some body')
83
- assert_commit_email('somebody@example.com')
84
- end
85
-
86
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
87
- end
88
- end
89
-
90
- context 'with remote having changes' do
91
- before do
92
- update_dir_from_fixture('skit1', 'skit1.1')
93
- update_dir_from_fixture('skit1', 'skit1.2')
94
- in_dir(@vendor_repository_dir) do
95
- run_command('git add *')
96
- run_command('git commit -m "Update vendored directory"')
97
- end
98
- end
99
- it 'should halt before attempting to push changes' do
100
- braid_output = nil
101
- in_dir(@repository_dir) do
102
- with_editor_message('Make some changes') do
103
- braid_output = run_command("#{BRAID_BIN} push skit1")
104
- end
105
- end
106
- expect(braid_output).to match(/Braid: Mirror is not up to date. Stopping./)
107
-
108
- assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{TMP_PATH}/skit1/#{@file_name}")
109
- end
110
- end
111
- end
112
-
113
- describe 'from a git repository braided into subdirectory' do
114
- before do
115
- @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
116
- @vendor_repository_dir = create_git_repo_from_fixture('skit1')
117
- @file_name = 'layouts/layout.liquid'
118
-
119
- in_dir(@repository_dir) do
120
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts skit-layouts")
121
- end
122
-
123
- in_dir(@vendor_repository_dir) do
124
- run_command('git config receive.denyCurrentBranch updateInstead')
125
- end
126
-
127
- update_dir_from_fixture('shiny/skit-layouts', 'skit1.1/layouts')
128
- in_dir(@repository_dir) do
129
- run_command('git add *')
130
- run_command('git commit -m "Make some changes to vendored files"')
131
- end
132
- end
133
-
134
- context 'with remote updtodate' do
135
- it 'should push changes successfully' do
136
- braid_output = nil
137
- commit_message = 'Make some changes'
138
- in_dir(@repository_dir) do
139
- with_editor_message(commit_message) do
140
- braid_output = run_command("#{BRAID_BIN} push skit-layouts")
141
- end
142
- end
143
- expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
144
- expect(braid_output).to match(/Make some changes/)
145
- expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
146
-
147
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit-layouts/layout.liquid")
148
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
149
-
150
- in_dir(@vendor_repository_dir) do
151
- run_command('git checkout master 2>&1')
152
-
153
- assert_commit_subject(commit_message)
154
- assert_commit_author('Some body')
155
- assert_commit_email('somebody@example.com')
156
- end
157
- end
158
- end
159
- end
160
-
161
- describe 'from a git repository braided into a single file' do
162
- before do
163
- @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
164
- @vendor_repository_dir = create_git_repo_from_fixture('skit1')
165
- @file_name = 'layouts/layout.liquid'
166
-
167
- in_dir(@repository_dir) do
168
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts/layout.liquid skit-layout.liquid")
169
- end
170
-
171
- in_dir(@vendor_repository_dir) do
172
- run_command('git config receive.denyCurrentBranch updateInstead')
173
- end
174
-
175
- FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1x') + '/layouts/layout.liquid', "#{@repository_dir}/skit-layout.liquid",
176
- preserve: true)
177
- in_dir(@repository_dir) do
178
- run_command('git add *')
179
- run_command('git commit -m "Make some changes to vendored files"')
180
- end
181
- end
182
-
183
- context 'with remote updtodate' do
184
- it 'should push changes successfully' do
185
- braid_output = nil
186
- commit_message = 'Make some changes'
187
- in_dir(@repository_dir) do
188
- with_editor_message(commit_message) do
189
- braid_output = run_command("#{BRAID_BIN} push skit-layout.liquid")
190
- end
191
- end
192
- expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
193
- expect(braid_output).to match(/Make some changes/)
194
- expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
195
-
196
- assert_no_diff("#{FIXTURE_PATH}/skit1.1x/#{@file_name}", "#{@repository_dir}/skit-layout.liquid")
197
- assert_no_diff("#{FIXTURE_PATH}/skit1.1x/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
198
-
199
- in_dir(@vendor_repository_dir) do
200
- run_command('git checkout master 2>&1')
201
-
202
- if filemode_enabled
203
- expect(File.stat(@file_name).mode & 0100).to eq(0100)
204
- end
205
-
206
- assert_commit_subject(commit_message)
207
- assert_commit_author('Some body')
208
- assert_commit_email('somebody@example.com')
209
- end
210
- end
211
- end
212
- end
213
-
214
- describe 'from a git repository braided in as a tag' do
215
- before do
216
- @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
217
- @vendor_repository_dir = create_git_repo_from_fixture('skit1')
218
- in_dir(@vendor_repository_dir) do
219
- run_command('git tag v1')
220
- end
221
- @file_name = 'layouts/layout.liquid'
222
-
223
- in_dir(@repository_dir) do
224
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --tag v1")
225
- end
226
-
227
- in_dir(@vendor_repository_dir) do
228
- run_command('git config receive.denyCurrentBranch updateInstead')
229
- end
230
-
231
- update_dir_from_fixture('shiny/skit1', 'skit1.1')
232
- in_dir(@repository_dir) do
233
- run_command('git add *')
234
- run_command('git commit -m "Make some changes to vendored files"')
235
- end
236
- end
237
-
238
- context 'with remote updtodate' do
239
- it 'should fail tring to push without specifying branch' do
240
- braid_output = nil
241
- commit_message = 'Make some changes'
242
- in_dir(@repository_dir) do
243
- with_editor_message(commit_message) do
244
- braid_output = `#{BRAID_BIN} push skit1`
245
- end
246
- end
247
- expect(braid_output).to match(/Braid: Error: mirror is based off a tag. Can not push to a tag: skit1/)
248
-
249
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
250
- assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
251
- end
252
-
253
- it 'should push changes to specified branch successfully' do
254
- commit_message = 'Make some changes'
255
- braid_output = nil
256
- in_dir(@repository_dir) do
257
- with_editor_message(commit_message) do
258
- braid_output = run_command("#{BRAID_BIN} push skit1 --branch MyBranch")
259
- end
260
- end
261
- expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
262
- expect(braid_output).to match(/Make some changes/)
263
- expect(braid_output).to match(/Braid: Pushing changes to remote branch MyBranch./)
264
-
265
- assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
266
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
267
-
268
- in_dir(@vendor_repository_dir) do
269
- run_command('git checkout MyBranch 2>&1')
270
-
271
- assert_commit_subject(commit_message)
272
- assert_commit_author('Some body')
273
- assert_commit_email('somebody@example.com')
274
- end
275
-
276
- assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
277
- end
278
- end
279
-
280
- context 'with remote having changes' do
281
- before do
282
- update_dir_from_fixture('skit1', 'skit1.1')
283
- update_dir_from_fixture('skit1', 'skit1.2')
284
- in_dir(@vendor_repository_dir) do
285
- run_command('git add *')
286
- run_command('git commit -m "Update vendored directory"')
287
- run_command('git tag -f v1')
288
- end
289
- end
290
-
291
- it 'should halt before attempting to push changes' do
292
- braid_output = nil
293
- in_dir(@repository_dir) do
294
- with_editor_message('Make some changes') do
295
- braid_output = run_command("#{BRAID_BIN} push skit1 --branch MyBranch")
296
- end
297
- end
298
- expect(braid_output).to match(/Braid: Mirror is not up to date. Stopping./)
299
-
300
- assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{TMP_PATH}/skit1/#{@file_name}")
301
- end
302
- end
303
- end
304
-
305
- describe 'from a git repository with a required filter', :if => BRAID_PUSH_USES_SPARSE_CHECKOUT do
306
- # This tests that a Git filter that is configured as "required" at the user
307
- # account level but fails without additional repository-level configuration
308
- # (which currently may be the case for Git LFS:
309
- # https://github.com/cristibalan/braid/pull/98) does not interfere with
310
- # pushing using a temporary repository. Braid achieves this by using an
311
- # empty sparse checkout in the temporary repository to avoid triggering the
312
- # filter.
313
-
314
- around do |example|
315
- # In order to simulate configuring the filter at the user account level
316
- # without modifying the user's real Git configuration, we have to
317
- # temporarily change $HOME. Unfortunately, this may break other things
318
- # that need the real $HOME. So far, the only problem we've seen is the
319
- # Braid subprocess not finding Ruby gems, and setting $GEM_PATH seems to
320
- # be a sufficient workaround.
321
- orig_gem_path = run_command('gem environment gempath').strip
322
- virtual_home = File.join(TMP_PATH, 'home')
323
- FileUtils.mkdir_p(virtual_home)
324
- Braid::Operations::with_modified_environment({
325
- 'HOME' => virtual_home,
326
- # If the user has an $XDG_CONFIG_HOME-based configuration file, ensure
327
- # that Git doesn't use it, to maintain consistency with not using the
328
- # original ~/.gitconfig. TODO: Would it be better to `include` both
329
- # files in case they have a setting that we actually need?
330
- 'XDG_CONFIG_HOME' => nil,
331
- 'GEM_PATH' => orig_gem_path
332
- }) do
333
- example.run
334
- end
335
- end
336
-
337
- before do
338
- # create_git_repo_from_fixture('skit1_with_filter') would check out the
339
- # working tree and trigger the broken filter before we have an opportunity
340
- # to turn it off in the repository configuration. Avoiding this problem
341
- # would take some extra code, so as a workaround, we just don't configure
342
- # the filter until after that step. :/
343
- @vendor_repository_dir = create_git_repo_from_fixture('skit1_with_filter')
344
-
345
- # Avoid a warning emitted by because we use the old default default branch name
346
- run_command('git config --global init.defaultBranch master')
347
-
348
- # Configure the broken filter globally. Here, `false` is the command that
349
- # always exits 1.
350
- run_command('git config --global filter.broken.clean false')
351
- run_command('git config --global filter.broken.smudge false')
352
- run_command('git config --global filter.broken.required true')
353
-
354
- # This won't trigger the filter because the .gitattributes file is only in
355
- # the vendor repository.
356
- @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
357
- @file_name = 'layouts/layout.liquid'
358
-
359
- in_dir(@repository_dir) do
360
- # Make the filter a no-op in the superproject repository.
361
- run_command('git config filter.broken.clean cat')
362
- run_command('git config filter.broken.smudge cat')
363
-
364
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} skit1")
365
- end
366
-
367
- in_dir(@vendor_repository_dir) do
368
- run_command('git config receive.denyCurrentBranch updateInstead')
369
- end
370
-
371
- update_dir_from_fixture('shiny/skit1', 'skit1.1_with_filter')
372
- in_dir(@repository_dir) do
373
- run_command('git add *')
374
- run_command('git commit -m "Make some changes to vendored files"')
375
- end
376
- end
377
-
378
- it 'should push changes successfully' do
379
- braid_output = nil
380
- commit_message = 'Make some changes'
381
- in_dir(@repository_dir) do
382
- with_editor_message(commit_message) do
383
- braid_output = run_command("#{BRAID_BIN} push skit1")
384
- end
385
- end
386
- expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
387
- expect(braid_output).to match(/Make some changes/)
388
- expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
389
-
390
- assert_no_diff("#{FIXTURE_PATH}/skit1.1_with_filter/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
391
- assert_no_diff("#{FIXTURE_PATH}/skit1.1_with_filter/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
392
-
393
- in_dir(@vendor_repository_dir) do
394
- run_command('git checkout master 2>&1')
395
-
396
- assert_commit_subject(commit_message)
397
- assert_commit_author('Some body')
398
- assert_commit_email('somebody@example.com')
399
- end
400
- end
401
- end
402
- end
@@ -1,81 +0,0 @@
1
- require File.dirname(__FILE__) + '/integration_helper'
2
-
3
- describe 'Removing a mirror' do
4
- before do
5
- FileUtils.rm_rf(TMP_PATH)
6
- FileUtils.mkdir_p(TMP_PATH)
7
- @repository_dir = create_git_repo_from_fixture('shiny')
8
- @vendor_repository_dir = create_git_repo_from_fixture('skit1')
9
- end
10
-
11
- describe 'braided directly in' do
12
- before do
13
- in_dir(@repository_dir) do
14
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir}")
15
-
16
- # Next line ensure the remote still exists
17
- run_command("#{BRAID_BIN} setup skit1")
18
- end
19
- end
20
-
21
- it 'should remove the files and the remote' do
22
-
23
- assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit1/layouts/layout.liquid")
24
-
25
- in_dir(@repository_dir) do
26
- run_command("#{BRAID_BIN} remove skit1")
27
- end
28
-
29
- expect(File.exist?("#{@repository_dir}/skit1)")).to eq(false)
30
-
31
- braids = YAML::load_file("#{@repository_dir}/.braids.json")
32
- expect(braids['skit1']).to be_nil
33
-
34
- expect(`#{BRAID_BIN} remote | grep skit1`).to eq('')
35
- end
36
- end
37
-
38
- describe 'braiding a subdirectory in' do
39
- before do
40
- in_dir(@repository_dir) do
41
- run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts skit-layouts")
42
- end
43
- end
44
-
45
- it 'should remove the files and the remote' do
46
-
47
- assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit-layouts/layout.liquid")
48
-
49
- in_dir(@repository_dir) do
50
- run_command("#{BRAID_BIN} remove skit-layouts")
51
- end
52
-
53
- expect(File.exist?("#{@repository_dir}/skit-layouts)")).to eq(false)
54
-
55
- braids = YAML::load_file("#{@repository_dir}/.braids.json")
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
79
- end
80
- end
81
- end