realityforge-braid 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - jruby-19mode
data/bin/braid CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
4
4
  require 'braid'
5
5
 
6
6
  require 'rubygems'
@@ -44,7 +44,7 @@ Main {
44
44
 
45
45
  run {
46
46
  Braid.verbose = verbose
47
- Braid::Command.run(:add, url, {"path" => path, "branch" => branch, "revision" => revision, "full" => full})
47
+ Braid::Command.run(:add, url, {'path' => path, 'branch' => branch, 'revision' => revision, 'full' => full})
48
48
  }
49
49
  }
50
50
 
@@ -68,7 +68,7 @@ Main {
68
68
 
69
69
  run {
70
70
  Braid.verbose = verbose
71
- Braid::Command.run(:update, path, {"revision" => revision, "head" => head})
71
+ Braid::Command.run(:update, path, {'revision' => revision, 'head' => head})
72
72
  }
73
73
  }
74
74
 
data/lib/braid/mirror.rb CHANGED
@@ -9,7 +9,7 @@ module Braid
9
9
  end
10
10
  class PathRequired < BraidError
11
11
  def message
12
- "path is required"
12
+ 'path is required'
13
13
  end
14
14
  end
15
15
 
@@ -25,16 +25,16 @@ module Braid
25
25
  def self.new_from_options(url, options = {})
26
26
  url = url.sub(/\/$/, '')
27
27
 
28
- branch = options["branch"] || "master"
28
+ branch = options['branch'] || 'master'
29
29
 
30
- unless path = options["path"] || extract_path_from_url(url)
30
+ unless path = options['path'] || extract_path_from_url(url)
31
31
  raise PathRequired
32
32
  end
33
33
 
34
34
  remote = "#{branch}/braid/#{path}"
35
- squashed = !options["full"]
35
+ squashed = !options['full']
36
36
 
37
- attributes = {"url" => url, "remote" => remote, "branch" => branch, "squashed" => squashed}
37
+ attributes = {'url' => url, 'remote' => remote, 'branch' => branch, 'squashed' => squashed}
38
38
  self.new(path, attributes)
39
39
  end
40
40
 
@@ -57,14 +57,15 @@ module Braid
57
57
  if squashed?
58
58
  !!base_revision && git.merge_base(commit, base_revision) == commit
59
59
  else
60
- git.merge_base(commit, "HEAD") == commit
60
+ git.merge_base(commit, 'HEAD') == commit
61
61
  end
62
62
  end
63
63
 
64
64
  def diff
65
+ fetch
65
66
  remote_hash = git.rev_parse("#{base_revision}:")
66
67
  local_hash = git.tree_hash(path)
67
- remote_hash != local_hash ? git.diff_tree(remote_hash, local_hash) : ""
68
+ remote_hash != local_hash ? git.diff_tree(remote_hash, local_hash) : ''
68
69
  end
69
70
 
70
71
  def fetch
@@ -89,10 +90,10 @@ module Braid
89
90
  end
90
91
 
91
92
  def remote
