braid 1.0.17 → 1.0.18
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/README.md +16 -2
- data/bin/braid +16 -5
- data/lib/braid/command.rb +30 -9
- data/lib/braid/commands/add.rb +7 -3
- data/lib/braid/commands/push.rb +10 -2
- data/lib/braid/commands/status.rb +7 -1
- data/lib/braid/commands/update.rb +44 -15
- data/lib/braid/mirror.rb +23 -5
- data/lib/braid/version.rb +1 -1
- data/spec/integration/adding_spec.rb +84 -0
- data/spec/integration/diff_spec.rb +64 -0
- data/spec/integration/push_spec.rb +88 -0
- data/spec/integration/status_spec.rb +112 -6
- data/spec/integration/updating_spec.rb +249 -0
- data/spec/mirror_spec.rb +54 -2
- 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: 91ffaf5ed3caf78d594252885a0a420faa985530
|
4
|
+
data.tar.gz: 34467d809339f7035e29ea3f53c88e322f391ee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e481ed9197ec3a0d48a2b76a1697cd7407fa36cc7ef4f5a8f045a1a2aac101d1f67f3f16412fdd79620cb6cd7b31e166320c574e97a9b57cea5716011b29ba9
|
7
|
+
data.tar.gz: f7222bc8ac1b732b44eaa038310ec5f7fd50c2a7b63164d1dec0aba6157305122940167f8775804b1962b85889251ffc67aa1bfafbe3a843e5fb5f580eb8862d
|
data/README.md
CHANGED
@@ -39,6 +39,7 @@ references to external libraries or mirrors. The configuration allows you to con
|
|
39
39
|
aspects of the mirroring process such as;
|
40
40
|
|
41
41
|
* whether the mirror is locked to a particular version of the external library.
|
42
|
+
* whether the mirror is tracking a tag or a branch.
|
42
43
|
* whether the mirror includes the entire external library or just a subdirectory.
|
43
44
|
|
44
45
|
## Installation
|
@@ -99,7 +100,15 @@ This is useful if you want to add a subdirectory from a mirror into your own pro
|
|
99
100
|
|
100
101
|
braid add --path dist https://github.com/twbs/bootstrap.git vendor/assets/bootstrap
|
101
102
|
|
102
|
-
#### Adding
|
103
|
+
#### Adding a mirror based on a branch
|
104
|
+
|
105
|
+
braid add --branch 5-0-stable https://github.com/rails/rails.git vendor/rails
|
106
|
+
|
107
|
+
#### Adding a mirror based on a tag
|
108
|
+
|
109
|
+
braid add --tag v1.0 https://github.com/realityforge/backpack.git vendor/tools/backpack
|
110
|
+
|
111
|
+
#### Adding mirror locked to a revision
|
103
112
|
|
104
113
|
braid add --revision bf1b1e0 git://github.com/rails/rails.git vendor/rails
|
105
114
|
|
@@ -123,8 +132,13 @@ index with `git reset --hard`.
|
|
123
132
|
|
124
133
|
#### Locking and unlocking mirrors
|
125
134
|
|
135
|
+
Lock to a particular version in the mirror.
|
136
|
+
|
126
137
|
braid update --revision 6c1c16b vendor/rails
|
127
|
-
|
138
|
+
|
139
|
+
Go back to tracking a particular branch.
|
140
|
+
|
141
|
+
braid update --branch master vendor/rails
|
128
142
|
|
129
143
|
#### Showing local changes made to mirrors
|
130
144
|
|
data/bin/braid
CHANGED
@@ -40,11 +40,11 @@ Main {
|
|
40
40
|
. braid add http://remote/path local/dir
|
41
41
|
TXT
|
42
42
|
|
43
|
-
mixin :argument_url, :optional_local_path, :option_branch, :option_revision, :option_verbose, :option_path
|
43
|
+
mixin :argument_url, :optional_local_path, :option_branch, :option_tag, :option_revision, :option_verbose, :option_path
|
44
44
|
|
45
45
|
run {
|
46
46
|
Braid.verbose = verbose
|
47
|
-
Braid::Command.run(:add, url, {'path' => local_path, 'branch' => branch, 'revision' => revision, 'remote_path' => path})
|
47
|
+
Braid::Command.run(:add, url, {'path' => local_path, 'branch' => branch, 'tag' => tag, 'revision' => revision, 'remote_path' => path})
|
48
48
|
}
|
49
49
|
}
|
50
50
|
|
@@ -65,10 +65,12 @@ Main {
|
|
65
65
|
. braid update local/dir
|
66
66
|
TXT
|
67
67
|
|
68
|
-
mixin :optional_local_path, :option_revision, :
|
68
|
+
mixin :optional_local_path, :option_head, :option_revision, :option_tag, :option_branch, :option_verbose, :option_keep_remote
|
69
69
|
|
70
70
|
run {
|
71
71
|
options = {
|
72
|
+
'branch' => branch,
|
73
|
+
'tag' => tag,
|
72
74
|
'revision' => revision,
|
73
75
|
'head' => head,
|
74
76
|
'keep' => keep
|
@@ -191,7 +193,16 @@ Main {
|
|
191
193
|
option(:branch, :b) {
|
192
194
|
optional
|
193
195
|
argument :required
|
194
|
-
desc 'remote branch name'
|
196
|
+
desc 'remote branch name to track'
|
197
|
+
attr
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
mixin(:option_tag) {
|
202
|
+
option(:tag, :t) {
|
203
|
+
optional
|
204
|
+
argument :required
|
205
|
+
desc 'remote tag name to track'
|
195
206
|
attr
|
196
207
|
}
|
197
208
|
}
|
@@ -217,7 +228,7 @@ Main {
|
|
217
228
|
mixin(:option_head) {
|
218
229
|
option(:head) {
|
219
230
|
optional
|
220
|
-
desc '
|
231
|
+
desc 'unused option'
|
221
232
|
attr
|
222
233
|
}
|
223
234
|
}
|
data/lib/braid/command.rb
CHANGED
@@ -45,7 +45,13 @@ module Braid
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def setup_remote(mirror)
|
48
|
-
|
48
|
+
existing_force = Braid.force
|
49
|
+
begin
|
50
|
+
Braid.force = true
|
51
|
+
Command.run(:setup, mirror.path)
|
52
|
+
ensure
|
53
|
+
Braid.force = existing_force
|
54
|
+
end
|
49
55
|
end
|
50
56
|
|
51
57
|
def clear_remote(mirror, options)
|
@@ -88,17 +94,32 @@ module Braid
|
|
88
94
|
"'#{revision[0, 7]}'"
|
89
95
|
end
|
90
96
|
|
91
|
-
def
|
92
|
-
|
97
|
+
def determine_repository_revision(mirror)
|
98
|
+
if mirror.tag
|
99
|
+
if use_local_cache?
|
100
|
+
Dir.chdir git_cache.path(mirror.url) do
|
101
|
+
git.rev_parse(mirror.local_ref)
|
102
|
+
end
|
103
|
+
else
|
104
|
+
raise BraidError, 'unable to retrieve tag version when cache disabled.'
|
105
|
+
end
|
106
|
+
else
|
107
|
+
git.rev_parse(mirror.local_ref)
|
108
|
+
end
|
109
|
+
end
|
93
110
|
|
94
|
-
|
95
|
-
|
111
|
+
def validate_new_revision(mirror, revision)
|
112
|
+
if revision.nil?
|
113
|
+
determine_repository_revision(mirror)
|
114
|
+
else
|
115
|
+
new_revision = git.rev_parse(revision)
|
96
116
|
|
97
|
-
|
98
|
-
|
99
|
-
|
117
|
+
if new_revision == mirror.revision
|
118
|
+
raise InvalidRevision, 'mirror is already at requested revision'
|
119
|
+
end
|
100
120
|
|
101
|
-
|
121
|
+
new_revision
|
122
|
+
end
|
102
123
|
end
|
103
124
|
|
104
125
|
def determine_target_revision(mirror, new_revision)
|
data/lib/braid/commands/add.rb
CHANGED
@@ -6,13 +6,18 @@ module Braid
|
|
6
6
|
mirror = config.add_from_options(url, options)
|
7
7
|
add_config_file
|
8
8
|
|
9
|
-
|
9
|
+
mirror.branch = nil if options['revision']
|
10
|
+
raise BraidError, 'Can not add mirror specifying both a revision and a tag' if options['revision'] && mirror.tag
|
11
|
+
|
12
|
+
branch_message = (mirror.branch.nil? || mirror.branch == 'master') ? '' : " branch '#{mirror.branch}'"
|
13
|
+
tag_message = mirror.tag.nil? ? '' : " tag '#{mirror.tag}'"
|
10
14
|
revision_message = options['revision'] ? " at #{display_revision(mirror, options['revision'])}" : ''
|
11
|
-
msg "Adding mirror of '#{mirror.url}'#{branch_message}#{revision_message}."
|
15
|
+
msg "Adding mirror of '#{mirror.url}'#{branch_message}#{tag_message}#{revision_message}."
|
12
16
|
|
13
17
|
# these commands are explained in the subtree merge guide
|
14
18
|
# http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
|
15
19
|
|
20
|
+
config.update(mirror)
|
16
21
|
setup_remote(mirror)
|
17
22
|
mirror.fetch
|
18
23
|
|
@@ -22,7 +27,6 @@ module Braid
|
|
22
27
|
git.read_tree_prefix_u(target_revision, mirror.path)
|
23
28
|
|
24
29
|
mirror.revision = new_revision
|
25
|
-
mirror.lock = new_revision if options['revision']
|
26
30
|
config.update(mirror)
|
27
31
|
add_config_file
|
28
32
|
|
data/lib/braid/commands/push.rb
CHANGED
@@ -2,6 +2,12 @@ require 'fileutils'
|
|
2
2
|
require 'tmpdir'
|
3
3
|
|
4
4
|
module Braid
|
5
|
+
class NoPushToTag < BraidError
|
6
|
+
def message
|
7
|
+
"mirror is based off a tag. Can not push to a tag: #{super}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
module Commands
|
6
12
|
class Push < Command
|
7
13
|
def run(path, options = {})
|
@@ -9,10 +15,12 @@ module Braid
|
|
9
15
|
|
10
16
|
branch = options['branch'] || mirror.branch
|
11
17
|
|
18
|
+
raise NoPushToTag, path unless branch
|
19
|
+
|
12
20
|
setup_remote(mirror)
|
13
21
|
mirror.fetch
|
14
22
|
|
15
|
-
base_revision =
|
23
|
+
base_revision = determine_repository_revision(mirror)
|
16
24
|
unless mirror.merged?(base_revision)
|
17
25
|
msg 'Mirror is not up to date. Stopping.'
|
18
26
|
clear_remote(mirror, options)
|
@@ -42,7 +50,7 @@ module Braid
|
|
42
50
|
git.config(['--local', 'user.name', "\"#{user_name}\""]) if user_name
|
43
51
|
git.config(['--local', 'user.email', "\"#{user_email}\""]) if user_email
|
44
52
|
git.fetch(mirror.cached_url) if File.exist?(mirror.cached_url)
|
45
|
-
git.fetch(remote_url,
|
53
|
+
git.fetch(remote_url, mirror.remote_ref)
|
46
54
|
git.checkout(base_revision)
|
47
55
|
args =[]
|
48
56
|
args << "--directory=#{mirror.remote_path}" if mirror.remote_path
|
@@ -22,7 +22,13 @@ module Braid
|
|
22
22
|
mirror.fetch
|
23
23
|
print path.to_s
|
24
24
|
print ' (' + mirror.base_revision + ')'
|
25
|
-
|
25
|
+
if mirror.locked?
|
26
|
+
print ' [REVISION LOCKED]'
|
27
|
+
elsif mirror.tag
|
28
|
+
print " [TAG=#{mirror.tag}]"
|
29
|
+
else # mirror.branch
|
30
|
+
print " [BRANCH=#{mirror.branch}]"
|
31
|
+
end
|
26
32
|
msg "Fetching new commits for '#{mirror.path}'." if verbose?
|
27
33
|
new_revision = validate_new_revision(mirror, options['revision'])
|
28
34
|
print ' (Remote Modified)' if new_revision.to_s != mirror.base_revision.to_s
|
@@ -17,24 +17,35 @@ module Braid
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def update_one(path, options = {})
|
20
|
+
bail_on_local_changes!
|
21
|
+
|
22
|
+
raise BraidError, "Do not specify --head option anymore. Please use '--branch MyBranch' to track a branch or '--tag MyTag' to track a branch" if options['head']
|
23
|
+
|
20
24
|
mirror = config.get!(path)
|
21
25
|
|
22
|
-
|
23
|
-
msg "Updating mirror '#{mirror.path}'#{revision_message}."
|
26
|
+
msg "Updating mirror '#{mirror.path}'."
|
24
27
|
|
25
28
|
was_locked = mirror.locked?
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
original_revision = mirror.revision
|
30
|
+
original_branch = mirror.branch
|
31
|
+
original_tag = mirror.tag
|
32
|
+
|
33
|
+
raise BraidError, 'Can not update mirror specifying both a revision and a tag' if options['revision'] && options['tag']
|
34
|
+
raise BraidError, 'Can not update mirror specifying both a branch and a tag' if options['branch'] && options['tag']
|
35
|
+
|
36
|
+
if options['tag']
|
37
|
+
mirror.tag = options['tag']
|
38
|
+
mirror.branch = nil
|
39
|
+
elsif options['branch']
|
40
|
+
mirror.tag = nil
|
41
|
+
mirror.branch = options['branch']
|
42
|
+
elsif options['revision']
|
43
|
+
mirror.tag = nil
|
44
|
+
mirror.branch = nil
|
36
45
|
end
|
37
46
|
|
47
|
+
config.update(mirror)
|
48
|
+
|
38
49
|
setup_remote(mirror)
|
39
50
|
msg "Fetching new commits for '#{mirror.path}'." if verbose?
|
40
51
|
mirror.fetch
|
@@ -48,8 +59,27 @@ module Braid
|
|
48
59
|
target_revision = determine_target_revision(mirror, new_revision)
|
49
60
|
current_revision = determine_target_revision(mirror, mirror.base_revision)
|
50
61
|
|
51
|
-
|
52
|
-
|
62
|
+
from_desc =
|
63
|
+
original_tag ? "tag '#{original_tag}'" :
|
64
|
+
!was_locked ? "branch '#{original_branch}'" :
|
65
|
+
"revision '#{original_revision}'"
|
66
|
+
|
67
|
+
switching = true
|
68
|
+
if mirror.branch && (original_branch != mirror.branch || (was_locked && !mirror.locked?))
|
69
|
+
msg "Switching mirror '#{mirror.path}' to branch '#{mirror.branch}' from #{from_desc}."
|
70
|
+
elsif mirror.tag && original_tag != mirror.tag
|
71
|
+
msg "Switching mirror '#{mirror.path}' to tag '#{mirror.tag}' from #{from_desc}."
|
72
|
+
elsif options['revision'] && original_revision != options['revision']
|
73
|
+
msg "Switching mirror '#{mirror.path}' to revision '#{options['revision']}' from #{from_desc}."
|
74
|
+
else
|
75
|
+
switching = false
|
76
|
+
end
|
77
|
+
|
78
|
+
if !switching &&
|
79
|
+
(
|
80
|
+
(options['revision'] && was_locked && target_revision == current_revision) ||
|
81
|
+
(options['revision'].nil? && !was_locked && mirror.merged?(git.rev_parse(new_revision)))
|
82
|
+
)
|
53
83
|
msg "Mirror '#{mirror.path}' is already up to date."
|
54
84
|
clear_remote(mirror, options)
|
55
85
|
return
|
@@ -58,7 +88,6 @@ module Braid
|
|
58
88
|
base_revision = mirror.base_revision
|
59
89
|
|
60
90
|
mirror.revision = new_revision
|
61
|
-
mirror.lock = new_revision if options['revision']
|
62
91
|
|
63
92
|
msg "Merging in mirror '#{mirror.path}'." if verbose?
|
64
93
|
in_error = false
|
data/lib/braid/mirror.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Braid
|
2
2
|
class Mirror
|
3
|
-
ATTRIBUTES = %w(url branch revision
|
3
|
+
ATTRIBUTES = %w(url branch revision tag path)
|
4
4
|
|
5
5
|
class UnknownType < BraidError
|
6
6
|
def message
|
@@ -12,6 +12,11 @@ module Braid
|
|
12
12
|
'path is required'
|
13
13
|
end
|
14
14
|
end
|
15
|
+
class NoTagAndBranch < BraidError
|
16
|
+
def message
|
17
|
+
'can not specify both tag and branch configuration'
|
18
|
+
end
|
19
|
+
end
|
15
20
|
|
16
21
|
include Operations::VersionControl
|
17
22
|
|
@@ -25,14 +30,17 @@ module Braid
|
|
25
30
|
def self.new_from_options(url, options = {})
|
26
31
|
url = url.sub(/\/$/, '')
|
27
32
|
|
28
|
-
|
33
|
+
raise NoTagAndBranch if options['tag'] && options['branch']
|
34
|
+
|
35
|
+
tag = options['tag']
|
36
|
+
branch = options['branch'] || (tag.nil? ? 'master' : nil)
|
29
37
|
|
30
38
|
path = (options['path'] || extract_path_from_url(url)).sub(/\/$/, '')
|
31
39
|
raise PathRequired unless path
|
32
40
|
|
33
41
|
remote_path = options['remote_path']
|
34
42
|
|
35
|
-
attributes = {'url' => url, 'branch' => branch, 'path' => remote_path}
|
43
|
+
attributes = {'url' => url, 'branch' => branch, 'path' => remote_path, 'tag' => tag}
|
36
44
|
self.new(path, attributes)
|
37
45
|
end
|
38
46
|
|
@@ -41,7 +49,7 @@ module Braid
|
|
41
49
|
end
|
42
50
|
|
43
51
|
def locked?
|
44
|
-
|
52
|
+
branch.nil? && tag.nil?
|
45
53
|
end
|
46
54
|
|
47
55
|
def merged?(commit)
|
@@ -79,6 +87,16 @@ module Braid
|
|
79
87
|
end
|
80
88
|
end
|
81
89
|
|
90
|
+
def local_ref
|
91
|
+
return "#{self.remote}/#{self.branch}" unless self.branch.nil?
|
92
|
+
return "tags/#{self.tag}" unless self.tag.nil?
|
93
|
+
self.revision
|
94
|
+
end
|
95
|
+
|
96
|
+
def remote_ref
|
97
|
+
self.branch.nil? ? "+refs/tags/#{self.tag}" : "+refs/heads/#{self.branch}"
|
98
|
+
end
|
99
|
+
|
82
100
|
def remote_path
|
83
101
|
self.attributes['path']
|
84
102
|
end
|
@@ -92,7 +110,7 @@ module Braid
|
|
92
110
|
end
|
93
111
|
|
94
112
|
def remote
|
95
|
-
"#{branch}/braid/#{path}"
|
113
|
+
"#{branch || tag || 'revision'}/braid/#{path}"
|
96
114
|
end
|
97
115
|
|
98
116
|
private
|
data/lib/braid/version.rb
CHANGED
@@ -30,6 +30,7 @@ describe 'Adding a mirror in a clean repository' do
|
|
30
30
|
expect(braids['skit1']['url']).to eq(@vendor_repository_dir)
|
31
31
|
expect(braids['skit1']['revision']).not_to be_nil
|
32
32
|
expect(braids['skit1']['branch']).to eq('master')
|
33
|
+
expect(braids['skit1']['tag']).to be_nil
|
33
34
|
expect(braids['skit1']['path']).to be_nil
|
34
35
|
end
|
35
36
|
end
|
@@ -57,7 +58,90 @@ describe 'Adding a mirror in a clean repository' do
|
|
57
58
|
expect(braids['skit1']['url']).to eq(@vendor_repository_dir)
|
58
59
|
expect(braids['skit1']['revision']).not_to be_nil
|
59
60
|
expect(braids['skit1']['branch']).to eq('master')
|
61
|
+
expect(braids['skit1']['tag']).to be_nil
|
60
62
|
expect(braids['skit1']['path']).to eq('layouts')
|
61
63
|
end
|
62
64
|
end
|
65
|
+
|
66
|
+
describe 'from a tag in a git repository' do
|
67
|
+
before do
|
68
|
+
@repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
|
69
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
70
|
+
in_dir(@vendor_repository_dir) do
|
71
|
+
run_command('git tag v1')
|
72
|
+
end
|
73
|
+
|
74
|
+
in_dir(@repository_dir) do
|
75
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --tag v1")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should add the files and commit' do
|
80
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit1/layouts/layout.liquid")
|
81
|
+
|
82
|
+
assert_commit_subject(/Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/)
|
83
|
+
assert_commit_author('Some body')
|
84
|
+
assert_commit_email('somebody@example.com')
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should create .braids.json and add the mirror to it' do
|
88
|
+
braids = YAML::load_file("#{@repository_dir}/.braids.json")
|
89
|
+
expect(braids['skit1']['url']).to eq(@vendor_repository_dir)
|
90
|
+
expect(braids['skit1']['revision']).not_to be_nil
|
91
|
+
expect(braids['skit1']['branch']).to be_nil
|
92
|
+
expect(braids['skit1']['tag']).to eq('v1')
|
93
|
+
expect(braids['skit1']['path']).to be_nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'from a revision in a git repository' do
|
98
|
+
before do
|
99
|
+
@repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
|
100
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
101
|
+
in_dir(@vendor_repository_dir) do
|
102
|
+
run_command('git tag v1')
|
103
|
+
@revision = run_command('git rev-parse HEAD').strip
|
104
|
+
end
|
105
|
+
|
106
|
+
in_dir(@repository_dir) do
|
107
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --revision #{@revision}")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should add the files and commit' do
|
112
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1/layouts/layout.liquid", "#{@repository_dir}/skit1/layouts/layout.liquid")
|
113
|
+
|
114
|
+
assert_commit_subject(/Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/)
|
115
|
+
assert_commit_author('Some body')
|
116
|
+
assert_commit_email('somebody@example.com')
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should create .braids.json and add the mirror to it' do
|
120
|
+
braids = YAML::load_file("#{@repository_dir}/.braids.json")
|
121
|
+
expect(braids['skit1']['url']).to eq(@vendor_repository_dir)
|
122
|
+
expect(braids['skit1']['revision']).not_to be_nil
|
123
|
+
expect(braids['skit1']['branch']).to be_nil
|
124
|
+
expect(braids['skit1']['tag']).to be_nil
|
125
|
+
expect(braids['skit1']['path']).to be_nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe 'with a git repository' do
|
130
|
+
before do
|
131
|
+
@repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
|
132
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
133
|
+
in_dir(@vendor_repository_dir) do
|
134
|
+
run_command('git tag v1')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should generate an error if both tag and revision specified' do
|
139
|
+
output = nil
|
140
|
+
in_dir(@repository_dir) do
|
141
|
+
output = `#{BRAID_BIN} add #{@vendor_repository_dir} --revision X --tag v1`
|
142
|
+
end
|
143
|
+
|
144
|
+
expect(output).to match(/^Braid: Error: Can not add mirror specifying both a revision and a tag$/)
|
145
|
+
end
|
146
|
+
end
|
63
147
|
end
|
@@ -6,6 +6,9 @@ describe 'Running braid diff on a mirror' do
|
|
6
6
|
FileUtils.mkdir_p(TMP_PATH)
|
7
7
|
@repository_dir = create_git_repo_from_fixture('shiny')
|
8
8
|
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
9
|
+
in_dir(@vendor_repository_dir) do
|
10
|
+
run_command('git tag v1')
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
describe 'braided directly in' do
|
@@ -173,6 +176,67 @@ index 9f75009..25a4b32 100644
|
|
173
176
|
<![endif]-->
|
174
177
|
</head>
|
175
178
|
|
179
|
+
-<body class="fixed orange">
|
180
|
+
+<body class="fixed green">
|
181
|
+
<script type="text/javascript">loadPreferences()</script>
|
182
|
+
|
183
|
+
<div id="wrapper">
|
184
|
+
PATCH
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe 'braided as a tag directly in' do
|
190
|
+
before do
|
191
|
+
in_dir(@repository_dir) do
|
192
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --tag v1")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe 'with no changes' do
|
197
|
+
it 'should emit no output when named in braid diff' do
|
198
|
+
diff = nil
|
199
|
+
in_dir(@repository_dir) do
|
200
|
+
diff = run_command("#{BRAID_BIN} diff skit1")
|
201
|
+
end
|
202
|
+
|
203
|
+
expect(diff).to eq('')
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should emit only banners when braid diff all' do
|
207
|
+
diff = nil
|
208
|
+
in_dir(@repository_dir) do
|
209
|
+
diff = run_command("#{BRAID_BIN} diff")
|
210
|
+
end
|
211
|
+
|
212
|
+
expect(diff).to eq("=======================================================\nBraid: Diffing skit1\n=======================================================\n")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe 'with changes' do
|
217
|
+
before do
|
218
|
+
FileUtils.cp_r(File.join(FIXTURE_PATH, 'skit1.1') + '/.', "#{@repository_dir}/skit1")
|
219
|
+
in_dir(@repository_dir) do
|
220
|
+
run_command('git add *')
|
221
|
+
run_command('git commit -m "Some local changes"')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should emit diff when named in braid diff' do
|
226
|
+
diff = nil
|
227
|
+
in_dir(@repository_dir) do
|
228
|
+
diff = run_command("#{BRAID_BIN} diff skit1")
|
229
|
+
end
|
230
|
+
|
231
|
+
expect(diff).to eq(<<PATCH)
|
232
|
+
diff --git a/layouts/layout.liquid b/layouts/layout.liquid
|
233
|
+
index 9f75009..25a4b32 100644
|
234
|
+
--- a/layouts/layout.liquid
|
235
|
+
+++ b/layouts/layout.liquid
|
236
|
+
@@ -22,7 +22,7 @@
|
237
|
+
<![endif]-->
|
238
|
+
</head>
|
239
|
+
|
176
240
|
-<body class="fixed orange">
|
177
241
|
+<body class="fixed green">
|
178
242
|
<script type="text/javascript">loadPreferences()</script>
|
@@ -146,4 +146,92 @@ describe 'Pushing to a mirror' do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
149
|
+
|
150
|
+
describe 'from a git repository braided in as a tag' do
|
151
|
+
before do
|
152
|
+
@repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
|
153
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
154
|
+
in_dir(@vendor_repository_dir) do
|
155
|
+
run_command('git tag v1')
|
156
|
+
end
|
157
|
+
@file_name = 'layouts/layout.liquid'
|
158
|
+
|
159
|
+
in_dir(@repository_dir) do
|
160
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --tag v1")
|
161
|
+
end
|
162
|
+
|
163
|
+
in_dir(@vendor_repository_dir) do
|
164
|
+
run_command('git config receive.denyCurrentBranch updateInstead')
|
165
|
+
end
|
166
|
+
|
167
|
+
update_dir_from_fixture('shiny/skit1', 'skit1.1')
|
168
|
+
in_dir(@repository_dir) do
|
169
|
+
run_command('git add *')
|
170
|
+
run_command('git commit -m "Make some changes to vendored files"')
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context 'with remote updtodate' do
|
175
|
+
it 'should fail tring to push without specifying branch' do
|
176
|
+
braid_output = nil
|
177
|
+
commit_message = 'Make some changes'
|
178
|
+
in_dir(@repository_dir) do
|
179
|
+
set_editor_message(commit_message)
|
180
|
+
braid_output = `#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1`
|
181
|
+
end
|
182
|
+
expect(braid_output).to match(/Braid: Error: mirror is based off a tag. Can not push to a tag: skit1/)
|
183
|
+
|
184
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
185
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should push changes to specified branch successfully' do
|
189
|
+
commit_message = 'Make some changes'
|
190
|
+
braid_output = nil
|
191
|
+
in_dir(@repository_dir) do
|
192
|
+
set_editor_message(commit_message)
|
193
|
+
braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1 --branch MyBranch")
|
194
|
+
end
|
195
|
+
expect(braid_output).to match(/Braid: Cloning mirror with local changes./)
|
196
|
+
expect(braid_output).to match(/Make some changes/)
|
197
|
+
expect(braid_output).to match(/Braid: Pushing changes to remote branch MyBranch./)
|
198
|
+
|
199
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
|
200
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
201
|
+
|
202
|
+
in_dir(@vendor_repository_dir) do
|
203
|
+
run_command('git checkout MyBranch 2>&1')
|
204
|
+
|
205
|
+
assert_commit_subject(commit_message)
|
206
|
+
assert_commit_author('Some body')
|
207
|
+
assert_commit_email('somebody@example.com')
|
208
|
+
end
|
209
|
+
|
210
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'with remote having changes' do
|
215
|
+
before do
|
216
|
+
update_dir_from_fixture('skit1', 'skit1.1')
|
217
|
+
update_dir_from_fixture('skit1', 'skit1.2')
|
218
|
+
in_dir(@vendor_repository_dir) do
|
219
|
+
run_command('git add *')
|
220
|
+
run_command('git commit -m "Update vendored directory"')
|
221
|
+
run_command('git tag -f v1')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should halt before attempting to push changes' do
|
226
|
+
braid_output = nil
|
227
|
+
in_dir(@repository_dir) do
|
228
|
+
set_editor_message('Make some changes')
|
229
|
+
braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1 --branch MyBranch")
|
230
|
+
end
|
231
|
+
expect(braid_output).to match(/Braid: Mirror is not up to date. Stopping./)
|
232
|
+
|
233
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{TMP_PATH}/skit1/#{@file_name}")
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
149
237
|
end
|
@@ -21,7 +21,7 @@ describe 'Running braid status on a mirror' do
|
|
21
21
|
diff = run_command("#{BRAID_BIN} status skit1")
|
22
22
|
end
|
23
23
|
|
24
|
-
expect(diff).to match(/^skit1 \([0-9a-f]{40}\)$/)
|
24
|
+
expect(diff).to match(/^skit1 \([0-9a-f]{40}\) \[BRANCH=master\]$/)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -35,24 +35,130 @@ describe 'Running braid status on a mirror' do
|
|
35
35
|
output = run_command("#{BRAID_BIN} status skit1")
|
36
36
|
end
|
37
37
|
|
38
|
-
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \(Locally Modified\)$/)
|
38
|
+
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \[BRANCH=master\] \(Locally Modified\)$/)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe 'with remote changes' do
|
43
43
|
it 'should emit remote modified indicator' do
|
44
|
-
|
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}\) \[BRANCH=master\] \(Remote Modified\)$/)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'braided into branch in' do
|
61
|
+
before do
|
45
62
|
in_dir(@vendor_repository_dir) do
|
46
|
-
run_command('git
|
47
|
-
|
63
|
+
run_command('git checkout -bbranch1 2>&1')
|
64
|
+
end
|
65
|
+
in_dir(@repository_dir) do
|
66
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --branch branch1")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
describe 'with no changes' do
|
70
|
+
it 'should only emit version when neither modified' do
|
71
|
+
diff = nil
|
72
|
+
in_dir(@repository_dir) do
|
73
|
+
diff = run_command("#{BRAID_BIN} status skit1")
|
74
|
+
end
|
75
|
+
|
76
|
+
expect(diff).to match(/^skit1 \([0-9a-f]{40}\) \[BRANCH=branch1\]$/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'with local changes' do
|
81
|
+
it 'should emit local modified indicator' do
|
82
|
+
output = nil
|
83
|
+
in_dir(@repository_dir) do
|
84
|
+
File.open("#{@repository_dir}/skit1/foo.txt", 'wb') { |f| f.write('Hi') }
|
85
|
+
run_command('git add *')
|
86
|
+
run_command('git commit -m "modify mirror"')
|
87
|
+
output = run_command("#{BRAID_BIN} status skit1")
|
88
|
+
end
|
89
|
+
|
90
|
+
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \[BRANCH=branch1\] \(Locally Modified\)$/)
|
48
91
|
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'with remote changes' do
|
95
|
+
it 'should emit remote modified indicator' do
|
96
|
+
update_dir_from_fixture('skit1', 'skit1.1')
|
97
|
+
in_dir(@vendor_repository_dir) do
|
98
|
+
run_command('git add *')
|
99
|
+
run_command('git commit -m "change default color"')
|
100
|
+
end
|
101
|
+
|
102
|
+
output = nil
|
103
|
+
in_dir(@repository_dir) do
|
104
|
+
output = run_command("#{BRAID_BIN} status skit1")
|
105
|
+
end
|
106
|
+
|
107
|
+
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \[BRANCH=branch1\] \(Remote Modified\)$/)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'braided directly in as tag' do
|
113
|
+
before do
|
114
|
+
in_dir(@vendor_repository_dir) do
|
115
|
+
run_command('git tag v1')
|
116
|
+
end
|
117
|
+
|
118
|
+
in_dir(@repository_dir) do
|
119
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --tag v1")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
describe 'with no changes' do
|
123
|
+
it 'should only emit version when neither modified' do
|
124
|
+
diff = nil
|
125
|
+
in_dir(@repository_dir) do
|
126
|
+
diff = run_command("#{BRAID_BIN} status skit1")
|
127
|
+
end
|
128
|
+
|
129
|
+
expect(diff).to match(/^skit1 \([0-9a-f]{40}\) \[TAG=v1\]$/)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'with local changes' do
|
134
|
+
it 'should emit local modified indicator' do
|
135
|
+
output = nil
|
136
|
+
in_dir(@repository_dir) do
|
137
|
+
File.open("#{@repository_dir}/skit1/foo.txt", 'wb') { |f| f.write('Hi') }
|
138
|
+
run_command('git add *')
|
139
|
+
run_command('git commit -m "modify mirror"')
|
140
|
+
output = run_command("#{BRAID_BIN} status skit1")
|
141
|
+
end
|
142
|
+
|
143
|
+
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \[TAG=v1\] \(Locally Modified\)$/)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe 'with remote changes' do
|
148
|
+
it 'should emit remote modified indicator' do
|
149
|
+
update_dir_from_fixture('skit1', 'skit1.1')
|
150
|
+
in_dir(@vendor_repository_dir) do
|
151
|
+
run_command('git add *')
|
152
|
+
run_command('git commit -m "change default color"')
|
153
|
+
run_command('git tag -f v1')
|
154
|
+
end
|
49
155
|
|
50
156
|
output = nil
|
51
157
|
in_dir(@repository_dir) do
|
52
158
|
output = run_command("#{BRAID_BIN} status skit1")
|
53
159
|
end
|
54
160
|
|
55
|
-
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \(Remote Modified\)$/)
|
161
|
+
expect(output).to match(/^skit1 \([0-9a-f]{40}\) \[TAG=v1\] \(Remote Modified\)$/)
|
56
162
|
end
|
57
163
|
end
|
58
164
|
end
|
@@ -7,6 +7,48 @@ describe 'Updating a mirror' do
|
|
7
7
|
FileUtils.mkdir_p(TMP_PATH)
|
8
8
|
end
|
9
9
|
|
10
|
+
describe 'with a git repository' do
|
11
|
+
before do
|
12
|
+
@repository_dir = create_git_repo_from_fixture('shiny', :name => 'Some body', :email => 'somebody@example.com')
|
13
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
14
|
+
@head_version = nil
|
15
|
+
in_dir(@vendor_repository_dir) do
|
16
|
+
run_command('git tag v1')
|
17
|
+
@head_version = run_command('git rev-parse HEAD')
|
18
|
+
end
|
19
|
+
in_dir(@repository_dir) do
|
20
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should generate an error if --head parameter passed' do
|
25
|
+
output = nil
|
26
|
+
in_dir(@repository_dir) do
|
27
|
+
output = `#{BRAID_BIN} update skit1 --head 2>&1`
|
28
|
+
end
|
29
|
+
|
30
|
+
expect(output).to match(/^Braid: Error: Do not specify --head option anymore. Please use '--branch MyBranch' to track a branch or '--tag MyTag' to track a branch$/)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should generate an error if both tag and revision specified' do
|
34
|
+
output = nil
|
35
|
+
in_dir(@repository_dir) do
|
36
|
+
output = `#{BRAID_BIN} update skit1 --tag v1 --revision #{@head_version} 2>&1`
|
37
|
+
end
|
38
|
+
|
39
|
+
expect(output).to match(/^Braid: Error: Can not update mirror specifying both a revision and a tag$/)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should generate an error if both branch and revision specified' do
|
43
|
+
output = nil
|
44
|
+
in_dir(@repository_dir) do
|
45
|
+
output = `#{BRAID_BIN} update skit1 --branch master --tag v1`
|
46
|
+
end
|
47
|
+
|
48
|
+
expect(output).to match(/^Braid: Error: Can not update mirror specifying both a branch and a tag$/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
10
52
|
describe 'from a git repository' do
|
11
53
|
before do
|
12
54
|
@repository_dir = create_git_repo_from_fixture('shiny')
|
@@ -150,4 +192,211 @@ describe 'Updating a mirror' do
|
|
150
192
|
end
|
151
193
|
end
|
152
194
|
end
|
195
|
+
|
196
|
+
describe 'from a git repository braided in as a tag' do
|
197
|
+
before do
|
198
|
+
@repository_dir = create_git_repo_from_fixture('shiny')
|
199
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
200
|
+
in_dir(@vendor_repository_dir) do
|
201
|
+
run_command('git tag v1')
|
202
|
+
end
|
203
|
+
@file_name = 'layouts/layout.liquid'
|
204
|
+
|
205
|
+
in_dir(@repository_dir) do
|
206
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --tag v1")
|
207
|
+
end
|
208
|
+
|
209
|
+
update_dir_from_fixture('skit1', 'skit1.1')
|
210
|
+
in_dir(@vendor_repository_dir) do
|
211
|
+
run_command('git add *')
|
212
|
+
run_command('git commit -m "change default color"')
|
213
|
+
end
|
214
|
+
|
215
|
+
update_dir_from_fixture('skit1', 'skit1.2')
|
216
|
+
in_dir(@vendor_repository_dir) do
|
217
|
+
run_command('git add *')
|
218
|
+
run_command('git commit -m "add a happy note"')
|
219
|
+
run_command('git tag -f v1')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'with no project-specific changes' do
|
224
|
+
it 'should add the files and commit' do
|
225
|
+
in_dir(@repository_dir) do
|
226
|
+
run_command("#{BRAID_BIN} update skit1")
|
227
|
+
end
|
228
|
+
|
229
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
230
|
+
|
231
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
232
|
+
expect(output.length).to eq(3)
|
233
|
+
expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
|
234
|
+
|
235
|
+
# No temporary commits should be added to the reflog.
|
236
|
+
output = `git log -g --pretty=oneline`.split("\n")
|
237
|
+
expect(output.length).to eq(3)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
context 'with mergeable changes to the same file' do
|
242
|
+
it 'should auto-merge and commit' do
|
243
|
+
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
244
|
+
|
245
|
+
in_dir(@repository_dir) do
|
246
|
+
run_command("git commit -a -m 'mergeable change'")
|
247
|
+
run_command("#{BRAID_BIN} update skit1")
|
248
|
+
end
|
249
|
+
|
250
|
+
assert_no_diff("#{FIXTURE_PATH}/shiny_skit1.2_merged/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
251
|
+
|
252
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
253
|
+
expect(output.length).to eq(4) # plus 'mergeable change'
|
254
|
+
expect(output[0]).to match(/Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
context 'with conflicting changes' do
|
259
|
+
it 'should leave conflict markup with the target revision' do
|
260
|
+
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_conflicting', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
261
|
+
|
262
|
+
target_revision = nil
|
263
|
+
in_dir(@vendor_repository_dir) do
|
264
|
+
target_revision = run_command('git rev-parse HEAD')
|
265
|
+
end
|
266
|
+
|
267
|
+
braid_output = nil
|
268
|
+
in_dir(@repository_dir) do
|
269
|
+
run_command("git commit -a -m 'conflicting change'")
|
270
|
+
braid_output = run_command("#{BRAID_BIN} update skit1")
|
271
|
+
end
|
272
|
+
expect(braid_output).to match(/Caught merge error\. Breaking\./)
|
273
|
+
|
274
|
+
run_command("grep -q '>>>>>>> #{target_revision}' #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
tracking_strategy =
|
280
|
+
{
|
281
|
+
'branch' => 'master',
|
282
|
+
'tag' => 'v1',
|
283
|
+
'revision' => nil,
|
284
|
+
}
|
285
|
+
|
286
|
+
tracking_strategy.each_pair do |initial_strategy, initial_value|
|
287
|
+
describe "from a git repository from tracking strategy #{initial_strategy} '#{initial_value}'" do
|
288
|
+
before do
|
289
|
+
@repository_dir = create_git_repo_from_fixture('shiny')
|
290
|
+
@vendor_repository_dir = create_git_repo_from_fixture('skit1')
|
291
|
+
@file_name = 'layouts/layout.liquid'
|
292
|
+
|
293
|
+
@initial_revision = nil
|
294
|
+
in_dir(@vendor_repository_dir) do
|
295
|
+
run_command('git tag v1')
|
296
|
+
@initial_revision = run_command('git rev-parse HEAD').strip
|
297
|
+
end
|
298
|
+
in_dir(@repository_dir) do
|
299
|
+
run_command("#{BRAID_BIN} add #{@vendor_repository_dir} --#{initial_strategy} #{initial_value || @initial_revision}")
|
300
|
+
end
|
301
|
+
|
302
|
+
update_dir_from_fixture('skit1', 'skit1.1')
|
303
|
+
in_dir(@vendor_repository_dir) do
|
304
|
+
run_command('git add *')
|
305
|
+
run_command('git commit -m "change default color"')
|
306
|
+
end
|
307
|
+
|
308
|
+
@target_revision = nil
|
309
|
+
update_dir_from_fixture('skit1', 'skit1.2')
|
310
|
+
in_dir(@vendor_repository_dir) do
|
311
|
+
run_command('git add *')
|
312
|
+
run_command('git commit -m "add a happy note"')
|
313
|
+
@target_revision = run_command('git rev-parse HEAD').strip
|
314
|
+
run_command('git tag -f v1')
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
context 'with no project-specific changes' do
|
319
|
+
if initial_strategy != 'revision'
|
320
|
+
it 'should add the files and commit' do
|
321
|
+
in_dir(@repository_dir) do
|
322
|
+
run_command("#{BRAID_BIN} update skit1")
|
323
|
+
end
|
324
|
+
|
325
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/layouts/layout.liquid")
|
326
|
+
|
327
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
328
|
+
expect(output.length).to eq(3)
|
329
|
+
expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
|
330
|
+
|
331
|
+
# No temporary commits should be added to the reflog.
|
332
|
+
output = `git log -g --pretty=oneline`.split("\n")
|
333
|
+
expect(output.length).to eq(3)
|
334
|
+
end
|
335
|
+
|
336
|
+
context 'with mergeable changes to the same file' do
|
337
|
+
it 'should auto-merge and commit' do
|
338
|
+
run_command("cp #{File.join(FIXTURE_PATH, 'shiny_skit1_mergeable', @file_name)} #{File.join(TMP_PATH, 'shiny', 'skit1', @file_name)}")
|
339
|
+
|
340
|
+
in_dir(@repository_dir) do
|
341
|
+
run_command("git commit -a -m 'mergeable change'")
|
342
|
+
run_command("#{BRAID_BIN} update skit1")
|
343
|
+
end
|
344
|
+
|
345
|
+
assert_no_diff("#{FIXTURE_PATH}/shiny_skit1.2_merged/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
346
|
+
|
347
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
348
|
+
expect(output.length).to eq(4) # plus 'mergeable change'
|
349
|
+
expect(output[0]).to match(/Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
else
|
353
|
+
it 'should not change files as revision not changed' do
|
354
|
+
in_dir(@repository_dir) do
|
355
|
+
run_command("#{BRAID_BIN} update skit1 --verbose")
|
356
|
+
end
|
357
|
+
|
358
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
|
359
|
+
|
360
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
361
|
+
expect(output.length).to eq(2)
|
362
|
+
|
363
|
+
# No temporary commits should be added to the reflog.
|
364
|
+
output = `git log -g --pretty=oneline`.split("\n")
|
365
|
+
expect(output.length).to eq(2)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
tracking_strategy.each_pair do |target_strategy, target_value|
|
371
|
+
describe "to a tracking strategy #{target_strategy} '#{target_value}'" do
|
372
|
+
it 'should add the files and commit' do
|
373
|
+
output = nil
|
374
|
+
in_dir(@repository_dir) do
|
375
|
+
output = run_command("#{BRAID_BIN} update skit1 --#{target_strategy} #{target_value || @target_revision}").split("\n")
|
376
|
+
end
|
377
|
+
|
378
|
+
index = 0
|
379
|
+
expect(output[index]).to match(/^Braid: Updating mirror 'skit1'.$/)
|
380
|
+
|
381
|
+
if initial_strategy != target_strategy || target_strategy == 'revision'
|
382
|
+
index = index + 1
|
383
|
+
expect(output[index]).to match(/^Braid: Switching mirror 'skit1' to #{target_strategy} '#{target_value || @target_revision}' from #{initial_strategy} '#{initial_value || @initial_revision}'.$/)
|
384
|
+
end
|
385
|
+
index = index + 1
|
386
|
+
expect(output[index]).to match(/^Braid: Updated mirror to '[0-9a-f]{7}'.$/)
|
387
|
+
|
388
|
+
assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{@repository_dir}/skit1/layouts/layout.liquid")
|
389
|
+
|
390
|
+
output = run_command('git log --pretty=oneline').split("\n")
|
391
|
+
expect(output.length).to eq(3)
|
392
|
+
expect(output[0]).to match(/^[0-9a-f]{40} Braid: Update mirror 'skit1' to '[0-9a-f]{7}'$/)
|
393
|
+
|
394
|
+
# No temporary commits should be added to the reflog.
|
395
|
+
output = `git log -g --pretty=oneline`.split("\n")
|
396
|
+
expect(output.length).to eq(3)
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
153
402
|
end
|
data/spec/mirror_spec.rb
CHANGED
@@ -15,6 +15,58 @@ describe 'Braid::Mirror.new_from_options' do
|
|
15
15
|
new_from_options('http://path.git', 'path' => 'vendor/tools/mytool/')
|
16
16
|
expect(@mirror.path).to eq('vendor/tools/mytool')
|
17
17
|
end
|
18
|
+
|
19
|
+
it 'should define local_ref correctly when default branch specified' do
|
20
|
+
new_from_options('http://mytool.git')
|
21
|
+
expect(@mirror.local_ref).to eq('master/braid/mytool/master')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should define local_ref correctly when explicit branch specified' do
|
25
|
+
new_from_options('http://mytool.git', 'branch' => 'mybranch')
|
26
|
+
expect(@mirror.local_ref).to eq('mybranch/braid/mytool/mybranch')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should define local_ref correctly when explicit tag specified' do
|
30
|
+
new_from_options('http://mytool.git', 'tag' => 'v1')
|
31
|
+
expect(@mirror.local_ref).to eq('tags/v1')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should raise an exception if both tag and branch specified' do
|
35
|
+
expect {
|
36
|
+
new_from_options('http://mytool.git', 'tag' => 'v1', 'branch' => 'mybranch')
|
37
|
+
}.to raise_error(Braid::Mirror::NoTagAndBranch)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should define remote_ref correctly when default branch specified' do
|
41
|
+
new_from_options('http://mytool.git')
|
42
|
+
expect(@mirror.remote_ref).to eq('+refs/heads/master')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should define remote_ref correctly when explicit branch specified' do
|
46
|
+
new_from_options('http://mytool.git', 'branch' => 'mybranch')
|
47
|
+
expect(@mirror.remote_ref).to eq('+refs/heads/mybranch')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should define remote_ref correctly when explicit tag specified' do
|
51
|
+
new_from_options('http://mytool.git', 'tag' => 'v1')
|
52
|
+
expect(@mirror.remote_ref).to eq('+refs/tags/v1')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should define remote correctly when default branch specified' do
|
56
|
+
new_from_options('http://mytool.git')
|
57
|
+
expect(@mirror.remote).to eq('master/braid/mytool')
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should define remote correctly when explicit branch specified' do
|
61
|
+
new_from_options('http://mytool.git', 'branch' => 'mybranch')
|
62
|
+
expect(@mirror.remote).to eq('mybranch/braid/mytool')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should define remote correctly when explicit tag specified' do
|
66
|
+
new_from_options('http://mytool.git', 'tag' => 'v1')
|
67
|
+
expect(@mirror.remote).to eq('v1/braid/mytool')
|
68
|
+
end
|
69
|
+
|
18
70
|
end
|
19
71
|
|
20
72
|
describe 'Braid::Mirror#diff' do
|
@@ -63,8 +115,8 @@ describe 'Braid::Mirror#inferred_revision' do
|
|
63
115
|
it 'should return the last commit before the most recent update' do
|
64
116
|
@mirror = new_from_options('git://path')
|
65
117
|
git.expects(:rev_list).times(2).returns(
|
66
|
-
|
67
|
-
|
118
|
+
"#{'a' * 40}\n",
|
119
|
+
"commit #{'b' * 40}\n#{'t' * 40}\n"
|
68
120
|
)
|
69
121
|
git.expects(:tree_hash).with(@mirror.path, 'a' * 40).returns('t' * 40)
|
70
122
|
expect(@mirror.send(:inferred_revision)).to eq('b' * 40)
|
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.18
|
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-03-
|
13
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: main
|