evilchelu-braid 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.
data/bin/braid CHANGED
@@ -51,9 +51,10 @@ Main {
51
51
  . braid add svn://remote/path --branch notmaster
52
52
  TXT
53
53
 
54
- mixin :argument_url, :option_type, :optional_path, :option_branch, :option_rails_plugin, :option_revision, :option_full
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::Operations::VERBOSE = verbose
57
58
  Braid::Command.run(:add, url, { "type" => type, "path" => path, "branch" => branch, "rails_plugin" => rails_plugin, "revision" => revision, "full" => full })
58
59
  }
59
60
  }
@@ -74,9 +75,10 @@ Main {
74
75
  . braid update local/dir
75
76
  TXT
76
77
 
77
- mixin :optional_path, :option_revision, :option_head, :option_safe
78
+ mixin :optional_path, :option_revision, :option_head, :option_safe, :option_verbose
78
79
 
79
80
  run {
81
+ Braid::Operations::VERBOSE = verbose
80
82
  Braid::Command.run(:update, path, { "revision" => revision, "head" => head , "safe" => safe })
81
83
  }
82
84
  }
@@ -94,9 +96,10 @@ Main {
94
96
  . braid remove local/dir
95
97
  TXT
96
98
 
97
- mixin :argument_path
99
+ mixin :argument_path, :option_verbose
98
100
 
99
101
  run {
102
+ Braid::Operations::VERBOSE = verbose
100
103
  Braid::Command.run(:remove, path)
101
104
  }
102
105
  }
@@ -110,9 +113,10 @@ Main {
110
113
  . braid setup local/dir
111
114
  TXT
112
115
 
113
- mixin :optional_path
116
+ mixin :optional_path, :option_verbose
114
117
 
115
118
  run {
119
+ Braid::Operations::VERBOSE = verbose
116
120
  Braid::Command.run(:setup, path)
117
121
  }
118
122
  }
@@ -126,9 +130,10 @@ Main {
126
130
  . braid diff local/dir
127
131
  TXT
128
132
 
129
- mixin :argument_path
133
+ mixin :argument_path, :option_verbose
130
134
 
131
135
  run {
136
+ Braid::Operations::VERBOSE = verbose
132
137
  Braid::Command.run(:diff, path)
133
138
  }
134
139
  }
@@ -218,6 +223,14 @@ Main {
218
223
  attr
219
224
  }
220
225
  }
226
+
227
+ mixin(:option_verbose) {
228
+ option(:verbose, :v) {
229
+ optional
230
+ desc 'log shell commands'
231
+ attr
232
+ }
233
+ }
221
234
 
222
235
  run { help! }
223
236
  }
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.11"
3
+ s.version = "0.4.12"
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-09-26}
9
+ s.date = %q{2008-10-04}
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}
@@ -14,13 +14,14 @@ module Braid
14
14
  end
15
15
  end
16
16
  class VersionTooLow < BraidError
17
- def initialize(command, version)
17
+ def initialize(command, version, required)
18
18
  @command = command
19
19
  @version = version.to_s.split("\n").first
20
+ @required = required
20
21
  end
21
22
 
22
23
  def message
23
- "#{@command} version too low: #{@version}"
24
+ "#{@command} version too low: #{@version}. #{@required} needed."
24
25
  end
25
26
  end
26
27
  class UnknownRevision < BraidError
@@ -33,12 +34,22 @@ module Braid
33
34
  "local changes are present"
34
35
  end
35
36
  end
37
+ class LocalCacheDirBroken < BraidError
38
+ def initialize(dir)
39
+ @dir = dir
40
+ end
41
+
42
+ def message
43
+ "Local cache '#{@dir}' needs to be recreated. Remove the directory and run the command again."
44
+ end
45
+ end
36
46
 
37
47
  # The command proxy is meant to encapsulate commands such as git, git-svn and svn, that work with subcommands.
38
48
  class Proxy
39
49
  include Singleton
40
50
 
41
51
  def self.command; name.split('::').last.downcase; end # hax!
52
+ def self.verbose; Braid::Operations::VERBOSE ; end
42
53
 
43
54
  def version
44
55
  status, out, err = exec!("#{self.class.command} --version")
@@ -68,7 +79,7 @@ module Braid
68
79
  end
69
80
 
70
81
  def require_version!(required)
71
- require_version(required) || raise(VersionTooLow.new(self.class.command, version))
82
+ require_version(required) || raise(VersionTooLow.new(self.class.command, version, required))
72
83
  end
73
84
 
74
85
  private
@@ -92,6 +103,7 @@ module Braid
92
103
  ENV['LANG'] = 'C'
93
104
 
94
105
  out, err = nil
106
+ puts "executing cmd(#{cmd})" if Proxy.verbose
95
107
  status = Open4.popen4(cmd) do |pid, stdin, stdout, stderr|
96
108
  out = stdout.read
97
109
  err = stderr.read
@@ -129,7 +141,7 @@ module Braid
129
141
 
130
142
  def fetch(remote)
131
143
  # open4 messes with the pipes of index-pack
132
- system("git fetch -n #{remote} &> /dev/null")
144
+ system("git fetch -n #{remote} 2>&1 >/dev/null")
133
145
  raise ShellExecutionError, "could not fetch" unless $? == 0
134
146
  true
135
147
  end
@@ -254,7 +266,7 @@ module Braid
254
266
 
255
267
  def fetch(remote)
256
268
  # open4 messes with the pipes of index-pack
257
- system("git svn fetch #{remote} &> /dev/null")
269
+ system("git svn fetch #{remote} 2>&1 >/dev/null")
258
270
  raise ShellExecutionError, "could not fetch" unless $? == 0
259
271
  true
260
272
  end
@@ -286,6 +298,11 @@ module Braid
286
298
  class GitCache < Proxy
287
299
  def init_or_fetch(url, dir)
288
300
  if File.exists? dir
301
+ # bail if the local cache was created with --no-checkout
302
+ if File.exists? "#{dir}/.git"
303
+ raise LocalCacheDirBroken.new(dir)
304
+ end
305
+
289
306
  msg "Updating local cache of '#{url}' into '#{dir}'."
290
307
  FileUtils.cd(dir) do |d|
291
308
  status, out, err = exec!("git fetch")
@@ -294,7 +311,7 @@ module Braid
294
311
  FileUtils.mkdir_p(Braid::LOCAL_CACHE_DIR)
295
312
 
296
313
  msg "Caching '#{url}' into '#{dir}'."
297
- status, out, err = exec!("git clone --no-checkout #{url} #{dir}")
314
+ status, out, err = exec!("git clone --mirror #{url} #{dir}")
298
315
  end
299
316
  end
300
317
  end
data/lib/braid.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  module Braid
4
- VERSION = "0.4.11"
4
+ VERSION = "0.4.12"
5
5
 
6
6
  CONFIG_FILE = ".braids"
7
- USE_LOCAL_CACHE = ENV["BRAID_USE_LOCAL_CACHE"] || true
7
+ USE_LOCAL_CACHE = ENV["BRAID_USE_LOCAL_CACHE"] != "no"
8
8
  LOCAL_CACHE_DIR = ENV["BRAID_LOCAL_CACHE_DIR"] || "#{ENV["HOME"]}/.braid/cache/"
9
- REQUIRED_GIT_VERSION = "1.5.4.5"
9
+ REQUIRED_GIT_VERSION = "1.6"
10
10
 
11
11
  class BraidError < StandardError
12
12
  def message
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evilchelu-braid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
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-09-26 00:00:00 -07:00
13
+ date: 2008-10-04 00:00:00 -07:00
14
14
  default_executable: braid
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency