braid 1.0.16 → 1.0.17

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.
@@ -0,0 +1,185 @@
1
+ require File.dirname(__FILE__) + '/integration_helper'
2
+
3
+ describe 'Running braid diff on 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
+ end
16
+ end
17
+
18
+ describe 'with no changes' do
19
+ it 'should emit no output when named in braid diff' do
20
+ diff = nil
21
+ in_dir(@repository_dir) do
22
+ diff = run_command("#{BRAID_BIN} diff skit1")
23
+ end
24
+
25
+ expect(diff).to eq('')
26
+ end
27
+
28
+ it 'should emit only banners when braid diff all' do
29
+ diff = nil
30
+ in_dir(@repository_dir) do
31
+ diff = run_command("#{BRAID_BIN} diff")
32
+ end
33
+
34
+ expect(diff).to eq("=======================================================\nBraid: Diffing skit1\n=======================================================\n")
35
+ end
36
+ end
37
+
38
+ describe 'with changes' do
39
+ before do
40
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/.', "#{@repository_dir}/skit1")
41
+ in_dir(@repository_dir) do
42
+ run_command('git add *')
43
+ run_command('git commit -m "Some local changes"')
44
+ end
45
+ end
46
+
47
+ it 'should emit diff when named in braid diff' do
48
+ diff = nil
49
+ in_dir(@repository_dir) do
50
+ diff = run_command("#{BRAID_BIN} diff skit1")
51
+ end
52
+
53
+ expect(diff).to eq(<<PATCH)
54
+ diff --git a/layouts/layout.liquid b/layouts/layout.liquid
55
+ index 9f75009..25a4b32 100644
56
+ --- a/layouts/layout.liquid
57
+ +++ b/layouts/layout.liquid
58
+ @@ -22,7 +22,7 @@
59
+ <![endif]-->
60
+ </head>
61
+
62
+ -<body class="fixed orange">
63
+ +<body class="fixed green">
64
+ <script type="text/javascript">loadPreferences()</script>
65
+
66
+ <div id="wrapper">
67
+ PATCH
68
+ end
69
+
70
+ it 'should emit only banners when braid diff all' do
71
+ diff = nil
72
+ in_dir(@repository_dir) do
73
+ diff = run_command("#{BRAID_BIN} diff")
74
+ end
75
+
76
+ expect(diff).to eq(<<PATCH)
77
+ =======================================================
78
+ Braid: Diffing skit1
79
+ =======================================================
80
+ diff --git a/layouts/layout.liquid b/layouts/layout.liquid
81
+ index 9f75009..25a4b32 100644
82
+ --- a/layouts/layout.liquid
83
+ +++ b/layouts/layout.liquid
84
+ @@ -22,7 +22,7 @@
85
+ <![endif]-->
86
+ </head>
87
+
88
+ -<body class="fixed orange">
89
+ +<body class="fixed green">
90
+ <script type="text/javascript">loadPreferences()</script>
91
+
92
+ <div id="wrapper">
93
+ PATCH
94
+ end
95
+ end
96
+ end
97
+
98
+ describe 'braided subdirectory into' do
99
+ before do
100
+ in_dir(@repository_dir) do
101
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
102
+ end
103
+ end
104
+
105
+ describe 'with no changes' do
106
+ it 'should emit no output when named in braid diff' do
107
+ diff = nil
108
+ in_dir(@repository_dir) do
109
+ diff = run_command("#{BRAID_BIN} diff skit1")
110
+ end
111
+
112
+ expect(diff).to eq('')
113
+ end
114
+
115
+ it 'should emit only banners when braid diff all' do
116
+ diff = nil
117
+ in_dir(@repository_dir) do
118
+ diff = run_command("#{BRAID_BIN} diff")
119
+ end
120
+
121
+ expect(diff).to eq("=======================================================\nBraid: Diffing skit1\n=======================================================\n")
122
+ end
123
+ end
124
+
125
+
126
+ describe 'with changes' do
127
+ before do
128
+ FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/layouts/.', "#{@repository_dir}/skit1")
129
+ in_dir(@repository_dir) do
130
+ run_command('git add *')
131
+ run_command('git commit -m "Some local changes"')
132
+ end
133
+ end
134
+
135
+ it 'should emit diff when named in braid diff' do
136
+ diff = nil
137
+ in_dir(@repository_dir) do
138
+ diff = run_command("#{BRAID_BIN} diff skit1")
139
+ end
140
+
141
+ expect(diff).to eq(<<PATCH)
142
+ diff --git a/layout.liquid b/layout.liquid
143
+ index 9f75009..25a4b32 100644
144
+ --- a/layout.liquid
145
+ +++ b/layout.liquid
146
+ @@ -22,7 +22,7 @@
147
+ <![endif]-->
148
+ </head>
149
+
150
+ -<body class="fixed orange">
151
+ +<body class="fixed green">
152
+ <script type="text/javascript">loadPreferences()</script>
153
+
154
+ <div id="wrapper">
155
+ PATCH
156
+ end
157
+
158
+ it 'should emit only banners when braid diff all' do
159
+ diff = nil
160
+ in_dir(@repository_dir) do
161
+ diff = run_command("#{BRAID_BIN} diff")
162
+ end
163
+
164
+ expect(diff).to eq(<<PATCH)
165
+ =======================================================
166
+ Braid: Diffing skit1
167
+ =======================================================
168
+ diff --git a/layout.liquid b/layout.liquid
169
+ index 9f75009..25a4b32 100644
170
+ --- a/layout.liquid
171
+ +++ b/layout.liquid
172
+ @@ -22,7 +22,7 @@
173
+ <![endif]-->
174
+ </head>
175
+
176
+ -<body class="fixed orange">
177
+ +<body class="fixed green">
178
+ <script type="text/javascript">loadPreferences()</script>
179
+
180
+ <div id="wrapper">
181
+ PATCH
182
+ end
183
+ end
184
+ end
185
+ end
@@ -6,10 +6,13 @@ require 'tempfile'
6
6
  require 'fileutils'
7
7
  require 'pathname'
8
8
 
9
- TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
10
- EDITOR_CMD = "#{TMP_PATH}/editor"
9
+ DEFAULT_NAME = 'Your Name'
10
+ DEFAULT_EMAIL = 'you@example.com'
11
+
12
+ TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
13
+ EDITOR_CMD = "#{TMP_PATH}/editor"
11
14
  EDITOR_CMD_PREFIX = "export GIT_EDITOR=#{EDITOR_CMD};"
12
- BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
15
+ BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.parent.realpath
13
16
  FIXTURE_PATH = File.join(BRAID_PATH, 'spec', 'fixtures')
14
17
  FileUtils.rm_rf(TMP_PATH)
15
18
  FileUtils.mkdir_p(TMP_PATH)
@@ -28,6 +31,24 @@ def assert_no_diff(file1, file2)
28
31
  run_command("diff -U 3 #{file1} #{file2}")
29
32
  end
30
33
 
34
+ def assert_commit_attribute(format_key, value, commit_index = 0)
35
+ output = run_command("git log --pretty=format:#{format_key}").split("\n")
36
+ regex = value.is_a?(Regexp) ? value : /^#{value}$/
37
+ expect(output[commit_index]).to match(regex)
38
+ end
39
+
40
+ def assert_commit_subject(value, commit_index = 0)
41
+ assert_commit_attribute('%s', value, commit_index)
42
+ end
43
+
44
+ def assert_commit_author(value, commit_index = 0)
45
+ assert_commit_attribute('%an', value, commit_index)
46
+ end
47
+
48
+ def assert_commit_email(value, commit_index = 0)
49
+ assert_commit_attribute('%ae', value, commit_index)
50
+ end
51
+
31
52
  def in_dir(dir = TMP_PATH)
32
53
  Dir.chdir(dir)
33
54
  yield
@@ -45,14 +66,17 @@ def update_dir_from_fixture(dir, fixture = dir)
45
66
  FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir)
46
67
  end
47
68
 
48
- def create_git_repo_from_fixture(fixture_name, directory = fixture_name)
69
+ def create_git_repo_from_fixture(fixture_name, options = {})
70
+ directory = options[:directory] || fixture_name
71
+ name = options[:name] || DEFAULT_NAME
72
+ email = options[:email] || DEFAULT_EMAIL
49
73
  git_repo = File.join(TMP_PATH, directory)
50
- update_dir_from_fixture(fixture_name)
74
+ update_dir_from_fixture(directory, fixture_name)
51
75
 
52
76
  in_dir(git_repo) do
53
77
  run_command('git init')
54
- run_command("git config user.email \"you@example.com\"")
55
- run_command("git config user.name \"Your Name\"")
78
+ run_command("git config --local user.email \"#{email}\"")
79
+ run_command("git config --local user.name \"#{name}\"")
56
80
  run_command('git add *')
57
81
  run_command("git commit -m \"initial commit of #{fixture_name}\"")
58
82
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../integration_helper'
1
+ require File.dirname(__FILE__) + '/integration_helper'
2
2
 
3
3
  describe 'Pushing to a mirror' do
4
4
 
@@ -9,7 +9,7 @@ describe 'Pushing to a mirror' do
9
9
 
10
10
  describe 'from a git repository' do
11
11
  before do
12
- @repository_dir = create_git_repo_from_fixture('shiny')
12
+ @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
13
13
  @vendor_repository_dir = create_git_repo_from_fixture('skit1')
14
14
  @file_name = 'layouts/layout.liquid'
15
15
 
@@ -31,33 +31,47 @@ describe 'Pushing to a mirror' do
31
31
  context 'with remote updtodate' do
32
32
  it 'should push changes successfully' do
33
33
  braid_output = nil
34
+ commit_message = 'Make some changes'
34
35
  in_dir(@repository_dir) do
35
- set_editor_message('Make some changes')
36
+ set_editor_message(commit_message)
36
37
  braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1")
37
38
  end
38
- braid_output.should =~ /Braid: Cloning mirror with local changes./
39
- braid_output.should =~ /Make some changes/
40
- braid_output.should =~ /Braid: Pushing changes to remote branch master./
39
+ expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
40
+ expect(braid_output).to match(/Make some changes/)
41
+ expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
41
42
 
42
43
  assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
43
44
  assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
45
+
46
+ in_dir(@vendor_repository_dir) do
47
+ run_command('git checkout master 2>&1')
48
+
49
+ assert_commit_subject(commit_message)
50
+ assert_commit_author('Some body')
51
+ assert_commit_email('somebody@example.com')
52
+ end
44
53
  end
45
54
 
46
55
  it 'should push changes to specified branch successfully' do
56
+ commit_message = 'Make some changes'
47
57
  braid_output = nil
48
58
  in_dir(@repository_dir) do
49
- set_editor_message('Make some changes')
59
+ set_editor_message(commit_message)
50
60
  braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1 --branch MyBranch")
51
61
  end
52
- braid_output.should =~ /Braid: Cloning mirror with local changes./
53
- braid_output.should =~ /Make some changes/
54
- braid_output.should =~ /Braid: Pushing changes to remote branch MyBranch./
62
+ expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
63
+ expect(braid_output).to match(/Make some changes/)
64
+ expect(braid_output).to match(/Braid: Pushing changes to remote branch MyBranch./)
55
65
 
56
66
  assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
57
67
  assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
58
68
 
59
69
  in_dir(@vendor_repository_dir) do
60
70
  run_command('git checkout MyBranch 2>&1')
71
+
72
+ assert_commit_subject(commit_message)
73
+ assert_commit_author('Some body')
74
+ assert_commit_email('somebody@example.com')
61
75
  end
62
76
 
63
77
  assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
@@ -73,16 +87,63 @@ describe 'Pushing to a mirror' do
73
87
  run_command('git commit -m "Update vendored directory"')
74
88
  end
75
89
  end
76
- it 'should push changes successfully' do
90
+ it 'should halt before attempting to push changes' do
77
91
  braid_output = nil
78
92
  in_dir(@repository_dir) do
79
93
  set_editor_message('Make some changes')
80
94
  braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1")
81
95
  end
82
- braid_output.should =~ /Braid: Mirror is not up to date. Stopping./
96
+ expect(braid_output).to match(/Braid: Mirror is not up to date. Stopping./)
83
97
 
84
98
  assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{TMP_PATH}/skit1/#{@file_name}")
85
99
  end
86
100
  end
87
101
  end
102
+
103
+ describe 'from a git repository braided into subdirectory' do
104
+ before do
105
+ @repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
106
+ @vendor_repository_dir = create_git_repo_from_fixture('skit1')
107
+ @file_name = 'layouts/layout.liquid'
108
+
109
+ in_dir(@repository_dir) do
110
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
111
+ end
112
+
113
+ in_dir(@vendor_repository_dir) do
114
+ run_command('git config receive.denyCurrentBranch updateInstead')
115
+ end
116
+
117
+ update_dir_from_fixture('shiny/skit1', 'skit1.1/layouts')
118
+ in_dir(@repository_dir) do
119
+ run_command('git add *')
120
+ run_command('git commit -m "Make some changes to vendored files"')
121
+ end
122
+ end
123
+
124
+ context 'with remote updtodate' do
125
+ it 'should push changes successfully' do
126
+ braid_output = nil
127
+ commit_message = 'Make some changes'
128
+ in_dir(@repository_dir) do
129
+ set_editor_message(commit_message)
130
+ braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1")
131
+ end
132
+ expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
133
+ expect(braid_output).to match(/Make some changes/)
134
+ expect(braid_output).to match(/Braid: Pushing changes to remote branch master./)
135
+
136
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/layout.liquid")
137
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
138
+
139
+ in_dir(@vendor_repository_dir) do
140
+ run_command('git checkout master 2>&1')
141
+
142
+ assert_commit_subject(commit_message)
143
+ assert_commit_author('Some body')
144
+ assert_commit_email('somebody@example.com')
145
+ end
146
+ end
147
+ end
148
+ end
88
149
  end
@@ -0,0 +1,59 @@
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")
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}/skit1/layout.liquid")
48
+
49
+ in_dir(@repository_dir) do
50
+ run_command("#{BRAID_BIN} remove skit1")
51
+ end
52
+
53
+ expect(File.exist?("#{@repository_dir}/skit1)")).to eq(false)
54
+
55
+ braids = YAML::load_file("#{@repository_dir}/.braids.json")
56
+ expect(braids['skit1']).to be_nil
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,59 @@
1
+ require File.dirname(__FILE__) + '/integration_helper'
2
+
3
+ describe 'Running braid status on 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
+ end
16
+ end
17
+ describe 'with no changes' do
18
+ it 'should only emit version when neither modified' do
19
+ diff = nil
20
+ in_dir(@repository_dir) do
21
+ diff = run_command("#{BRAID_BIN} status skit1")
22
+ end
23
+
24
+ expect(diff).to match(/^skit1 \([0-9a-f]{40}\)$/)
25
+ end
26
+ end
27
+
28
+ describe 'with local changes' do
29
+ it 'should emit local modified indicator' do
30
+ output = nil
31
+ in_dir(@repository_dir) do
32
+ File.open("#{@repository_dir}/skit1/foo.txt", 'wb') { |f| f.write('Hi') }
33
+ run_command('git add *')
34
+ run_command('git commit -m "modify mirror"')
35
+ output = run_command("#{BRAID_BIN} status skit1")
36
+ end
37
+
38
+ expect(output).to match(/^skit1 \([0-9a-f]{40}\) \(Locally Modified\)$/)
39
+ end
40
+ end
41
+
42
+ describe 'with remote changes' do
43
+ it 'should emit remote modified indicator' do
44
+ update_dir_from_fixture('skit1', 'skit1.1')
45
+ in_dir(@vendor_repository_dir) do
46
+ run_command('git add *')
47
+ run_command('git commit -m "change default color"')
48
+ end
49
+
50
+ output = nil
51
+ in_dir(@repository_dir) do
52
+ output = run_command("#{BRAID_BIN} status skit1")
53
+ end
54
+
55
+ expect(output).to match(/^skit1 \([0-9a-f]{40}\) \(Remote Modified\)$/)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../integration_helper'
1
+ require File.dirname(__FILE__) + '/integration_helper'
2
2
 
3
3
  describe 'Updating a mirror' do
4
4
 
@@ -9,22 +9,22 @@ describe 'Updating a mirror' do
9
9
 
10
10
  describe 'from a git repository' do
11
11
  before do
12
- @shiny = create_git_repo_from_fixture('shiny')
13
- @skit1 = create_git_repo_from_fixture('skit1')
12
+ @repository_dir = create_git_repo_from_fixture('shiny')
13
+ @vendor_repository_dir = create_git_repo_from_fixture('skit1')
14
14
  @file_name = 'layouts/layout.liquid'
15
15
 
16
- in_dir(@shiny) do
17
- run_command("#{BRAID_BIN} add #{@skit1}")
16
+ in_dir(@repository_dir) do
17
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir}")
18
18
  end
19
19
 
20
20
  update_dir_from_fixture('skit1', 'skit1.1')
21
- in_dir(@skit1) do
21
+ in_dir(@vendor_repository_dir) do
22
22
  run_command('git add *')
23
23
  run_command('git commit -m "change default color"')
24
24
  end
25
25
 
26
26
  update_dir_from_fixture('skit1', 'skit1.2')
27
- in_dir(@skit1) do
27
+ in_dir(@vendor_repository_dir) do
28
28
  run_command('git add *')
29
29
  run_command('git commit -m "add a happy note"')
30
30
  end
@@ -32,19 +32,19 @@ describe 'Updating a mirror' do
32
32
 
33
33
  context 'with no project-specific changes' do
34
34
  it 'should add the files and commit' do
35
- in_dir(@shiny) do
35
+ in_dir(@repository_dir) do
36
36
  run_command("#{BRAID_BIN} update skit1")
37
37
  end
38
38
 
39
- run_command("diff -U 3 #{File.join(FIXTURE_PATH, 'skit1.2', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
39
+ assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
40
40
 
41
41
  output = run_command('git log --pretty=oneline').split("\n")
42
- output.length.should == 3
43
- output[0].should =~ /Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/
42
+ expect(output.length).to eq(3)
43
+ expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
44
44
 
45
45
  # No temporary commits should be added to the reflog.
46
46
  output = `git log -g --pretty=oneline`.split("\n")
47
- output.length.should == 3
47
+ expect(output.length).to eq(3)
48
48
  end
49
49
  end
50
50
 
@@ -52,16 +52,16 @@ describe 'Updating a mirror' do
52
52
  it 'should auto-merge and commit' do
53
53
  run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
54
54
 
55
- in_dir(@shiny) do
55
+ in_dir(@repository_dir) do
56
56
  run_command("git commit -a -m 'mergeable change'")
57
57
  run_command("#{BRAID_BIN} update skit1")
58
58
  end
59
59
 
60
- run_command("diff -U 3 #{File.join(FIXTURE_PATH, 'shiny_skit1.2_merged', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
60
+ assert_no_diff("#{FIXTURE_PATH}/shiny_skit1.2_merged/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
61
61
 
62
62
  output = run_command('git log --pretty=oneline').split("\n")
63
- output.length.should == 4 # plus 'mergeable change'
64
- output[0].should =~ /Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/
63
+ expect(output.length).to eq(4) # plus 'mergeable change'
64
+ expect(output[0]).to match(/Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/)
65
65
  end
66
66
  end
67
67
 
@@ -70,16 +70,16 @@ describe 'Updating a mirror' do
70
70
  run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_conflicting', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
71
71
 
72
72
  target_revision = nil
73
- in_dir(@skit1) do
73
+ in_dir(@vendor_repository_dir) do
74
74
  target_revision = run_command('git rev-parse HEAD')
75
75
  end
76
76
 
77
77
  braid_output = nil
78
- in_dir(@shiny) do
78
+ in_dir(@repository_dir) do
79
79
  run_command("git commit -a -m 'conflicting change'")
80
80
  braid_output = run_command("#{BRAID_BIN} update skit1")
81
81
  end
82
- braid_output.should =~ /Caught merge error\. Breaking\./
82
+ expect(braid_output).to match(/Caught merge error\. Breaking\./)
83
83
 
84
84
  run_command("grep -q '>>>>>>> #{target_revision}' #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
85
85
  end
@@ -88,11 +88,11 @@ describe 'Updating a mirror' do
88
88
  # Regression test for https://github.com/cristibalan/braid/issues/41.
89
89
  context 'with a convergent deletion' do
90
90
  it 'should not detect a bogus rename' do
91
- in_dir(@skit1) do
91
+ in_dir(@vendor_repository_dir) do
92
92
  run_command('git rm layouts/layout.liquid')
93
93
  run_command('git commit -m "delete"')
94
94
  end
95
- in_dir(@shiny) do
95
+ in_dir(@repository_dir) do
96
96
  run_command('git rm skit1/layouts/layout.liquid')
97
97
  run_command('git commit -m "delete here too"')
98
98
  end
@@ -101,10 +101,52 @@ describe 'Updating a mirror' do
101
101
  # think skit1/layouts/layout.liquid was renamed to
102
102
  # other-skit/layout.liquid, resulting in a rename-delete conflict.
103
103
  braid_output = nil
104
- in_dir(@shiny) do
104
+ in_dir(@repository_dir) do
105
105
  braid_output = run_command("#{BRAID_BIN} update skit1")
106
106
  end
107
- braid_output.should_not =~ /Caught merge error\. Breaking\./
107
+ expect(braid_output).not_to match(/Caught merge error\. Breaking\./)
108
+ end
109
+ end
110
+ end
111
+
112
+ describe 'from a git repository with a braid into subdirectory' do
113
+ before do
114
+ @repository_dir = create_git_repo_from_fixture('shiny')
115
+ @vendor_repository_dir = create_git_repo_from_fixture('skit1')
116
+ @file_name = 'layouts/layout.liquid'
117
+
118
+ in_dir(@repository_dir) do
119
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --path layouts")
120
+ end
121
+
122
+ update_dir_from_fixture('skit1', 'skit1.1')
123
+ in_dir(@vendor_repository_dir) do
124
+ run_command('git add *')
125
+ run_command('git commit -m "change default color"')
126
+ end
127
+
128
+ update_dir_from_fixture('skit1', 'skit1.2')
129
+ in_dir(@vendor_repository_dir) do
130
+ run_command('git add *')
131
+ run_command('git commit -m "add a happy note"')
132
+ end
133
+ end
134
+
135
+ context 'with no project-specific changes' do
136
+ it 'should add the files and commit' do
137
+ in_dir(@repository_dir) do
138
+ run_command("#{BRAID_BIN} update skit1")
139
+ end
140
+
141
+ assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/layout.liquid")
142
+
143
+ output = run_command('git log --pretty=oneline').split("\n")
144
+ expect(output.length).to eq(3)
145
+ expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
146
+
147
+ # No temporary commits should be added to the reflog.
148
+ output = `git log -g --pretty=oneline`.split("\n")
149
+ expect(output.length).to eq(3)
108
150
  end
109
151
  end
110
152
  end