dreamcat4-braid 0.53 → 0.531

Sign up to get free protection for your applications and to get access to all the features.
data/bin/braid CHANGED
@@ -197,7 +197,7 @@ Main {
197
197
  }
198
198
 
199
199
  mixin(:option_rails_gem) {
200
- option(:rails_gem, :p) {
200
+ option(:rails_gem, :g) {
201
201
  optional
202
202
  desc 'added mirror is a Rails gem'
203
203
  attr
data/braid.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{braid}
3
- s.version = "0.53"
3
+ s.version = "0.531"
4
4
 
5
5
  s.specification_version = 2 if s.respond_to? :specification_version=
6
6
 
@@ -18,7 +18,8 @@ module Braid
18
18
 
19
19
  if mirror.type == "git-clone"
20
20
  gitclone.add_gitignore(mirror.path)
21
- mirror.rspec_git.update
21
+ mirror.rspec_git.update options["revision"]
22
+ commit_message = "Added clone repository #{mirror.rspec_git.url} in #{mirror.path}"
22
23
  else
23
24
  mirror.fetch
24
25
 
@@ -32,11 +33,12 @@ module Braid
32
33
 
33
34
  mirror.revision = new_revision
34
35
  mirror.lock = new_revision if options["revision"]
35
- end
36
+ commit_message = "Added mirror '#{mirror.path}' at #{display_revision(mirror)}"
37
+ end
38
+
36
39
  config.update(mirror)
37
40
  add_config_file
38
41
 
39
- commit_message = "Added mirror '#{mirror.path}' at #{display_revision(mirror)}"
40
42
 
41
43
  git.commit(commit_message)
42
44
  msg commit_message
@@ -14,6 +14,7 @@ module Braid
14
14
  FileUtils.rm_rf(mirror.path)
15
15
  config.remove(mirror)
16
16
  add_config_file
17
+ commit_message = "Removed clone repository '#{mirror.path}'"
17
18
  else
18
19
  git.rm_r(mirror.path)
19
20
 
@@ -28,9 +29,9 @@ module Braid
28
29
  else
29
30
  msg "Remote '#{mirror.remote}' not found, nothing to cleanup" if verbose?
30
31
  end
32
+ commit_message = "Removed mirror '#{mirror.path}'"
31
33
  end
32
34
 
33
- commit_message = "Removed mirror '#{mirror.path}'"
34
35
  git.commit(commit_message)
35
36
  msg commit_message
36
37
  end
data/lib/braid/mirror.rb CHANGED
@@ -1,3 +1,4 @@
1
+ $:.unshift File.dirname(__FILE__)
1
2
  require 'rspec_git.rb'
2
3
 
3
4
  module Braid
@@ -28,7 +29,7 @@ module Braid
28
29
  def initialize(path, attributes = {})
29
30
  @path = path.sub(/\/$/, '')
30
31
  @attributes = attributes
31
- @rspec_git = RSpec::Git.new File.basename(@path) @path attributes["url"]
32
+ @rspec_git = RSpec::Git.new(File.basename(@path), @path, attributes["url"])
32
33
  end
33
34
 
34
35
  def self.new_from_options(url, options = {})
@@ -45,19 +46,21 @@ module Braid
45
46
  unless path = options["path"] || extract_path_from_url(url)
46
47
  raise PathRequired
47
48
  end
48
-
49
- if options["rails_plugin"] && ! path =~ /vendor\/plugins.*/
49
+
50
+ if options["rails_plugin"] && ( path =~ /vendor\/plugins.*/ ) == nil
50
51
  path = "vendor/plugins/#{path}"
51
52
  end
52
53
 
53
- if options["rails_gem"] && ! path =~ /vendor\/gems.*/
54
+ if options["rails_gem"] && (path =~ /vendor\/gems.*/ ) == nil
54
55
  path = "vendor/gems/#{path}"
55
56
  end
56
-
57
- remote = "braid/#{path}".gsub("_", '-') # stupid git svn changes all _ to ., weird
58
- squashed = !options["full"]
59
- branch = nil if type == "svn"
60
-
57
+
58
+ if type != "git-clone"
59
+ remote = "braid/#{path}".gsub("_", '-') # stupid git svn changes all _ to ., weird
60
+ squashed = !options["full"]
61
+ branch = nil if type == "svn"
62
+ end
63
+
61
64
  attributes = { "url" => url, "remote" => remote, "type" => type, "branch" => branch, "squashed" => squashed }
62
65
  self.new(path, attributes)
63
66
  end
@@ -137,60 +137,71 @@ module Braid
137
137
  end
138
138
  end
139
139
 
140
- class GitClone < Proxy
140
+ class GitClone
141
+
142
+ include Singleton
143
+
141
144
  def in_rep_root_check
142
145
  if ! File.exists?(".git")
143
146
  raise("Not in root repository.")
144
147
  end
145
148
  end
146
-
149
+
147
150
  def add_gitignore(path)
148
- # add mirror to .gitignore file
151
+ # remove mirror from .gitignore file
149
152
  in_rep_root_check
150
- if ! File.exists?(".gitignore")
151
- f = File.new(".gitignore", "w+")
152
- else
153
- f = File.open( 'index', 'w+')
153
+ if File.exists?(".gitignore")
154
+ f = File.open( '.gitignore', 'r+')
155
+ path_ignored = nil
156
+ f.each { |line|
157
+ if line == path+"\n"
158
+ path_ignored = line
159
+ end
160
+ }
161
+ f.rewind
162
+ f.close
163
+
164
+ if ! path_ignored
165
+ date_str = Date.new.to_s
166
+ f = File.open( '.gitignore', 'r+')
167
+ n = File.new(".gitignore-#{date_str}", "w+")
168
+ f.each { |line| n.puts line }
169
+ n.puts path+"\n"
170
+ n.close
171
+ f.close
172
+ File.rename( ".gitignore-#{date_str}", ".gitignore" )
173
+ Git.instance.add(".gitignore")
174
+ end
154
175
  end
155
-
156
- f.each { |line|
157
- if line == path
158
- path_ignored = line
159
- end
160
- }
161
- if ! ignored
162
- f.puts path
163
- git.add(".gitignore")
164
- end
165
- f.close
166
176
  end
167
177
 
168
178
  def remove_gitignore(path)
169
179
  # remove mirror from .gitignore file
170
180
  in_rep_root_check
171
181
  if File.exists?(".gitignore")
172
- f = File.open( 'index', 'w+')
173
-
182
+ f = File.open( '.gitignore', 'r+')
183
+ path_ignored = nil
174
184
  f.each { |line|
175
- if line == path
185
+ if line == path+"\n"
176
186
  path_ignored = line
177
187
  end
178
188
  }
179
189
  f.rewind
180
-
190
+ f.close
191
+
181
192
  if path_ignored
182
193
  date_str= Date.new.to_s
194
+ f = File.open( '.gitignore', 'r+')
183
195
  n = File.new(".gitignore-#{date_str}", "w+")
184
196
  f.each { |line|
185
197
  n.puts line unless line == path_ignored
186
198
  }
187
199
  n.close
200
+ f.close
201
+ File.rename( ".gitignore-#{date_str}", ".gitignore" )
202
+ Git.instance.add(".gitignore")
188
203
  end
189
- f.close
190
- File.rename( ".gitignore-#{date_str}", ".gitignore" )
191
- git.add(".gitignore")
192
204
  end
193
-
194
205
  end
195
206
 
196
207
  private
@@ -198,7 +209,7 @@ module Braid
198
209
  "#{self.class.command} #{name}"
199
210
  end
200
211
 
201
- def git
212
+ def gitclone
202
213
  GitClone.instance
203
214
  end
204
215
  end
@@ -436,6 +447,10 @@ module Braid
436
447
  end
437
448
 
438
449
  module VersionControl
450
+ def gitclone
451
+ GitClone.instance
452
+ end
453
+
439
454
  def git
440
455
  Git.instance
441
456
  end
@@ -9,6 +9,10 @@ module RSpec
9
9
  @url = url
10
10
  end
11
11
 
12
+ def msg(str)
13
+ puts "RSpec: #{str}"
14
+ end
15
+
12
16
  def plugins_fetched?
13
17
  submodules.all? {|s| File.directory?(s[:path]) }
14
18
  end
@@ -19,8 +23,9 @@ module RSpec
19
23
  repos.each do |r|
20
24
  if File.exist?(r[:path])
21
25
  msg "** Updating #{r[:name]}"
22
- # target = ENV['REMOTE'] ? "#{ENV['REMOTE']} master" : ""
23
- unless system("cd #{r[:path]} && git pull --rebase #{target}")
26
+ target = target ? target : "master"
27
+ # unless system("cd #{r[:path]} && git pull --rebase #{target}")
28
+ unless system("cd #{r[:path]} && git pull --rebase #{r[:url]} #{target}")
24
29
  msg "Error updating #{r[:name]}"
25
30
  exit 1
26
31
  end
data/lib/braid.rb CHANGED
@@ -9,7 +9,8 @@ module Braid
9
9
  def self.verbose; @verbose || false; end
10
10
  def self.verbose=(new_value); @verbose = !!new_value; end
11
11
 
12
- def self.use_local_cache; [nil, "true", "1"].include?(ENV["BRAID_USE_LOCAL_CACHE"]); end
12
+ # def self.use_local_cache; [nil, "true", "1"].include?(ENV["BRAID_USE_LOCAL_CACHE"]); end
13
+ def self.use_local_cache; false; end
13
14
  def self.local_cache_dir; File.expand_path(ENV["BRAID_LOCAL_CACHE_DIR"] || "#{ENV["HOME"]}/.braid/cache"); end
14
15
 
15
16
  class BraidError < StandardError
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dreamcat4-braid
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.53"
4
+ version: "0.531"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristi Balan