braid 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/bin/braid +3 -3
- data/lib/braid/command.rb +1 -0
- data/lib/braid/commands/add.rb +0 -1
- data/lib/braid/commands/update.rb +1 -1
- data/lib/braid/config.rb +19 -12
- data/lib/braid/operations.rb +12 -12
- data/lib/braid/version.rb +1 -1
- data/lib/braid.rb +2 -1
- data/spec/config_spec.rb +22 -22
- data/spec/integration/adding_spec.rb +17 -18
- data/spec/integration/updating_spec.rb +38 -42
- data/spec/integration_helper.rb +3 -3
- data/spec/mirror_spec.rb +22 -22
- data/spec/operations_spec.rb +22 -22
- data/spec/test_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48581b45f4b17cc8b8e621d5e24c841b42efba99
|
4
|
+
data.tar.gz: 7bdfa40b888e48c3d9c7a3a6bbd35dfc4b479495
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b9eaae5700bc0b454099d94765acd1994334c5631ef2546026f76ac6a33e94ab7ffc0a106cb3e502dd6f4cce02785069916747adcbf479a3e762d1a01066905
|
7
|
+
data.tar.gz: 3f6bc0b3237ea79ed1fa49d5f7e846a388dcc03c4655185b6ef93535f387c46108dbe888569825d6999635d3e3540c2f3edb7d62a1d77475ed448d93fab39d57
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ This is where Braid comes into play. Braid makes it easy to vendor in remote git
|
|
34
34
|
repositories and use an automated mechanism for updating the external library
|
35
35
|
and generating patches to upgrade the external library.
|
36
36
|
|
37
|
-
Braid creates a file `.braids` in the root of your repository that contains
|
37
|
+
Braid creates a file `.braids.json` in the root of your repository that contains
|
38
38
|
references to external libraries or mirrors. There are two types of mirrors in
|
39
39
|
Braid: squashed and full. Mirrors are squashed by default, which is what you'll
|
40
40
|
generally want because they're faster and don't pollute your history with
|
data/Rakefile
CHANGED
data/bin/braid
CHANGED
@@ -24,7 +24,7 @@ Main {
|
|
24
24
|
description <<-TXT
|
25
25
|
Add a new mirror to be tracked.
|
26
26
|
|
27
|
-
* adds metadata about the mirror to .braids
|
27
|
+
* adds metadata about the mirror to .braids.json
|
28
28
|
* adds the git remotes to .git/config
|
29
29
|
* fetches and merges remote code into given directory
|
30
30
|
|
@@ -54,7 +54,7 @@ Main {
|
|
54
54
|
|
55
55
|
* get new changes from remote
|
56
56
|
* always creates a merge commit
|
57
|
-
* updates metadata in .braids when revisions are changed
|
57
|
+
* updates metadata in .braids.json when revisions are changed
|
58
58
|
|
59
59
|
Defaults to updating all unlocked mirrors if none is specified.
|
60
60
|
TXT
|
@@ -76,7 +76,7 @@ Main {
|
|
76
76
|
description <<-TXT
|
77
77
|
Remove a mirror.
|
78
78
|
|
79
|
-
* removes metadata from .braids
|
79
|
+
* removes metadata from .braids.json
|
80
80
|
* removes the local directory and commits the removal
|
81
81
|
* removes the git remote by default, --keep can be used to suppress that
|
82
82
|
TXT
|
data/lib/braid/command.rb
CHANGED
data/lib/braid/commands/add.rb
CHANGED
@@ -20,7 +20,7 @@ module Braid
|
|
20
20
|
def update_one(path, options = {})
|
21
21
|
mirror = config.get!(path)
|
22
22
|
|
23
|
-
revision_message = options[
|
23
|
+
revision_message = options['revision'] ? " to #{display_revision(mirror, options['revision'])}" : ''
|
24
24
|
msg "Updating mirror '#{mirror.path}'#{revision_message}."
|
25
25
|
|
26
26
|
was_locked = mirror.locked?
|
data/lib/braid/config.rb
CHANGED
@@ -15,19 +15,25 @@ module Braid
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def initialize(config_file = CONFIG_FILE)
|
18
|
+
def initialize(config_file = CONFIG_FILE, old_config_files = [OLD_CONFIG_FILE])
|
19
19
|
@config_file = config_file
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
(old_config_files + [config_file]).each do |file|
|
21
|
+
next unless File.exist?(file)
|
22
|
+
begin
|
23
|
+
store = YAML::Store.new(file)
|
24
|
+
@db = {}
|
25
|
+
store.transaction(true) do
|
26
|
+
store.roots.each do |path|
|
27
|
+
@db[path] = store[path]
|
28
|
+
end
|
26
29
|
end
|
30
|
+
return
|
31
|
+
rescue
|
32
|
+
@db = JSON.parse(file)
|
33
|
+
return if @db
|
27
34
|
end
|
28
|
-
rescue
|
29
|
-
@db = JSON.parse(@config_file)
|
30
35
|
end
|
36
|
+
@db = {}
|
31
37
|
end
|
32
38
|
|
33
39
|
def add_from_options(url, options)
|
@@ -44,7 +50,7 @@ module Braid
|
|
44
50
|
def get(path)
|
45
51
|
key = path.to_s.sub(/\/$/, '')
|
46
52
|
attributes = @db[key]
|
47
|
-
|
53
|
+
attributes ? Mirror.new(path, attributes) : nil
|
48
54
|
end
|
49
55
|
|
50
56
|
def get!(path)
|
@@ -70,6 +76,7 @@ module Braid
|
|
70
76
|
end
|
71
77
|
|
72
78
|
private
|
79
|
+
|
73
80
|
def write_mirror(mirror)
|
74
81
|
@db[mirror.path] = clean_attributes(mirror.attributes)
|
75
82
|
write_db
|
@@ -80,10 +87,10 @@ module Braid
|
|
80
87
|
@db.keys.sort.each do |key|
|
81
88
|
new_db[key] = @db[key]
|
82
89
|
new_db[key].keys.each do |k|
|
83
|
-
new_db[key].delete(k)
|
90
|
+
new_db[key].delete(k) unless Braid::Mirror::ATTRIBUTES.include?(k)
|
84
91
|
end
|
85
92
|
end
|
86
|
-
File.open(@config_file,
|
93
|
+
File.open(@config_file, 'wb') do |f|
|
87
94
|
f.write JSON.pretty_generate(new_db)
|
88
95
|
f.write "\n"
|
89
96
|
end
|
data/lib/braid/operations.rb
CHANGED
@@ -172,7 +172,7 @@ module Braid
|
|
172
172
|
def commit(message, *args)
|
173
173
|
cmd = 'git commit --no-verify'
|
174
174
|
if message # allow nil
|
175
|
-
message_file = Tempfile.new(
|
175
|
+
message_file = Tempfile.new('braid_commit')
|
176
176
|
message_file.print("Braid: #{message}")
|
177
177
|
message_file.flush
|
178
178
|
message_file.close
|
@@ -257,16 +257,16 @@ module Braid
|
|
257
257
|
# Merge three trees (local_treeish should match the current state of the
|
258
258
|
# index) and update the index and working tree.
|
259
259
|
#
|
260
|
-
# The usage of
|
260
|
+
# The usage of 'git merge-recursive' doesn't seem to be officially
|
261
261
|
# documented, but it does accept trees. When a single base is passed, the
|
262
|
-
#
|
262
|
+
# 'recursive' part (i.e., merge of bases) does not come into play and only
|
263
263
|
# the trees matter. But for some reason, Git's smartest tree merge
|
264
|
-
# algorithm is only available via the
|
264
|
+
# algorithm is only available via the 'recursive' strategy.
|
265
265
|
def merge_trees(base_treeish, local_treeish, remote_treeish)
|
266
266
|
invoke(:merge_recursive, base_treeish, "-- #{local_treeish} #{remote_treeish}")
|
267
267
|
true
|
268
268
|
rescue ShellExecutionError => error
|
269
|
-
#
|
269
|
+
# 'CONFLICT' messages go to stdout.
|
270
270
|
raise MergeError, error.out
|
271
271
|
end
|
272
272
|
|
@@ -290,24 +290,24 @@ module Braid
|
|
290
290
|
# Read tree into the root of the index. This may not be the preferred way
|
291
291
|
# to do it, but it seems to work.
|
292
292
|
def read_tree_im(treeish)
|
293
|
-
invoke(:read_tree,
|
293
|
+
invoke(:read_tree, '-im', treeish)
|
294
294
|
true
|
295
295
|
end
|
296
296
|
|
297
297
|
# Write a tree object for the current index and return its ID.
|
298
|
-
def write_tree
|
298
|
+
def write_tree
|
299
299
|
invoke(:write_tree)
|
300
300
|
end
|
301
301
|
|
302
302
|
# Execute a block using a temporary git index file, initially empty.
|
303
|
-
def with_temporary_index
|
304
|
-
Dir.mktmpdir(
|
305
|
-
orig_index_file = ENV[
|
306
|
-
ENV[
|
303
|
+
def with_temporary_index
|
304
|
+
Dir.mktmpdir('braid_index') do |dir|
|
305
|
+
orig_index_file = ENV['GIT_INDEX_FILE']
|
306
|
+
ENV['GIT_INDEX_FILE'] = File.join(dir, 'index')
|
307
307
|
begin
|
308
308
|
yield
|
309
309
|
ensure
|
310
|
-
ENV[
|
310
|
+
ENV['GIT_INDEX_FILE'] = orig_index_file
|
311
311
|
end
|
312
312
|
end
|
313
313
|
end
|
data/lib/braid/version.rb
CHANGED
data/lib/braid.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Braid::Config, when empty' do
|
4
4
|
before(:each) do
|
5
|
-
@config = Braid::Config.new(
|
5
|
+
@config = Braid::Config.new('tmp.yml')
|
6
6
|
end
|
7
7
|
|
8
8
|
after(:each) do
|
9
|
-
FileUtils.rm(
|
9
|
+
FileUtils.rm('tmp.yml') rescue nil
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
13
|
-
@config.get(
|
14
|
-
lambda { @config.get!(
|
12
|
+
it 'should not get a mirror by name' do
|
13
|
+
@config.get('path').should be_nil
|
14
|
+
lambda { @config.get!('path') }.should raise_error(Braid::Config::MirrorDoesNotExist)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'should add a mirror and its params' do
|
18
18
|
@mirror = build_mirror
|
19
19
|
@config.add(@mirror)
|
20
|
-
@config.get(
|
20
|
+
@config.get('path').path.should_not be_nil
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe 'Braid::Config, with one mirror' do
|
25
25
|
before(:each) do
|
26
|
-
@config = Braid::Config.new(
|
26
|
+
@config = Braid::Config.new('tmp.yml')
|
27
27
|
@mirror = build_mirror
|
28
28
|
@config.add(@mirror)
|
29
29
|
end
|
30
30
|
|
31
31
|
after(:each) do
|
32
|
-
FileUtils.rm(
|
32
|
+
FileUtils.rm('tmp.yml') rescue nil
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
36
|
-
@config.get(
|
37
|
-
@config.get!(
|
35
|
+
it 'should get the mirror by name' do
|
36
|
+
@config.get('path').should == @mirror
|
37
|
+
@config.get!('path').should == @mirror
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'should raise when trying to overwrite a mirror on add' do
|
41
41
|
lambda { @config.add(@mirror) }.should raise_error(Braid::Config::PathAlreadyInUse)
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it 'should remove the mirror' do
|
45
45
|
@config.remove(@mirror)
|
46
|
-
@config.get(
|
46
|
+
@config.get('path').should be_nil
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
50
|
-
@mirror.branch =
|
49
|
+
it 'should update the mirror with new params' do
|
50
|
+
@mirror.branch = 'other'
|
51
51
|
@config.update(@mirror)
|
52
|
-
@config.get(
|
52
|
+
@config.get('path').attributes.should == {'branch' => 'other'}
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
@mirror.instance_variable_set(
|
55
|
+
it 'should raise when trying to update nonexistent mirror' do
|
56
|
+
@mirror.instance_variable_set('@path', 'other')
|
57
57
|
lambda { @config.update(@mirror) }.should raise_error(Braid::Config::MirrorDoesNotExist)
|
58
58
|
end
|
59
59
|
end
|
@@ -1,43 +1,42 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../integration_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Adding a mirror in a clean repository' do
|
4
4
|
|
5
5
|
before do
|
6
6
|
FileUtils.rm_rf(TMP_PATH)
|
7
7
|
FileUtils.mkdir_p(TMP_PATH)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'from a git repository' do
|
11
11
|
before do
|
12
|
-
@shiny = create_git_repo_from_fixture(
|
13
|
-
@skit1 = create_git_repo_from_fixture(
|
12
|
+
@shiny = create_git_repo_from_fixture('shiny')
|
13
|
+
@skit1 = create_git_repo_from_fixture('skit1')
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should add the files and commit' do
|
17
17
|
in_dir(@shiny) do
|
18
|
-
|
18
|
+
run_command("#{BRAID_BIN} add #{@skit1}")
|
19
19
|
end
|
20
20
|
|
21
|
-
file_name =
|
22
|
-
|
23
|
-
$?.should be_success
|
21
|
+
file_name = 'skit1/layouts/layout.liquid'
|
22
|
+
run_command("diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, 'shiny', file_name)}")
|
24
23
|
|
25
|
-
output =
|
24
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
26
25
|
output.length.should == 2
|
27
26
|
output[0].should =~ /Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
29
|
+
it 'should create .braids.json and add the mirror to it' do
|
31
30
|
in_dir(@shiny) do
|
32
|
-
|
31
|
+
run_command("#{BRAID_BIN} add #{@skit1}")
|
33
32
|
end
|
34
33
|
|
35
|
-
braids = YAML::load_file("#{@shiny}
|
36
|
-
braids[
|
37
|
-
braids[
|
38
|
-
braids[
|
39
|
-
braids[
|
40
|
-
braids[
|
34
|
+
braids = YAML::load_file("#{@shiny}/#{Braid::CONFIG_FILE}")
|
35
|
+
braids['skit1']['squashed'].should == true
|
36
|
+
braids['skit1']['url'].should == @skit1
|
37
|
+
braids['skit1']['revision'].should_not be_nil
|
38
|
+
braids['skit1']['branch'].should == 'master'
|
39
|
+
braids['skit1']['remote'].should == 'master/braid/skit1'
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
@@ -1,46 +1,44 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../integration_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Updating a mirror' do
|
4
4
|
|
5
5
|
before do
|
6
6
|
FileUtils.rm_rf(TMP_PATH)
|
7
7
|
FileUtils.mkdir_p(TMP_PATH)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'from a git repository' do
|
11
11
|
before do
|
12
|
-
@shiny = create_git_repo_from_fixture(
|
13
|
-
@skit1 = create_git_repo_from_fixture(
|
14
|
-
@file_name =
|
12
|
+
@shiny = create_git_repo_from_fixture('shiny')
|
13
|
+
@skit1 = create_git_repo_from_fixture('skit1')
|
14
|
+
@file_name = 'layouts/layout.liquid'
|
15
15
|
|
16
16
|
in_dir(@shiny) do
|
17
|
-
|
17
|
+
run_command("#{BRAID_BIN} add #{@skit1}")
|
18
18
|
end
|
19
19
|
|
20
|
-
update_dir_from_fixture(
|
20
|
+
update_dir_from_fixture('skit1', 'skit1.1')
|
21
21
|
in_dir(@skit1) do
|
22
|
-
|
23
|
-
|
22
|
+
run_command('git add *')
|
23
|
+
run_command('git commit -m "change default color"')
|
24
24
|
end
|
25
25
|
|
26
|
-
update_dir_from_fixture(
|
26
|
+
update_dir_from_fixture('skit1', 'skit1.2')
|
27
27
|
in_dir(@skit1) do
|
28
|
-
|
29
|
-
|
28
|
+
run_command('git add *')
|
29
|
+
run_command('git commit -m "add a happy note"')
|
30
30
|
end
|
31
|
-
|
32
31
|
end
|
33
32
|
|
34
|
-
context
|
35
|
-
it
|
33
|
+
context 'with no project-specific changes' do
|
34
|
+
it 'should add the files and commit' do
|
36
35
|
in_dir(@shiny) do
|
37
|
-
|
36
|
+
run_command("#{BRAID_BIN} update skit1")
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
|
-
$?.should be_success
|
39
|
+
run_command("diff -U 3 #{File.join(FIXTURE_PATH, 'skit1.2', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
42
40
|
|
43
|
-
output =
|
41
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
44
42
|
output.length.should == 3
|
45
43
|
output[0].should =~ /Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/
|
46
44
|
|
@@ -50,55 +48,53 @@ describe "Updating a mirror" do
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
context
|
54
|
-
it
|
55
|
-
|
51
|
+
context 'with mergeable changes to the same file' do
|
52
|
+
it 'should auto-merge and commit' do
|
53
|
+
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
56
54
|
|
57
55
|
in_dir(@shiny) do
|
58
|
-
|
59
|
-
|
56
|
+
run_command("git commit -a -m 'mergeable change'")
|
57
|
+
run_command("#{BRAID_BIN} update skit1")
|
60
58
|
end
|
61
59
|
|
62
|
-
|
63
|
-
$?.should be_success
|
60
|
+
run_command("diff -U 3 #{File.join(FIXTURE_PATH, 'shiny_skit1.2_merged', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
64
61
|
|
65
|
-
output =
|
62
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
66
63
|
output.length.should == 4 # plus 'mergeable change'
|
67
64
|
output[0].should =~ /Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/
|
68
65
|
end
|
69
66
|
end
|
70
67
|
|
71
|
-
context
|
72
|
-
it
|
73
|
-
|
68
|
+
context 'with conflicting changes' do
|
69
|
+
it 'should leave conflict markup with the target revision' do
|
70
|
+
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_conflicting', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
74
71
|
|
75
72
|
target_revision = nil
|
76
73
|
in_dir(@skit1) do
|
77
|
-
target_revision =
|
74
|
+
target_revision = run_command('git rev-parse HEAD')
|
78
75
|
end
|
79
76
|
|
80
77
|
braid_output = nil
|
81
78
|
in_dir(@shiny) do
|
82
|
-
|
83
|
-
braid_output =
|
79
|
+
run_command("git commit -a -m 'conflicting change'")
|
80
|
+
braid_output = run_command("#{BRAID_BIN} update skit1")
|
84
81
|
end
|
85
82
|
braid_output.should =~ /Caught merge error\. Breaking\./
|
86
83
|
|
87
|
-
|
88
|
-
$?.should be_success
|
84
|
+
run_command("grep -q '>>>>>>> #{target_revision}' #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
89
85
|
end
|
90
86
|
end
|
91
87
|
|
92
88
|
# Regression test for https://github.com/cristibalan/braid/issues/41.
|
93
|
-
context
|
94
|
-
it
|
89
|
+
context 'with a convergent deletion' do
|
90
|
+
it 'should not detect a bogus rename' do
|
95
91
|
in_dir(@skit1) do
|
96
|
-
|
97
|
-
|
92
|
+
run_command('git rm layouts/layout.liquid')
|
93
|
+
run_command('git commit -m "delete"')
|
98
94
|
end
|
99
95
|
in_dir(@shiny) do
|
100
|
-
|
101
|
-
|
96
|
+
run_command('git rm skit1/layouts/layout.liquid')
|
97
|
+
run_command('git commit -m "delete here too"')
|
102
98
|
end
|
103
99
|
|
104
100
|
# Without the fix, when git diffs the base and local trees, it will
|
@@ -106,7 +102,7 @@ describe "Updating a mirror" do
|
|
106
102
|
# other-skit/layout.liquid, resulting in a rename-delete conflict.
|
107
103
|
braid_output = nil
|
108
104
|
in_dir(@shiny) do
|
109
|
-
braid_output =
|
105
|
+
braid_output = run_command("#{BRAID_BIN} update skit1")
|
110
106
|
end
|
111
107
|
braid_output.should_not =~ /Caught merge error\. Breaking\./
|
112
108
|
end
|
data/spec/integration_helper.rb
CHANGED
@@ -6,9 +6,9 @@ require 'tempfile'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'pathname'
|
8
8
|
|
9
|
-
TMP_PATH = File.join(Dir.tmpdir,
|
9
|
+
TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
|
10
10
|
BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
|
11
|
-
FIXTURE_PATH = File.join(BRAID_PATH,
|
11
|
+
FIXTURE_PATH = File.join(BRAID_PATH, 'spec', 'fixtures')
|
12
12
|
FileUtils.rm_rf(TMP_PATH)
|
13
13
|
FileUtils.mkdir_p(TMP_PATH)
|
14
14
|
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
def update_dir_from_fixture(dir, fixture = dir)
|
29
29
|
to_dir = File.join(TMP_PATH, dir)
|
30
30
|
FileUtils.mkdir_p(to_dir)
|
31
|
-
FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) +
|
31
|
+
FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir)
|
32
32
|
end
|
33
33
|
|
34
34
|
def create_git_repo_from_fixture(fixture_name)
|
data/spec/mirror_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
5
|
-
new_from_options(
|
6
|
-
@mirror.branch.should ==
|
3
|
+
describe 'Braid::Mirror.new_from_options' do
|
4
|
+
it 'should default branch to master' do
|
5
|
+
new_from_options('git://path')
|
6
|
+
@mirror.branch.should == 'master'
|
7
7
|
end
|
8
8
|
|
9
|
-
it
|
10
|
-
new_from_options(
|
11
|
-
@mirror.path.should ==
|
9
|
+
it 'should default mirror to last path part, ignoring trailing .git' do
|
10
|
+
new_from_options('http://path.git')
|
11
|
+
@mirror.path.should == 'path'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe 'Braid::Mirror#diff' do
|
16
16
|
before(:each) do
|
17
17
|
@mirror = build_mirror('revision' => 'a' * 40, 'url' => 'git://path')
|
18
18
|
@mirror.stubs(:base_revision).returns(@mirror.revision) # bypass rev_parse
|
@@ -23,14 +23,14 @@ describe "Braid::Mirror#diff" do
|
|
23
23
|
git.expects(:tree_hash).with(@mirror.path).returns(local_hash)
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should return an empty string when the hashes match' do
|
27
27
|
set_hashes('b' * 40, 'b' * 40)
|
28
28
|
git.expects(:fetch)
|
29
29
|
git.expects(:diff_tree).never
|
30
|
-
@mirror.diff.should ==
|
30
|
+
@mirror.diff.should == ''
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'should generate a diff when the hashes do not match' do
|
34
34
|
set_hashes('b' * 40, 'c' * 40)
|
35
35
|
diff = "diff --git a/path b/path\n"
|
36
36
|
git.expects(:fetch)
|
@@ -39,24 +39,24 @@ describe "Braid::Mirror#diff" do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
43
|
-
it
|
42
|
+
describe 'Braid::Mirror#base_revision' do
|
43
|
+
it 'should be inferred when no revision is set' do
|
44
44
|
@mirror = build_mirror
|
45
45
|
@mirror.revision.should be_nil
|
46
46
|
@mirror.expects(:inferred_revision).returns('b' * 40)
|
47
47
|
@mirror.base_revision.should == 'b' * 40
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
@mirror = build_mirror(
|
50
|
+
it 'should be the parsed hash for git mirrors' do
|
51
|
+
@mirror = build_mirror('revision' => 'a' * 7)
|
52
52
|
git.expects(:rev_parse).with('a' * 7).returns('a' * 40)
|
53
53
|
@mirror.base_revision.should == 'a' * 40
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe
|
58
|
-
it
|
59
|
-
@mirror = new_from_options(
|
57
|
+
describe 'Braid::Mirror#inferred_revision' do
|
58
|
+
it 'should return the last commit before the most recent update' do
|
59
|
+
@mirror = new_from_options('git://path')
|
60
60
|
git.expects(:rev_list).times(2).returns(
|
61
61
|
"#{'a' * 40}\n",
|
62
62
|
"commit #{'b' * 40}\n#{'t' * 40}\n"
|
@@ -66,17 +66,17 @@ describe "Braid::Mirror#inferred_revision" do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe
|
69
|
+
describe 'Braid::Mirror#cached?' do
|
70
70
|
before(:each) do
|
71
|
-
@mirror = new_from_options(
|
71
|
+
@mirror = new_from_options('git://path')
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'should be true when the remote path matches the cache path' do
|
75
75
|
git.expects(:remote_url).with(@mirror.remote).returns(git_cache.path(@mirror.url))
|
76
76
|
@mirror.should be_cached
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
79
|
+
it 'should be false if the remote does not point to the cache' do
|
80
80
|
git.expects(:remote_url).with(@mirror.remote).returns(@mirror.url)
|
81
81
|
@mirror.should_not be_cached
|
82
82
|
end
|
data/spec/operations_spec.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
3
|
+
describe 'Braid::Operations::Git#remote_url' do
|
4
|
+
it 'should use git config' do
|
5
5
|
# FIXME weak test
|
6
|
-
git.stubs(:invoke).with(:config, 'remote.braid/git/one.url').returns(
|
7
|
-
git.remote_url(
|
6
|
+
git.stubs(:invoke).with(:config, 'remote.braid/git/one.url').returns('git://path')
|
7
|
+
git.remote_url('braid/git/one').should == 'git://path'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it
|
11
|
+
describe 'Braid::Operations::Git#rev_parse' do
|
12
|
+
it 'should return the full hash when a hash is found' do
|
13
13
|
full_revision = 'a' * 40
|
14
|
-
git.expects(:exec).returns([0, full_revision,
|
14
|
+
git.expects(:exec).returns([0, full_revision, ''])
|
15
15
|
git.rev_parse('a' * 7).should == full_revision
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'should raise a revision error when the hash is not found' do
|
19
19
|
ambiguous_revision = 'b' * 7
|
20
|
-
git.expects(:exec).returns([1, ambiguous_revision,
|
20
|
+
git.expects(:exec).returns([1, ambiguous_revision, 'fatal: ...'])
|
21
21
|
lambda { git.rev_parse(ambiguous_revision) }.should raise_error(Braid::Operations::UnknownRevision)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
26
|
-
ACTUAL_VERSION =
|
25
|
+
describe 'Braid::Operations::Git#version' do
|
26
|
+
ACTUAL_VERSION = '1.5.5.1.98.gf0ec4'
|
27
27
|
|
28
28
|
before(:each) do
|
29
|
-
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n",
|
29
|
+
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", ''])
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'should extract from git --version output' do
|
33
33
|
git.version.should == ACTUAL_VERSION
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
38
|
-
REQUIRED_VERSION =
|
37
|
+
describe 'Braid::Operations::Git#require_version' do
|
38
|
+
REQUIRED_VERSION = '1.5.4.5'
|
39
39
|
PASS_VERSIONS = %w(1.5.4.6 1.5.5 1.6 1.5.4.5.2 1.5.5.1.98.gf0ec4)
|
40
40
|
FAIL_VERSIONS = %w(1.5.4.4 1.5.4 1.5.3 1.4.5.6)
|
41
41
|
|
42
42
|
def set_version(str)
|
43
|
-
git.expects(:exec).returns([0, "git version #{str}\n",
|
43
|
+
git.expects(:exec).returns([0, "git version #{str}\n", ''])
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'should return true for higher revisions' do
|
47
47
|
PASS_VERSIONS.each do |version|
|
48
48
|
set_version(version)
|
49
49
|
git.require_version(REQUIRED_VERSION).should == true
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it 'should return false for lower revisions' do
|
54
54
|
FAIL_VERSIONS.each do |version|
|
55
55
|
set_version(version)
|
56
56
|
git.require_version(REQUIRED_VERSION).should == false
|
@@ -58,9 +58,9 @@ describe "Braid::Operations::Git#require_version" do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
describe
|
62
|
-
it
|
63
|
-
git_cache.path(
|
64
|
-
git_cache.path(
|
61
|
+
describe 'Braid::Operations::GitCache#path' do
|
62
|
+
it 'should use the local cache directory and strip characters' do
|
63
|
+
git_cache.path('git://path').should == File.join(Braid.local_cache_dir, 'git___path')
|
64
|
+
git_cache.path('git@domain:repository.git').should == File.join(Braid.local_cache_dir, 'git_domain_repository.git')
|
65
65
|
end
|
66
66
|
end
|
data/spec/test_helper.rb
CHANGED
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.9
|
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-
|
13
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: main
|