braid 1.0.19 → 1.0.20
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/lib/braid.rb +1 -0
- data/lib/braid/commands/push.rb +3 -2
- data/lib/braid/commands/update.rb +6 -3
- data/lib/braid/operations.rb +26 -32
- data/lib/braid/operations_lite.rb +21 -0
- data/lib/braid/version.rb +1 -1
- data/spec/integration/integration_helper.rb +8 -2
- data/spec/integration/push_spec.rb +21 -14
- data/spec/integration/updating_spec.rb +6 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d55b46eb72620ccc9092841609eda270aee04f6
|
4
|
+
data.tar.gz: 684c604750e8774035de42d48c071a9796719be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12781c901dc784fffa89b9d16ff941cafb3d9edc9f32435826a0654529962ea736731bab75959c94d4059357772d69211e2d670f1e848fd7733b92613f359c55
|
7
|
+
data.tar.gz: 5cee8e7cbd85eb2fdc40b8a86dafdb89b2808aa5453a0a832158d1f88b2692a71e892a982d3e5752120497220834e193113cdcadb8ff913191776fb6df7c7586
|
data/lib/braid.rb
CHANGED
data/lib/braid/commands/push.rb
CHANGED
@@ -60,8 +60,9 @@ module Braid
|
|
60
60
|
# worry about them being moved or deleted during the lifetime of this
|
61
61
|
# temporary repository) and faster than fetching from them. We don't
|
62
62
|
# need git.repo_file_path because the temporary repository isn't using
|
63
|
-
# a linked worktree.
|
64
|
-
|
63
|
+
# a linked worktree. Git for Windows seems to want LF and not CRLF in
|
64
|
+
# the alternates file; hope that works for Cygwin Git, etc. too.
|
65
|
+
File.open('.git/objects/info/alternates', 'wb') { |f|
|
65
66
|
f.puts(odb_paths)
|
66
67
|
}
|
67
68
|
git.fetch(remote_url, mirror.remote_ref)
|
@@ -95,9 +95,12 @@ module Braid
|
|
95
95
|
local_hash = git.rev_parse('HEAD')
|
96
96
|
base_hash = generate_tree_hash(mirror, mirror.versioned_path(base_revision))
|
97
97
|
remote_hash = generate_tree_hash(mirror, target_revision)
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
Operations::with_modified_environment({
|
99
|
+
"GITHEAD_#{local_hash}" => 'HEAD',
|
100
|
+
"GITHEAD_#{remote_hash}" => target_revision
|
101
|
+
}) do
|
102
|
+
git.merge_trees(base_hash, local_hash, remote_hash)
|
103
|
+
end
|
101
104
|
rescue Operations::MergeError => error
|
102
105
|
in_error = true
|
103
106
|
print error.conflicts_text
|
data/lib/braid/operations.rb
CHANGED
@@ -110,35 +110,32 @@ module Braid
|
|
110
110
|
def exec(cmd)
|
111
111
|
cmd.strip!
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
113
|
+
Operations::with_modified_environment({'LANG' => 'C'}) do
|
114
|
+
out, err = nil
|
115
|
+
status, pid = 0
|
116
|
+
log(cmd)
|
117
|
+
|
118
|
+
if USE_OPEN3
|
119
|
+
status = nil
|
120
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thread|
|
121
|
+
# Under old jrubies this may sometimes throw an exception
|
122
|
+
stdin.close rescue nil
|
123
|
+
out = stdout.read
|
124
|
+
err = stderr.read
|
125
|
+
# Under earlier jrubies this is not correctly passed so add in check
|
126
|
+
status = wait_thread.value if wait_thread # Process::Status object returned.
|
127
|
+
end
|
128
|
+
# Handle earlier jrubies such as 1.6.7.2
|
129
|
+
status = $?.exitstatus if status.nil?
|
130
|
+
else
|
131
|
+
status = Open4.popen4(cmd) do |pid, stdin, stdout, stderr|
|
132
|
+
out = stdout.read
|
133
|
+
err = stderr.read
|
134
|
+
end.exitstatus
|
129
135
|
end
|
130
|
-
# Handle earlier jrubies such as 1.6.7.2
|
131
|
-
status = $?.exitstatus if status.nil?
|
132
|
-
else
|
133
|
-
status = Open4.popen4(cmd) do |pid, stdin, stdout, stderr|
|
134
|
-
out = stdout.read
|
135
|
-
err = stderr.read
|
136
|
-
end.exitstatus
|
137
|
-
end
|
138
136
|
|
139
|
-
|
140
|
-
|
141
|
-
ENV['LANG'] = previous_lang
|
137
|
+
[status, out, err]
|
138
|
+
end
|
142
139
|
end
|
143
140
|
|
144
141
|
def exec!(cmd)
|
@@ -305,12 +302,9 @@ module Braid
|
|
305
302
|
# Execute a block using a temporary git index file, initially empty.
|
306
303
|
def with_temporary_index
|
307
304
|
Dir.mktmpdir('braid_index') do |dir|
|
308
|
-
|
309
|
-
|
310
|
-
begin
|
305
|
+
Operations::with_modified_environment(
|
306
|
+
{'GIT_INDEX_FILE' => File.join(dir, 'index')}) do
|
311
307
|
yield
|
312
|
-
ensure
|
313
|
-
ENV['GIT_INDEX_FILE'] = orig_index_file
|
314
308
|
end
|
315
309
|
end
|
316
310
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# One helper that is shared with the integration test harness and has no
|
2
|
+
# dependencies on the rest of Braid.
|
3
|
+
module Braid
|
4
|
+
module Operations
|
5
|
+
# Want to use https://github.com/thoughtbot/climate_control ?
|
6
|
+
def self.with_modified_environment(dict)
|
7
|
+
orig_dict = {}
|
8
|
+
dict.each { |name, value|
|
9
|
+
orig_dict[name] = ENV[name]
|
10
|
+
ENV[name] = value
|
11
|
+
}
|
12
|
+
begin
|
13
|
+
yield
|
14
|
+
ensure
|
15
|
+
orig_dict.each { |name, orig_value|
|
16
|
+
ENV[name] = orig_value
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/braid/version.rb
CHANGED
@@ -6,12 +6,13 @@ require 'tempfile'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'pathname'
|
8
8
|
|
9
|
+
require File.dirname(__FILE__) + '/../../lib/braid/operations_lite'
|
10
|
+
|
9
11
|
DEFAULT_NAME = 'Your Name'
|
10
12
|
DEFAULT_EMAIL = 'you@example.com'
|
11
13
|
|
12
14
|
TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
|
13
15
|
EDITOR_CMD = "#{TMP_PATH}/editor"
|
14
|
-
EDITOR_CMD_PREFIX = "export GIT_EDITOR=#{EDITOR_CMD};"
|
15
16
|
BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.parent.realpath
|
16
17
|
FIXTURE_PATH = File.join(BRAID_PATH, 'spec', 'fixtures')
|
17
18
|
FileUtils.rm_rf(TMP_PATH)
|
@@ -19,12 +20,15 @@ FileUtils.mkdir_p(TMP_PATH)
|
|
19
20
|
|
20
21
|
BRAID_BIN = ((defined?(JRUBY_VERSION) || Gem.win_platform?) ? 'ruby ' : '') + File.join(BRAID_PATH, 'bin', 'braid')
|
21
22
|
|
22
|
-
def
|
23
|
+
def with_editor_message(message = 'Make some changes')
|
23
24
|
File.write(EDITOR_CMD, <<CMD)
|
24
25
|
#!/usr/bin/env ruby
|
25
26
|
File.open(ARGV[0], 'w') { |file| file.write(#{message.inspect}) }
|
26
27
|
CMD
|
27
28
|
FileUtils.chmod 0755, EDITOR_CMD
|
29
|
+
Braid::Operations::with_modified_environment({'GIT_EDITOR' => EDITOR_CMD}) do
|
30
|
+
yield
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
def assert_no_diff(file1, file2)
|
@@ -54,6 +58,8 @@ def in_dir(dir = TMP_PATH)
|
|
54
58
|
yield
|
55
59
|
end
|
56
60
|
|
61
|
+
# Note: Do not use single quotes to quote spaces in arguments. They do not work
|
62
|
+
# on Windows.
|
57
63
|
def run_command(command)
|
58
64
|
output = `#{command}`
|
59
65
|
raise "Error executing command: #{command}\nOutput: #{output}" unless $?.success?
|
@@ -33,8 +33,9 @@ describe 'Pushing to a mirror' do
|
|
33
33
|
braid_output = nil
|
34
34
|
commit_message = 'Make some changes'
|
35
35
|
in_dir(@repository_dir) do
|
36
|
-
|
37
|
-
|
36
|
+
with_editor_message(commit_message) do
|
37
|
+
braid_output = run_command("#{BRAID_BIN} push skit1")
|
38
|
+
end
|
38
39
|
end
|
39
40
|
expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
|
40
41
|
expect(braid_output).to match(/Make some changes/)
|
@@ -56,8 +57,9 @@ describe 'Pushing to a mirror' do
|
|
56
57
|
commit_message = 'Make some changes'
|
57
58
|
braid_output = nil
|
58
59
|
in_dir(@repository_dir) do
|
59
|
-
|
60
|
-
|
60
|
+
with_editor_message(commit_message) do
|
61
|
+
braid_output = run_command("#{BRAID_BIN} push skit1 --branch MyBranch")
|
62
|
+
end
|
61
63
|
end
|
62
64
|
expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
|
63
65
|
expect(braid_output).to match(/Make some changes/)
|
@@ -90,8 +92,9 @@ describe 'Pushing to a mirror' do
|
|
90
92
|
it 'should halt before attempting to push changes' do
|
91
93
|
braid_output = nil
|
92
94
|
in_dir(@repository_dir) do
|
93
|
-
|
94
|
-
|
95
|
+
with_editor_message('Make some changes') do
|
96
|
+
braid_output = run_command("#{BRAID_BIN} push skit1")
|
97
|
+
end
|
95
98
|
end
|
96
99
|
expect(braid_output).to match(/Braid: Mirror is not up to date. Stopping./)
|
97
100
|
|
@@ -126,8 +129,9 @@ describe 'Pushing to a mirror' do
|
|
126
129
|
braid_output = nil
|
127
130
|
commit_message = 'Make some changes'
|
128
131
|
in_dir(@repository_dir) do
|
129
|
-
|
130
|
-
|
132
|
+
with_editor_message(commit_message) do
|
133
|
+
braid_output = run_command("#{BRAID_BIN} push skit1")
|
134
|
+
end
|
131
135
|
end
|
132
136
|
expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
|
133
137
|
expect(braid_output).to match(/Make some changes/)
|
@@ -176,8 +180,9 @@ describe 'Pushing to a mirror' do
|
|
176
180
|
braid_output = nil
|
177
181
|
commit_message = 'Make some changes'
|
178
182
|
in_dir(@repository_dir) do
|
179
|
-
|
180
|
-
|
183
|
+
with_editor_message(commit_message) do
|
184
|
+
braid_output = `#{BRAID_BIN} push skit1`
|
185
|
+
end
|
181
186
|
end
|
182
187
|
expect(braid_output).to match(/Braid: Error: mirror is based off a tag. Can not push to a tag: skit1/)
|
183
188
|
|
@@ -189,8 +194,9 @@ describe 'Pushing to a mirror' do
|
|
189
194
|
commit_message = 'Make some changes'
|
190
195
|
braid_output = nil
|
191
196
|
in_dir(@repository_dir) do
|
192
|
-
|
193
|
-
|
197
|
+
with_editor_message(commit_message) do
|
198
|
+
braid_output = run_command("#{BRAID_BIN} push skit1 --branch MyBranch")
|
199
|
+
end
|
194
200
|
end
|
195
201
|
expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
|
196
202
|
expect(braid_output).to match(/Make some changes/)
|
@@ -225,8 +231,9 @@ describe 'Pushing to a mirror' do
|
|
225
231
|
it 'should halt before attempting to push changes' do
|
226
232
|
braid_output = nil
|
227
233
|
in_dir(@repository_dir) do
|
228
|
-
|
229
|
-
|
234
|
+
with_editor_message('Make some changes') do
|
235
|
+
braid_output = run_command("#{BRAID_BIN} push skit1 --branch MyBranch")
|
236
|
+
end
|
230
237
|
end
|
231
238
|
expect(braid_output).to match(/Braid: Mirror is not up to date. Stopping./)
|
232
239
|
|
@@ -95,7 +95,7 @@ describe 'Updating a mirror' do
|
|
95
95
|
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
96
96
|
|
97
97
|
in_dir(@repository_dir) do
|
98
|
-
run_command(
|
98
|
+
run_command('git commit -a -m "mergeable change"')
|
99
99
|
run_command("#{BRAID_BIN} update skit1")
|
100
100
|
end
|
101
101
|
|
@@ -118,12 +118,12 @@ describe 'Updating a mirror' do
|
|
118
118
|
|
119
119
|
braid_output = nil
|
120
120
|
in_dir(@repository_dir) do
|
121
|
-
run_command(
|
121
|
+
run_command('git commit -a -m "conflicting change"')
|
122
122
|
braid_output = run_command("#{BRAID_BIN} update skit1")
|
123
123
|
end
|
124
124
|
expect(braid_output).to match(/Caught merge error\. Breaking\./)
|
125
125
|
|
126
|
-
run_command("grep -q
|
126
|
+
run_command("grep -q \">>>>>>> #{target_revision}\" #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -243,7 +243,7 @@ describe 'Updating a mirror' do
|
|
243
243
|
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
244
244
|
|
245
245
|
in_dir(@repository_dir) do
|
246
|
-
run_command(
|
246
|
+
run_command('git commit -a -m "mergeable change"')
|
247
247
|
run_command("#{BRAID_BIN} update skit1")
|
248
248
|
end
|
249
249
|
|
@@ -266,7 +266,7 @@ describe 'Updating a mirror' do
|
|
266
266
|
|
267
267
|
braid_output = nil
|
268
268
|
in_dir(@repository_dir) do
|
269
|
-
run_command(
|
269
|
+
run_command('git commit -a -m "conflicting change"')
|
270
270
|
braid_output = run_command("#{BRAID_BIN} update skit1")
|
271
271
|
end
|
272
272
|
expect(braid_output).to match(/Caught merge error\. Breaking\./)
|
@@ -338,7 +338,7 @@ describe 'Updating a mirror' do
|
|
338
338
|
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
339
339
|
|
340
340
|
in_dir(@repository_dir) do
|
341
|
-
run_command(
|
341
|
+
run_command('git commit -a -m "mergeable change"')
|
342
342
|
run_command("#{BRAID_BIN} update skit1")
|
343
343
|
end
|
344
344
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cristi Balan
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-05-
|
13
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: main
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/braid/config.rb
|
98
98
|
- lib/braid/mirror.rb
|
99
99
|
- lib/braid/operations.rb
|
100
|
+
- lib/braid/operations_lite.rb
|
100
101
|
- lib/braid/version.rb
|
101
102
|
- spec/config_spec.rb
|
102
103
|
- spec/fixtures/shiny/README
|