norbert-braid 0.4.12 → 0.4.13
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.
- data/bin/braid +6 -15
- data/braid.gemspec +2 -2
- data/lib/braid/command.rb +5 -1
- data/lib/braid/commands/add.rb +4 -4
- data/lib/braid/commands/setup.rb +3 -2
- data/lib/braid/commands/update.rb +37 -19
- data/lib/braid/mirror.rb +13 -21
- data/lib/braid/operations.rb +79 -39
- data/lib/braid.rb +7 -3
- data/test/integration/updating_test.rb +2 -2
- data/test/mirror_test.rb +12 -20
- data/test/operations_test.rb +9 -17
- metadata +2 -2
data/bin/braid
CHANGED
@@ -54,7 +54,7 @@ Main {
|
|
54
54
|
mixin :argument_url, :option_type, :optional_path, :option_branch, :option_rails_plugin, :option_revision, :option_full, :option_verbose
|
55
55
|
|
56
56
|
run {
|
57
|
-
Braid
|
57
|
+
Braid.verbose = verbose
|
58
58
|
Braid::Command.run(:add, url, { "type" => type, "path" => path, "branch" => branch, "rails_plugin" => rails_plugin, "revision" => revision, "full" => full })
|
59
59
|
}
|
60
60
|
}
|
@@ -75,11 +75,11 @@ Main {
|
|
75
75
|
. braid update local/dir
|
76
76
|
TXT
|
77
77
|
|
78
|
-
mixin :optional_path, :option_revision, :option_head, :
|
78
|
+
mixin :optional_path, :option_revision, :option_head, :option_verbose
|
79
79
|
|
80
80
|
run {
|
81
|
-
Braid
|
82
|
-
Braid::Command.run(:update, path, { "revision" => revision, "head" => head
|
81
|
+
Braid.verbose = verbose
|
82
|
+
Braid::Command.run(:update, path, { "revision" => revision, "head" => head })
|
83
83
|
}
|
84
84
|
}
|
85
85
|
|
@@ -99,7 +99,7 @@ Main {
|
|
99
99
|
mixin :argument_path, :option_verbose
|
100
100
|
|
101
101
|
run {
|
102
|
-
Braid
|
102
|
+
Braid.verbose = verbose
|
103
103
|
Braid::Command.run(:remove, path)
|
104
104
|
}
|
105
105
|
}
|
@@ -116,7 +116,7 @@ Main {
|
|
116
116
|
mixin :optional_path, :option_verbose
|
117
117
|
|
118
118
|
run {
|
119
|
-
Braid
|
119
|
+
Braid.verbose = verbose
|
120
120
|
Braid::Command.run(:setup, path)
|
121
121
|
}
|
122
122
|
}
|
@@ -133,7 +133,6 @@ Main {
|
|
133
133
|
mixin :argument_path, :option_verbose
|
134
134
|
|
135
135
|
run {
|
136
|
-
Braid::Operations::VERBOSE = verbose
|
137
136
|
Braid::Command.run(:diff, path)
|
138
137
|
}
|
139
138
|
}
|
@@ -216,14 +215,6 @@ Main {
|
|
216
215
|
}
|
217
216
|
}
|
218
217
|
|
219
|
-
mixin(:option_safe) {
|
220
|
-
option(:safe) {
|
221
|
-
optional
|
222
|
-
desc 'safe on merge errors'
|
223
|
-
attr
|
224
|
-
}
|
225
|
-
}
|
226
|
-
|
227
218
|
mixin(:option_verbose) {
|
228
219
|
option(:verbose, :v) {
|
229
220
|
optional
|
data/braid.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{braid}
|
3
|
-
s.version = "0.4.
|
3
|
+
s.version = "0.4.13"
|
4
4
|
|
5
5
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Cristi Balan", "Norbert Crombach"]
|
9
|
-
s.date = %q{2008-10-
|
9
|
+
s.date = %q{2008-10-23}
|
10
10
|
s.default_executable = %q{braid}
|
11
11
|
s.description = %q{A simple tool for tracking vendor branches in git.}
|
12
12
|
s.email = %q{evil@che.lu}
|
data/lib/braid/command.rb
CHANGED
@@ -35,6 +35,10 @@ module Braid
|
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
|
+
def use_local_cache?
|
39
|
+
Braid.use_local_cache
|
40
|
+
end
|
41
|
+
|
38
42
|
def self.verify_git_version!
|
39
43
|
git.require_version!(REQUIRED_GIT_VERSION)
|
40
44
|
end
|
@@ -108,7 +112,7 @@ module Braid
|
|
108
112
|
new_revision
|
109
113
|
end
|
110
114
|
|
111
|
-
def
|
115
|
+
def determine_target_revision(mirror, new_revision)
|
112
116
|
unless mirror.type == "svn"
|
113
117
|
git.rev_parse(new_revision)
|
114
118
|
else
|
data/lib/braid/commands/add.rb
CHANGED
@@ -8,7 +8,7 @@ module Braid
|
|
8
8
|
mirror = config.add_from_options(url, options)
|
9
9
|
|
10
10
|
branch_message = (mirror.type == "svn" || mirror.branch == "master") ? "" : " branch '#{mirror.branch}'"
|
11
|
-
revision_message = options["revision"] ? " at #{display_revision(mirror)}" : ""
|
11
|
+
revision_message = options["revision"] ? " at #{display_revision(mirror, options["revision"])}" : ""
|
12
12
|
msg "Adding #{mirror.type} mirror of '#{mirror.url}'#{branch_message}#{revision_message}."
|
13
13
|
|
14
14
|
# these commands are explained in the subtree merge guide
|
@@ -18,12 +18,12 @@ module Braid
|
|
18
18
|
mirror.fetch
|
19
19
|
|
20
20
|
new_revision = validate_new_revision(mirror, options["revision"])
|
21
|
-
|
21
|
+
target_revision = determine_target_revision(mirror, new_revision)
|
22
22
|
|
23
23
|
unless mirror.squashed?
|
24
|
-
git.merge_ours(
|
24
|
+
git.merge_ours(target_revision)
|
25
25
|
end
|
26
|
-
git.
|
26
|
+
git.read_tree_prefix(target_revision, mirror.path)
|
27
27
|
|
28
28
|
mirror.revision = new_revision
|
29
29
|
mirror.lock = new_revision if options["revision"]
|
data/lib/braid/commands/setup.rb
CHANGED
@@ -16,14 +16,15 @@ module Braid
|
|
16
16
|
def setup_one(path)
|
17
17
|
mirror = config.get!(path)
|
18
18
|
|
19
|
-
if git.
|
19
|
+
if git.remote_url(mirror.remote)
|
20
20
|
msg "Mirror '#{mirror.path}/' already has a remote. Skipping."
|
21
21
|
return
|
22
22
|
end
|
23
23
|
|
24
24
|
msg "Setting up remote for '#{mirror.path}/'."
|
25
25
|
unless mirror.type == "svn"
|
26
|
-
|
26
|
+
url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
|
27
|
+
git.remote_add(mirror.remote, url, mirror.branch)
|
27
28
|
else
|
28
29
|
git_svn.init(mirror.remote, mirror.url)
|
29
30
|
end
|
@@ -35,44 +35,62 @@ module Braid
|
|
35
35
|
mirror.fetch
|
36
36
|
|
37
37
|
new_revision = validate_new_revision(mirror, options["revision"])
|
38
|
-
|
38
|
+
target_revision = determine_target_revision(mirror, new_revision)
|
39
39
|
|
40
|
-
if mirror.merged?(
|
40
|
+
if mirror.merged?(target_revision)
|
41
41
|
msg "Mirror '#{mirror.path}/' is already up to date. Skipping."
|
42
42
|
return
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
if mirror.squashed?
|
46
|
+
diff = mirror.diff
|
47
|
+
base_revision = mirror.base_revision
|
48
|
+
end
|
46
49
|
|
47
50
|
mirror.revision = new_revision
|
48
51
|
mirror.lock = new_revision if options["revision"]
|
49
|
-
config.update(mirror)
|
50
52
|
|
51
53
|
msg "Updating mirror '#{mirror.path}/'."
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
begin
|
55
|
+
if mirror.squashed?
|
56
|
+
local_hash = git.rev_parse("HEAD")
|
57
|
+
if diff
|
58
|
+
base_hash = generate_tree_hash(mirror, base_revision)
|
59
|
+
else
|
60
|
+
base_hash = local_hash
|
61
|
+
end
|
62
|
+
remote_hash = generate_tree_hash(mirror, target_revision)
|
63
|
+
ENV["GITHEAD_#{local_hash}"] = "HEAD"
|
64
|
+
ENV["GITHEAD_#{remote_hash}"] = target_revision
|
65
|
+
git.merge_recursive(base_hash, local_hash, remote_hash)
|
66
|
+
else
|
67
|
+
git.merge_subtree(target_revision)
|
57
68
|
end
|
58
|
-
|
59
|
-
|
69
|
+
rescue Operations::MergeError => error
|
70
|
+
msg "Caught merge error. Breaking."
|
60
71
|
end
|
61
72
|
|
73
|
+
config.update(mirror)
|
62
74
|
add_config_file
|
63
75
|
|
64
|
-
|
65
|
-
commit_message = "Update mirror '#{mirror.path}/'#{revision_message}"
|
66
|
-
git.commit(commit_message)
|
76
|
+
commit_message = "Update mirror '#{mirror.path}/' to #{display_revision(mirror)}"
|
67
77
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
exit(0)
|
78
|
+
if error
|
79
|
+
File.open(".git/MERGE_MSG", 'w') { |f| f.puts(commit_message) }
|
80
|
+
return
|
72
81
|
else
|
73
|
-
|
82
|
+
git.commit(commit_message)
|
74
83
|
end
|
75
84
|
end
|
85
|
+
|
86
|
+
def generate_tree_hash(mirror, revision)
|
87
|
+
git.rm_r(mirror.path)
|
88
|
+
git.read_tree_prefix(revision, mirror.path)
|
89
|
+
success = git.commit("Temporary commit for mirror '#{mirror.path}/'")
|
90
|
+
hash = git.rev_parse("HEAD")
|
91
|
+
git.reset_hard("HEAD^") if success
|
92
|
+
hash
|
93
|
+
end
|
76
94
|
end
|
77
95
|
end
|
78
96
|
end
|
data/lib/braid/mirror.rb
CHANGED
@@ -91,23 +91,27 @@ module Braid
|
|
91
91
|
|
92
92
|
def fetch
|
93
93
|
unless type == "svn"
|
94
|
-
|
94
|
+
git_cache.fetch(url) if cached?
|
95
95
|
git.fetch(remote)
|
96
96
|
else
|
97
97
|
git_svn.fetch(remote)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
102
|
-
|
103
|
-
File.join(Braid::LOCAL_CACHE_DIR, url.gsub(/[\/:@]/, "_"))
|
104
|
-
else
|
105
|
-
url
|
106
|
-
end
|
101
|
+
def cached?
|
102
|
+
git.remote_url(remote) == git_cache.path(url)
|
107
103
|
end
|
108
104
|
|
109
|
-
def
|
110
|
-
|
105
|
+
def base_revision
|
106
|
+
if revision
|
107
|
+
unless type == "svn"
|
108
|
+
git.rev_parse(revision)
|
109
|
+
else
|
110
|
+
git_svn.commit_hash(remote, revision)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
inferred_revision
|
114
|
+
end
|
111
115
|
end
|
112
116
|
|
113
117
|
private
|
@@ -123,18 +127,6 @@ module Braid
|
|
123
127
|
end
|
124
128
|
end
|
125
129
|
|
126
|
-
def base_revision
|
127
|
-
if revision
|
128
|
-
unless type == "svn"
|
129
|
-
git.rev_parse(revision)
|
130
|
-
else
|
131
|
-
git_svn.commit_hash(remote, revision)
|
132
|
-
end
|
133
|
-
else
|
134
|
-
inferred_revision
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
130
|
def inferred_revision
|
139
131
|
local_commits = git.rev_list("HEAD", "-- #{path}").split("\n")
|
140
132
|
remote_hashes = git.rev_list("--pretty=format:\"%T\"", remote).split("commit ").map do |chunk|
|
data/lib/braid/operations.rb
CHANGED
@@ -34,13 +34,9 @@ module Braid
|
|
34
34
|
"local changes are present"
|
35
35
|
end
|
36
36
|
end
|
37
|
-
class
|
38
|
-
def initialize(dir)
|
39
|
-
@dir = dir
|
40
|
-
end
|
41
|
-
|
37
|
+
class MergeError < BraidError
|
42
38
|
def message
|
43
|
-
"
|
39
|
+
"could not merge"
|
44
40
|
end
|
45
41
|
end
|
46
42
|
|
@@ -49,7 +45,6 @@ module Braid
|
|
49
45
|
include Singleton
|
50
46
|
|
51
47
|
def self.command; name.split('::').last.downcase; end # hax!
|
52
|
-
def self.verbose; Braid::Operations::VERBOSE ; end
|
53
48
|
|
54
49
|
def version
|
55
50
|
status, out, err = exec!("#{self.class.command} --version")
|
@@ -103,7 +98,7 @@ module Braid
|
|
103
98
|
ENV['LANG'] = 'C'
|
104
99
|
|
105
100
|
out, err = nil
|
106
|
-
|
101
|
+
log(cmd)
|
107
102
|
status = Open4.popen4(cmd) do |pid, stdin, stdout, stderr|
|
108
103
|
out = stdout.read
|
109
104
|
err = stderr.read
|
@@ -120,10 +115,25 @@ module Braid
|
|
120
115
|
[status, out, err]
|
121
116
|
end
|
122
117
|
|
118
|
+
def sh(cmd, message = nil)
|
119
|
+
message ||= "could not fetch" if cmd =~ /fetch/
|
120
|
+
log(cmd)
|
121
|
+
system(cmd)
|
122
|
+
raise ShellExecutionError, message unless $? == 0
|
123
|
+
true
|
124
|
+
end
|
125
|
+
|
123
126
|
def msg(str)
|
124
127
|
puts str
|
125
128
|
end
|
126
129
|
|
130
|
+
def log(cmd)
|
131
|
+
msg "Executing `#{cmd}`" if verbose?
|
132
|
+
end
|
133
|
+
|
134
|
+
def verbose?
|
135
|
+
Braid.verbose
|
136
|
+
end
|
127
137
|
end
|
128
138
|
|
129
139
|
class Git < Proxy
|
@@ -139,16 +149,13 @@ module Braid
|
|
139
149
|
end
|
140
150
|
end
|
141
151
|
|
142
|
-
def fetch(remote)
|
152
|
+
def fetch(remote = nil)
|
153
|
+
args = remote && "-n #{remote}"
|
143
154
|
# open4 messes with the pipes of index-pack
|
144
|
-
|
145
|
-
raise ShellExecutionError, "could not fetch" unless $? == 0
|
146
|
-
true
|
155
|
+
sh("git fetch #{args} 2>&1 >/dev/null")
|
147
156
|
end
|
148
157
|
|
149
158
|
def checkout(treeish)
|
150
|
-
# TODO debug
|
151
|
-
msg "Checking out '#{treeish}'."
|
152
159
|
invoke(:checkout, treeish)
|
153
160
|
true
|
154
161
|
end
|
@@ -173,9 +180,15 @@ module Braid
|
|
173
180
|
end
|
174
181
|
|
175
182
|
# Checks git and svn remotes.
|
176
|
-
def
|
177
|
-
|
178
|
-
|
183
|
+
def remote_url(remote)
|
184
|
+
key = "remote.#{remote}.url"
|
185
|
+
begin
|
186
|
+
invoke(:config, key)
|
187
|
+
rescue ShellExecutionError
|
188
|
+
invoke(:config, "svn-#{key}")
|
189
|
+
end
|
190
|
+
rescue ShellExecutionError
|
191
|
+
nil
|
179
192
|
end
|
180
193
|
|
181
194
|
def reset_hard(target)
|
@@ -194,9 +207,18 @@ module Braid
|
|
194
207
|
# TODO which options are needed?
|
195
208
|
invoke(:merge, "-s subtree --no-commit --no-ff", opt)
|
196
209
|
true
|
210
|
+
rescue ShellExecutionError
|
211
|
+
raise MergeError
|
212
|
+
end
|
213
|
+
|
214
|
+
def merge_recursive(base_hash, local_hash, remote_hash)
|
215
|
+
invoke(:merge_recursive, base_hash, "-- #{local_hash} #{remote_hash}")
|
216
|
+
true
|
217
|
+
rescue ShellExecutionError
|
218
|
+
raise MergeError
|
197
219
|
end
|
198
220
|
|
199
|
-
def
|
221
|
+
def read_tree_prefix(treeish, prefix)
|
200
222
|
invoke(:read_tree, "--prefix=#{prefix}/ -u", treeish)
|
201
223
|
true
|
202
224
|
end
|
@@ -248,6 +270,11 @@ module Braid
|
|
248
270
|
true
|
249
271
|
end
|
250
272
|
|
273
|
+
def clone(*args)
|
274
|
+
# overrides builtin
|
275
|
+
invoke(:clone, *args)
|
276
|
+
end
|
277
|
+
|
251
278
|
private
|
252
279
|
def command(name)
|
253
280
|
"#{self.class.command} #{name.to_s.gsub('_', '-')}"
|
@@ -261,14 +288,11 @@ module Braid
|
|
261
288
|
out = invoke(:log, "--show-commit --oneline", "-r #{revision}", remote)
|
262
289
|
part = out.to_s.split(" | ")[1]
|
263
290
|
raise UnknownRevision, "r#{revision}" unless part
|
264
|
-
|
291
|
+
git.rev_parse(part)
|
265
292
|
end
|
266
293
|
|
267
294
|
def fetch(remote)
|
268
|
-
|
269
|
-
system("git svn fetch #{remote} 2>&1 >/dev/null")
|
270
|
-
raise ShellExecutionError, "could not fetch" unless $? == 0
|
271
|
-
true
|
295
|
+
sh("git svn fetch #{remote} 2>&1 >/dev/null")
|
272
296
|
end
|
273
297
|
|
274
298
|
def init(remote, path)
|
@@ -280,6 +304,10 @@ module Braid
|
|
280
304
|
def command(name)
|
281
305
|
"#{self.class.command} #{name}"
|
282
306
|
end
|
307
|
+
|
308
|
+
def git
|
309
|
+
Git.instance
|
310
|
+
end
|
283
311
|
end
|
284
312
|
|
285
313
|
class Svn < Proxy
|
@@ -295,25 +323,39 @@ module Braid
|
|
295
323
|
end
|
296
324
|
end
|
297
325
|
|
298
|
-
class GitCache
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
raise LocalCacheDirBroken.new(dir)
|
304
|
-
end
|
326
|
+
class GitCache
|
327
|
+
include Singleton
|
328
|
+
|
329
|
+
def fetch(url)
|
330
|
+
dir = path(url)
|
305
331
|
|
306
|
-
|
307
|
-
|
308
|
-
|
332
|
+
# remove local cache if it was created with --no-checkout
|
333
|
+
if File.exists?("#{dir}/.git")
|
334
|
+
FileUtils.rm_r(dir)
|
335
|
+
end
|
336
|
+
|
337
|
+
if File.exists?(dir)
|
338
|
+
Dir.chdir(dir) do
|
339
|
+
git.fetch
|
309
340
|
end
|
310
341
|
else
|
311
|
-
FileUtils.mkdir_p(
|
312
|
-
|
313
|
-
msg "Caching '#{url}' into '#{dir}'."
|
314
|
-
status, out, err = exec!("git clone --mirror #{url} #{dir}")
|
342
|
+
FileUtils.mkdir_p(local_cache_dir)
|
343
|
+
git.clone("--mirror", url, dir)
|
315
344
|
end
|
316
345
|
end
|
346
|
+
|
347
|
+
def path(url)
|
348
|
+
File.join(local_cache_dir, url.gsub(/[\/:@]/, "_"))
|
349
|
+
end
|
350
|
+
|
351
|
+
private
|
352
|
+
def local_cache_dir
|
353
|
+
Braid.local_cache_dir
|
354
|
+
end
|
355
|
+
|
356
|
+
def git
|
357
|
+
Git.instance
|
358
|
+
end
|
317
359
|
end
|
318
360
|
|
319
361
|
module VersionControl
|
@@ -335,5 +377,3 @@ module Braid
|
|
335
377
|
end
|
336
378
|
end
|
337
379
|
end
|
338
|
-
|
339
|
-
|
data/lib/braid.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__)
|
2
2
|
|
3
3
|
module Braid
|
4
|
-
VERSION = "0.4.
|
4
|
+
VERSION = "0.4.13"
|
5
5
|
|
6
6
|
CONFIG_FILE = ".braids"
|
7
|
-
USE_LOCAL_CACHE = ENV["BRAID_USE_LOCAL_CACHE"] != "no"
|
8
|
-
LOCAL_CACHE_DIR = ENV["BRAID_LOCAL_CACHE_DIR"] || "#{ENV["HOME"]}/.braid/cache/"
|
9
7
|
REQUIRED_GIT_VERSION = "1.6"
|
10
8
|
|
9
|
+
def self.verbose; @verbose || false; end
|
10
|
+
def self.verbose=(new_value); @verbose = !!new_value; end
|
11
|
+
|
12
|
+
def self.use_local_cache; [nil, "true", "1"].include?(ENV["BRAID_USE_LOCAL_CACHE"]); end
|
13
|
+
def self.local_cache_dir; File.expand_path(ENV["BRAID_LOCAL_CACHE_DIR"] || "#{ENV["HOME"]}/.braid/cache"); end
|
14
|
+
|
11
15
|
class BraidError < StandardError
|
12
16
|
def message
|
13
17
|
value = super
|
@@ -41,7 +41,7 @@ describe "Updating a mirror without conflicts" do
|
|
41
41
|
|
42
42
|
output = `git log --pretty=oneline`.split("\n")
|
43
43
|
output.length.should == 3
|
44
|
-
output[0].should =~
|
44
|
+
output[0].should =~ /Update mirror 'skit1\/' to '[0-9a-f]{7}'/
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -79,7 +79,7 @@ describe "Updating a mirror without conflicts" do
|
|
79
79
|
|
80
80
|
output = `git log --pretty=oneline`.split("\n")
|
81
81
|
output.length.should == 3
|
82
|
-
output[0].should =~ "Update mirror 'skit1/' to
|
82
|
+
output[0].should =~ "Update mirror 'skit1/' to r3"
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
data/test/mirror_test.rb
CHANGED
@@ -71,13 +71,13 @@ describe "Braid::Mirror#base_revision" do
|
|
71
71
|
@mirror = build_mirror
|
72
72
|
@mirror.revision.should.be.nil
|
73
73
|
@mirror.expects(:inferred_revision).returns('b' * 40)
|
74
|
-
@mirror.
|
74
|
+
@mirror.base_revision.should == 'b' * 40
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should be the parsed hash for git mirrors" do
|
78
78
|
@mirror = build_mirror("revision" => 'a' * 7)
|
79
79
|
git.expects(:rev_parse).with('a' * 7).returns('a' * 40)
|
80
|
-
@mirror.
|
80
|
+
@mirror.base_revision.should == 'a' * 40
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -93,26 +93,18 @@ describe "Braid::Mirror#inferred_revision" do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
describe "Braid::Mirror#
|
97
|
-
|
98
|
-
@mirror = new_from_options("git://
|
99
|
-
@mirror.cached_url.should == "#{ENV["HOME"]}/.braid/cache/git___remoteurl_path_to_repo.git"
|
100
|
-
|
101
|
-
@mirror = new_from_options("git@remoteurl/path/to/repo.git")
|
102
|
-
@mirror.cached_url.should == "#{ENV["HOME"]}/.braid/cache/git_remoteurl_path_to_repo.git"
|
103
|
-
|
104
|
-
@mirror = new_from_options("remoteurl/path/to/repo/", "type" => "git")
|
105
|
-
@mirror.cached_url.should == "#{ENV["HOME"]}/.braid/cache/remoteurl_path_to_repo"
|
96
|
+
describe "Braid::Mirror#cached?" do
|
97
|
+
before(:each) do
|
98
|
+
@mirror = new_from_options("git://path")
|
106
99
|
end
|
107
|
-
end
|
108
100
|
|
109
|
-
|
110
|
-
|
111
|
-
@mirror
|
112
|
-
git_cache.expects(:init_or_fetch).with("git@remoteurl/path/to/repo.git", "#{ENV["HOME"]}/.braid/cache/git_remoteurl_path_to_repo.git")
|
113
|
-
@mirror.init_or_fetch_local_cache
|
101
|
+
it "should be true when the remote path matches the cache path" do
|
102
|
+
git.expects(:remote_url).with(@mirror.remote).returns(git_cache.path(@mirror.url))
|
103
|
+
@mirror.should.be.cached
|
114
104
|
end
|
115
105
|
|
106
|
+
it "should be false if the remote does not point to the cache" do
|
107
|
+
git.expects(:remote_url).with(@mirror.remote).returns(@mirror.url)
|
108
|
+
@mirror.should.not.be.cached
|
109
|
+
end
|
116
110
|
end
|
117
|
-
|
118
|
-
|
data/test/operations_test.rb
CHANGED
@@ -1,20 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
|
-
describe "Braid::Operations::Git#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
it "should return true for existing git remotes" do
|
9
|
-
git.remote_exists?("braid/git/one").should == true
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return true for existing svn remotes" do
|
13
|
-
git.remote_exists?("braid/git/two").should == true
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should return false for nonexistent remotes" do
|
17
|
-
git.remote_exists?("N/A").should == false
|
3
|
+
describe "Braid::Operations::Git#remote_url" do
|
4
|
+
it "should use git config" do
|
5
|
+
# FIXME weak test
|
6
|
+
git.expects(:invoke).with(:config, 'remote.braid/git/one.url').returns("git://path")
|
7
|
+
git.remote_url("braid/git/one").should == "git://path"
|
18
8
|
end
|
19
9
|
end
|
20
10
|
|
@@ -68,7 +58,9 @@ describe "Braid::Operations::Git#require_version" do
|
|
68
58
|
end
|
69
59
|
end
|
70
60
|
|
71
|
-
describe "Braid::Operations::GitCache#
|
72
|
-
it "should
|
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")
|
73
65
|
end
|
74
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: norbert-braid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cristi Balan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-10-
|
13
|
+
date: 2008-10-23 00:00:00 -07:00
|
14
14
|
default_executable: braid
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|