92
- if (attributes["remote"] && attributes["remote"] =~ /^braid\//)
93
- attributes["remote"] = "#{branch}/#{attributes["remote"]}"
93
+ if (attributes['remote'] && attributes['remote'] =~ /^braid\//)
94
+ attributes['remote'] = "#{branch}/#{attributes['remote']}"
94
95
  else
95
- attributes["remote"]
96
+ attributes['remote']
96
97
  end
97
98
  end
98
99
 
@@ -111,8 +112,8 @@ module Braid
111
112
  end
112
113
 
113
114
  def inferred_revision
114
- local_commits = git.rev_list("HEAD", "-- #{path}").split("\n")
115
- remote_hashes = git.rev_list("--pretty=format:\"%T\"", remote).split("commit ").map do |chunk|
115
+ local_commits = git.rev_list('HEAD', "-- #{path}").split("\n")
116
+ remote_hashes = git.rev_list("--pretty=format:\"%T\"", remote).split('commit ').map do |chunk|
116
117
  chunk.split("\n", 2).map { |value| value.strip }
117
118
  end
118
119
  hash = nil
@@ -130,12 +131,9 @@ module Braid
130
131
  return nil unless url
131
132
  name = File.basename(url)
132
133
 
133
- if File.extname(name) == ".git"
134
+ if File.extname(name) == '.git'
134
135
  # strip .git
135
136
  name[0..-5]
136
- elsif name == "trunk"
137
- # use parent
138
- File.basename(File.dirname(url))
139
137
  else
140
138
  name
141
139
  end
@@ -1,5 +1,10 @@
1
1
  require 'singleton'
2
2
  require 'rubygems'
3
+ if defined?(JRUBY_VERSION) || Gem.win_platform?
4
+ require'open3'
5
+ else
6
+ require 'open4'
7
+ end
3
8
  require defined?(JRUBY_VERSION) ? 'open3' : 'open4'
4
9
  require 'tempfile'
5
10
 
@@ -103,14 +108,15 @@ module Braid
103
108
  ENV['LANG'] = 'C'
104
109
 
105
110
  out, err = nil
111
+ status, pid = 0
106
112
  log(cmd)
107
113
 
108
- if defined?(JRUBY_VERSION)
109
- Open3.popen3(cmd) do |stdin, stdout, stderr|
114
+ if defined?(JRUBY_VERSION) || Gem.win_platform?
115
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
110
116
  out = stdout.read
111
117
  err = stderr.read
118
+ status = wait_thr.value # Process::Status object returned.
112
119
  end
113
- status = $?.exitstatus
114
120
  else
115
121
  status = Open4.popen4(cmd) do |pid, stdin, stdout, stderr|
116
122
  out = stdout.read
@@ -176,7 +182,7 @@ module Braid
176
182
  def fetch(remote = nil, *args)
177
183
  args.unshift "-n #{remote}" if remote
178
184
  # open4 messes with the pipes of index-pack
179
- sh("git fetch #{args.join(' ')} 2>&1 >/dev/null")
185
+ sh("git fetch #{args.join(' ')} 2>&1 > #{Gem.win_platform? ? 'nul' : '/dev/null'}")
180
186
  end
181
187
 
182
188
  def checkout(treeish)
@@ -284,17 +290,19 @@ module Braid
284
290
  end
285
291
 
286
292
  def apply(diff, *args)
287
- err = nil
293
+ status, err = nil, nil
294
+
295
+ command = "git apply --index --whitespace=nowarn #{args.join(' ')} -"
288
296
 
289
- if defined?(JRUBY_VERSION)
290
- Open3.popen3("git apply --index --whitespace=nowarn #{args.join(' ')} -") do |stdin, stdout, stderr|
297
+ if defined?(JRUBY_VERSION) || Gem.win_platform?
298
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
291
299
  stdin.puts(diff)
292
300
  stdin.close
293
301
  err = stderr.read
302
+ status = wait_thr.value # Process::Status object returned.
294
303
  end
295
- status = $?.exitstatus
296
304
  else
297
- status = Open4.popen4("git apply --index --whitespace=nowarn #{args.join(' ')} -") do |pid, stdin, stdout, stderr|
305
+ status = Open4.popen4(command) do |pid, stdin, stdout, stderr|
298
306
  stdin.puts(diff)
299
307
  stdin.close
300
308
  err = stderr.read
data/lib/braid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Braid
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  end
data/lib/braid.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'braid/version'
2
2
 
3
3
  module Braid
4
- CONFIG_FILE = ".braids"
5
- REQUIRED_GIT_VERSION = "1.6"
4
+ CONFIG_FILE = '.braids'
5
+ REQUIRED_GIT_VERSION = '1.6'
6
6
 
7
7
  def self.verbose
8
- @verbose || false
8
+ !!@verbose
9
9
  end
10
10
 
11
11
  def self.verbose=(new_value)
@@ -13,7 +13,7 @@ module Braid
13
13
  end
14
14
 
15
15
  def self.force
16
- @force || false
16
+ !!@force
17
17
  end
18
18
 
19
19
  def self.force=(new_value)
@@ -21,11 +21,11 @@ module Braid
21
21
  end
22
22
 
23
23
  def self.use_local_cache
24
- [nil, "true", "1"].include?(ENV["BRAID_USE_LOCAL_CACHE"])
24
+ [nil, 'true', '1'].include?(ENV['BRAID_USE_LOCAL_CACHE'])
25
25
  end
26
26
 
27
27
  def self.local_cache_dir
28
- File.expand_path(ENV["BRAID_LOCAL_CACHE_DIR"] || "#{ENV["HOME"]}/.braid/cache")
28
+ File.expand_path(ENV['BRAID_LOCAL_CACHE_DIR'] || "#{ENV['HOME']}/.braid/cache")
29
29
  end
30
30
 
31
31
  class BraidError < StandardError
@@ -11,7 +11,8 @@ BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
11
11
  FIXTURE_PATH = File.join(BRAID_PATH, "spec", "fixtures")
12
12
  FileUtils.rm_rf(TMP_PATH)
13
13
  FileUtils.mkdir_p(TMP_PATH)
14
- BRAID_BIN = File.join(BRAID_PATH, "bin", "braid")
14
+
15
+ BRAID_BIN = ((defined?(JRUBY_VERSION) || Gem.win_platform?) ? 'ruby ' : '') + File.join(BRAID_PATH, 'bin', 'braid')
15
16
 
16
17
  def in_dir(dir = TMP_PATH)
17
18
  Dir.chdir(dir)
data/spec/mirror_spec.rb CHANGED
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  describe "Braid::Mirror#diff" do
16
16
  before(:each) do
17
- @mirror = build_mirror("revision" => 'a' * 40)
17
+ @mirror = build_mirror('revision' => 'a' * 40, 'url' => 'git://path')
18
18
  @mirror.stubs(:base_revision).returns(@mirror.revision) # bypass rev_parse
19
19
  end
20
20
 
@@ -25,6 +25,7 @@ describe "Braid::Mirror#diff" do
25
25
 
26
26
  it "should return an empty string when the hashes match" do
27
27
  set_hashes('b' * 40, 'b' * 40)
28
+ git.expects(:fetch)
28
29
  git.expects(:diff_tree).never
29
30
  @mirror.diff.should == ""
30
31
  end
@@ -32,6 +33,7 @@ describe "Braid::Mirror#diff" do
32
33
  it "should generate a diff when the hashes do not match" do
33
34
  set_hashes('b' * 40, 'c' * 40)
34
35
  diff = "diff --git a/path b/path\n"
36
+ git.expects(:fetch)
35
37
  git.expects(:diff_tree).with('b' * 40, 'c' * 40).returns(diff)
36
38
  @mirror.diff.should == diff
37
39
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realityforge-braid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Cristi Balan
@@ -9,11 +10,12 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-04-17 00:00:00.000000000 Z
13
+ date: 2014-04-24 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: main
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ! '>='
19
21
  - !ruby/object:Gem::Version
@@ -21,6 +23,7 @@ dependencies:
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ! '>='
26
29
  - !ruby/object:Gem::Version
@@ -28,6 +31,7 @@ dependencies:
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: open4
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
36
  - - ! '>='
33
37
  - !ruby/object:Gem::Version
@@ -35,6 +39,7 @@ dependencies:
35
39
  type: :runtime
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
44
  - - ! '>='
40
45
  - !ruby/object:Gem::Version
@@ -42,6 +47,7 @@ dependencies:
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: rspec
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
52
  - - '='
47
53
  - !ruby/object:Gem::Version
@@ -49,6 +55,7 @@ dependencies:
49
55
  type: :development
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
52
59
  requirements:
53
60
  - - '='
54
61
  - !ruby/object:Gem::Version
@@ -56,6 +63,7 @@ dependencies:
56
63
  - !ruby/object:Gem::Dependency
57
64
  name: mocha
58
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
59
67
  requirements:
60
68
  - - ! '>='
61
69
  - !ruby/object:Gem::Version
@@ -63,6 +71,7 @@ dependencies:
63
71
  type: :development
64
72
  prerelease: false
65
73
  version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
66
75
  requirements:
67
76
  - - ! '>='
68
77
  - !ruby/object:Gem::Version
@@ -111,7 +120,6 @@ files:
111
120
  - spec/test_helper.rb
112
121
  homepage: http://evil.che.lu/projects/braid
113
122
  licenses: []
114
- metadata: {}
115
123
  post_install_message:
116
124
  rdoc_options:
117
125
  - --line-numbers
@@ -122,20 +130,21 @@ rdoc_options:
122
130
  require_paths:
123
131
  - lib
124
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
125
134
  requirements:
126
135
  - - ! '>='
127
136
  - !ruby/object:Gem::Version
128
137
  version: '0'
129
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
130
140
  requirements:
131
141
  - - ! '>='
132
142
  - !ruby/object:Gem::Version
133
143
  version: '0'
134
144
  requirements: []
135
145
  rubyforge_project: braid
136
- rubygems_version: 2.0.3
146
+ rubygems_version: 1.8.23
137
147
  signing_key:
138
- specification_version: 4
148
+ specification_version: 3
139
149
  summary: A simple tool for tracking vendor branches in git.
140
150
  test_files: []
141
- has_rdoc: false
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YmEwNDIxOTcxMzU5YzI5Nzc1NTg3MGI4NDRhMDQ1Nzk5YTAyZDZiYg==
5
- data.tar.gz: !binary |-
6
- NDhiN2ZiYzE5MTM4MmRkYWNiZTMzMTAxMGRhMGFjZjM0OWY5MjBhZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- Y2Y4M2JlMGVhZDViZjk4ZmM5ODQ3OThjZmM4ODliNTNmZDAzMTRiZTI3YTFm
10
- OGY0Yjc4NTFkODNlMjA3MDU2M2Y0MmJjNjFiYTk3MzNhODE4YTg1ODlmM2Mx
11
- MzBjNzZkNWY2Mzc5NmM3MzIyZTRmZTg5YjY3YTg1MDNjZjg3MGY=
12
- data.tar.gz: !binary |-
13
- OTg3YWI1ZTZmNTFkY2Y2NWMxNTAyODQ1MjFiMWVhZDc4Mzk5NDAyZmJjYTRh
14
- MjBmOGZjMjE3OGQwYzVjMGJhYzc3NmU2OTdiMDliZjE1Mjg2MjgwMmQ2Mjg5
15
- YTNmOWU0ZDMwMWRkZDU0NTU2NGVmYWViZDMyZGVhNjEzMjgyYzU=