braid 1.1.6 → 1.1.7
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/exe/braid +11 -0
- data/lib/braid/check_gem.rb +58 -0
- data/lib/braid/command.rb +13 -0
- data/lib/braid/commands/diff.rb +1 -1
- data/lib/braid/config.rb +28 -4
- data/{bin/braid → lib/braid/main.rb} +1 -16
- data/lib/braid/mirror.rb +110 -23
- data/lib/braid/operations.rb +5 -4
- data/lib/braid/operations_lite.rb +19 -1
- data/lib/braid/sorbet/fake_runtime.rb +68 -0
- data/lib/braid/sorbet/setup.rb +18 -0
- data/lib/braid/version.rb +1 -1
- data/lib/braid.rb +21 -0
- metadata +12 -75
- data/.gitignore +0 -16
- data/.travis.yml +0 -15
- data/CONTRIBUTING.md +0 -24
- data/Gemfile +0 -3
- data/README.md +0 -234
- data/Rakefile +0 -12
- data/_config.yml +0 -1
- data/braid.gemspec +0 -35
- data/braids-json.schema.json +0 -91
- data/config_versions.md +0 -58
- data/spec/config_spec.rb +0 -59
- data/spec/fixtures/shiny/README +0 -3
- data/spec/fixtures/shiny/other-skit/layout.liquid +0 -219
- data/spec/fixtures/shiny/skit-layout.liquid.test +0 -2
- data/spec/fixtures/shiny/skit1.test +0 -2
- data/spec/fixtures/shiny-conf-1.0.9-lock/.braids.json +0 -10
- data/spec/fixtures/shiny-conf-1.0.9-lock/expected.braids.json +0 -9
- data/spec/fixtures/shiny-conf-1.0.9-lock/skit1/layouts/layout.liquid +0 -219
- data/spec/fixtures/shiny-conf-1.0.9-lock/skit1/preview.png +0 -0
- data/spec/fixtures/shiny-conf-breaking-changes/.braids +0 -14
- data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/README.md +0 -9
- data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/index.html +0 -20
- data/spec/fixtures/shiny-conf-breaking-changes/Spoon-Knife/styles.css +0 -17
- data/spec/fixtures/shiny-conf-breaking-changes/expected.braids.json +0 -10
- data/spec/fixtures/shiny-conf-breaking-changes/skit1/layouts/layout.liquid +0 -219
- data/spec/fixtures/shiny-conf-breaking-changes/skit1/preview.png +0 -0
- data/spec/fixtures/shiny-conf-future/.braids.json +0 -10
- data/spec/fixtures/shiny-conf-future/skit1/layouts/layout.liquid +0 -219
- data/spec/fixtures/shiny-conf-future/skit1/preview.png +0 -0
- data/spec/fixtures/shiny-conf-json-old-name/.braids +0 -9
- data/spec/fixtures/shiny-conf-json-old-name/expected.braids.json +0 -10
- data/spec/fixtures/shiny-conf-json-old-name/skit1/layouts/layout.liquid +0 -219
- data/spec/fixtures/shiny-conf-json-old-name/skit1/preview.png +0 -0
- data/spec/fixtures/shiny-conf-yaml/.braids +0 -8
- data/spec/fixtures/shiny-conf-yaml/expected.braids.json +0 -10
- data/spec/fixtures/shiny-conf-yaml/skit1/layouts/layout.liquid +0 -219
- data/spec/fixtures/shiny-conf-yaml/skit1/preview.png +0 -0
- data/spec/fixtures/shiny_skit1.2_merged/layouts/layout.liquid +0 -223
- data/spec/fixtures/shiny_skit1.2_merged/preview.png +0 -0
- data/spec/fixtures/shiny_skit1_conflicting/layouts/layout.liquid +0 -221
- data/spec/fixtures/shiny_skit1_conflicting/preview.png +0 -0
- data/spec/fixtures/shiny_skit1_mergeable/layouts/layout.liquid +0 -221
- data/spec/fixtures/shiny_skit1_mergeable/preview.png +0 -0
- data/spec/fixtures/skit1/layouts/layout.liquid +0 -219
- data/spec/fixtures/skit1/preview.png +0 -0
- data/spec/fixtures/skit1.1/layouts/layout.liquid +0 -219
- data/spec/fixtures/skit1.1_with_filter/.gitattributes +0 -1
- data/spec/fixtures/skit1.1_with_filter/layouts/layout.liquid +0 -219
- data/spec/fixtures/skit1.1_with_filter/preview.png +0 -0
- data/spec/fixtures/skit1.1x/layouts/layout.liquid +0 -219
- data/spec/fixtures/skit1.2/layouts/layout.liquid +0 -221
- data/spec/fixtures/skit1.3/layouts/README.md +0 -1
- data/spec/fixtures/skit1.3/layouts/layout.liquid +0 -221
- data/spec/fixtures/skit1_with_filter/.gitattributes +0 -1
- data/spec/fixtures/skit1_with_filter/layouts/layout.liquid +0 -219
- data/spec/fixtures/skit1_with_filter/preview.png +0 -0
- data/spec/integration/adding_spec.rb +0 -230
- data/spec/integration/config_versioning_spec.rb +0 -222
- data/spec/integration/diff_spec.rb +0 -597
- data/spec/integration/integration_helper.rb +0 -129
- data/spec/integration/push_spec.rb +0 -399
- data/spec/integration/remove_spec.rb +0 -81
- data/spec/integration/status_spec.rb +0 -165
- data/spec/integration/updating_spec.rb +0 -487
- data/spec/mirror_spec.rb +0 -119
- data/spec/operations_spec.rb +0 -66
- data/spec/test_helper.rb +0 -19
@@ -1,129 +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.sub(/ .*$/, '').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
|
-
# If we don't specify the initial branch name, Git >= 2.30 warns that the
|
115
|
-
# default of `master` is subject to change. We're still using `master` for
|
116
|
-
# now, so avoid the warning by specifying it explicitly. Git >= 2.28 honors
|
117
|
-
# init.defaultBranch, while older versions of Git ignore it and are
|
118
|
-
# hard-coded to use `master`. (Using the `--initial-branch=master` option
|
119
|
-
# would cause an error on Git < 2.28, so we don't do that.)
|
120
|
-
run_command('git -c init.defaultBranch=master init')
|
121
|
-
run_command("git config --local user.email \"#{email}\"")
|
122
|
-
run_command("git config --local user.name \"#{name}\"")
|
123
|
-
run_command('git config --local commit.gpgsign false')
|
124
|
-
run_command('git add .')
|
125
|
-
run_command("git commit -m \"initial commit of #{fixture_name}\"")
|
126
|
-
end
|
127
|
-
|
128
|
-
git_repo
|
129
|
-
end
|
@@ -1,399 +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
|
-
# Configure the broken filter globally. Here, `false` is the command that
|
346
|
-
# always exits 1.
|
347
|
-
run_command('git config --global filter.broken.clean false')
|
348
|
-
run_command('git config --global filter.broken.smudge false')
|
349
|
-
run_command('git config --global filter.broken.required true')
|
350
|
-
|
351
|
-
# This won't trigger the filter because the .gitattributes file is only in
|
352
|
-
# the vendor repository.
|
353
|
-
@repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
|
354
|
-
@file_name = 'layouts/layout.liquid'
|
355
|
-
|
356
|
-
in_dir(@repository_dir) do
|
357
|
-
# Make the filter a no-op in the superproject repository.
|
358
|
-
run_command('git config filter.broken.clean cat')
|
359
|
-
run_command('git config filter.broken.smudge cat')
|
360
|
-
|
361
|
-
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} skit1")
|
362
|
-
end
|
363
|
-
|
364
|
-
in_dir(@vendor_repository_dir) do
|
365
|
-
run_command('git config receive.denyCurrentBranch updateInstead')
|
366
|
-
end
|
367
|
-
|
368
|
-
update_dir_from_fixture('shiny/skit1', 'skit1.1_with_filter')
|
369
|
-
in_dir(@repository_dir) do
|
370
|
-
run_command('git add *')
|
371
|
-
run_command('git commit -m "Make some changes to vendored files"')
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
it 'should push changes successfully' do
|
376
|
-
braid_output = nil
|
377
|
-
commit_message = 'Make some changes'
|
378
|
-
in_dir(@repository_dir) do
|
379
|
-
with_editor_message(commit_message) do
|
380
|
-
braid_output = run_command("#{BRAID_BIN} push skit1")
|
381
|
-
end
|
382
|
-
end
|
383
|
-
expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
|
384
|
-
expect(braid_output).to match(/Make some changes/)
|
385
|
-
expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
|
386
|
-
|
387
|
-
assert_no_diff("#{FIXTURE_PATH}/skit1.1_with_filter/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
388
|
-
assert_no_diff("#{FIXTURE_PATH}/skit1.1_with_filter/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
|
389
|
-
|
390
|
-
in_dir(@vendor_repository_dir) do
|
391
|
-
run_command('git checkout master 2>&1')
|
392
|
-
|
393
|
-
assert_commit_subject(commit_message)
|
394
|
-
assert_commit_author('Some body')
|
395
|
-
assert_commit_email('somebody@example.com')
|
396
|
-
end
|
397
|
-
end
|
398
|
-
end
|
399
|
-
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
|