realityforge-braid 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -10,3 +10,6 @@ nbproject
10
10
  pkg
11
11
  pkg/*
12
12
  rdoc
13
+ /*.iml
14
+ /*.ipr
15
+ /*.iws
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.8.7-p371
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Braid
2
2
 
3
- Braid is a simple tool to help track git and svn vendor branches in a git repository.
3
+ Braid is a simple tool to help track git vendor branches in a git repository.
4
4
 
5
5
  The project homepage is [here](http://github.com/evilchelu/braid/wikis/home).
6
6
 
7
7
  ## Requirements
8
8
 
9
- * git 1.6+ (and git-svn if you want to mirror svn repositories)
9
+ * git 1.6+
10
10
  * main >= 4.2.0
11
11
  * open4 >= 1.0.1 (unless using jruby)
12
12
 
data/Rakefile CHANGED
@@ -2,19 +2,8 @@ require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rake'
5
- require 'rake/testtask'
6
-
7
- task :default => :test
8
-
9
- def test_task(name, pattern)
10
- Rake::TestTask.new(name) do |t|
11
- ENV['TESTOPTS'] = '--runner=s'
12
-
13
- t.libs << 'lib'
14
- t.pattern = pattern
15
- t.verbose = true
16
- end
5
+ require 'rspec/core/rake_task'
6
+ desc 'Run all specs'
7
+ RSpec::Core::RakeTask.new :spec do |task|
8
+ task.rspec_opts = %w{--backtrace}
17
9
  end
18
-
19
- test_task(:test, "test/*_test.rb")
20
- namespace(:test) { test_task(:integration, "test/integration/*_test.rb") }
data/bin/braid CHANGED
@@ -12,7 +12,7 @@ Home = File.expand_path(ENV['HOME'] || '~')
12
12
  # main kicks ass!
13
13
  Main {
14
14
  description <<-TXT
15
- braid is a simple tool to help track git or svn repositories inside a git repository.
15
+ braid is a simple tool to help track git repositories inside a git repository.
16
16
 
17
17
  Run 'braid commandname help' for more details.
18
18
 
@@ -25,16 +25,9 @@ Main {
25
25
  Add a new mirror to be tracked.
26
26
 
27
27
  * adds metadata about the mirror to .braids
28
- * adds the git or git svn remotes to .git/config
28
+ * adds the git remotes to .git/config
29
29
  * fetches and merges remote code into given directory
30
30
 
31
- --type defaults:
32
-
33
- * svn://path # => svn
34
- * git://path # => git
35
- * http://path/trunk # => svn
36
- * http://path.git # => git
37
-
38
31
  Name defaults:
39
32
 
40
33
  * remote/path # => path
@@ -43,12 +36,8 @@ Main {
43
36
  TXT
44
37
 
45
38
  examples <<-TXT
46
- . braid add svn://remote/path
47
- . braid add svn://remote/path local/dir
48
- . braid add git://remote/path local/dir
49
39
  . braid add http://remote/path.git local/dir
50
- . braid add http://remote/path --type git local/dir
51
- . braid add svn://remote/path --branch notmaster
40
+ . braid add http://remote/path local/dir
52
41
  TXT
53
42
 
54
43
  mixin :argument_url, :option_type, :optional_path, :option_branch, :option_rails_plugin, :option_revision, :option_full, :option_verbose
@@ -134,7 +123,7 @@ Main {
134
123
 
135
124
  mode(:setup) {
136
125
  description <<-TXT
137
- Set up git and git-svn remotes.
126
+ Set up git remotes.
138
127
  TXT
139
128
 
140
129
  mixin :optional_path, :option_verbose, :option_force
data/braid.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.rubyforge_project = %q{braid}
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
22
  s.default_executable = %q{braid}
23
23
  s.require_paths = ["lib"]
@@ -28,6 +28,6 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency(%q<main>, [">= 4.7.3"])
29
29
  s.add_dependency(%q<open4>, [">= 1.0.1"]) unless defined?(JRUBY_VERSION)
30
30
 
31
- s.add_development_dependency(%q<test-spec>, [">= 0.10.0"])
31
+ s.add_development_dependency(%q<rspec>, ["= 2.12.0"])
32
32
  s.add_development_dependency(%q<mocha>, [">= 0.9.11"])
33
33
  end
data/lib/braid/command.rb CHANGED
@@ -89,48 +89,24 @@ module Braid
89
89
 
90
90
  def display_revision(mirror, revision = nil)
91
91
  revision ||= mirror.revision
92
- mirror.type == "svn" ? "r#{revision}" : "'#{revision[0, 7]}'"
92
+ "'#{revision[0, 7]}'"
93
93
  end
94
94
 
95
95
  def validate_new_revision(mirror, new_revision)
96
- unless new_revision
97
- unless mirror.type == "svn"
98
- return git.rev_parse(mirror.remote)
99
- else
100
- return svn.head_revision(mirror.url)
101
- end
102
- end
96
+ return git.rev_parse(mirror.remote) unless new_revision
103
97
 
104
- unless mirror.type == "svn"
105
- new_revision = git.rev_parse(new_revision)
106
- else
107
- new_revision = svn.clean_revision(new_revision)
108
- end
98
+ new_revision = git.rev_parse(new_revision)
109
99
  old_revision = mirror.revision
110
100
 
111
101
  if new_revision == old_revision
112
102
  raise InvalidRevision, "mirror is already at requested revision"
113
103
  end
114
104
 
115
- if mirror.type == "svn"
116
- if old_revision && new_revision < old_revision
117
- raise InvalidRevision, "local revision is higher than request revision"
118
- end
119
-
120
- if svn.head_revision(mirror.url) < new_revision
121
- raise InvalidRevision, "requested revision is higher than remote revision"
122
- end
123
- end
124
-
125
105
  new_revision
126
106
  end
127
107
 
128
108
  def determine_target_revision(mirror, new_revision)
129
- unless mirror.type == "svn"
130
- git.rev_parse(new_revision)
131
- else
132
- git_svn.commit_hash(mirror.remote, new_revision)
133
- end
109
+ git.rev_parse(new_revision)
134
110
  end
135
111
  end
136
112
  end
@@ -7,9 +7,9 @@ module Braid
7
7
  with_reset_on_error do
8
8
  mirror = config.add_from_options(url, options)
9
9
 
10
- branch_message = (mirror.type == "svn" || mirror.branch == "master") ? "" : " branch '#{mirror.branch}'"
10
+ branch_message = (mirror.branch == "master") ? "" : " branch '#{mirror.branch}'"
11
11
  revision_message = options["revision"] ? " at #{display_revision(mirror, options["revision"])}" : ""
12
- msg "Adding #{mirror.type} mirror of '#{mirror.url}'#{branch_message}#{revision_message}."
12
+ msg "Adding mirror of '#{mirror.url}'#{branch_message}#{revision_message}."
13
13
 
14
14
  # these commands are explained in the subtree merge guide
15
15
  # http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
@@ -28,12 +28,8 @@ module Braid
28
28
  end
29
29
 
30
30
  msg "Setup: Creating remote for '#{mirror.path}'."
31
- unless mirror.type == "svn"
32
- url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
33
- git.remote_add(mirror.remote, url, mirror.branch)
34
- else
35
- git_svn.init(mirror.remote, mirror.url)
36
- end
31
+ url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
32
+ git.remote_add(mirror.remote, url, mirror.branch)
37
33
  end
38
34
  end
39
35
  end
data/lib/braid/config.rb CHANGED
@@ -1,9 +1,4 @@
1
1
  require 'yaml'
2
-
3
- # psych throws such wonderful errors as:
4
- # `@vendor/rails' is not allowed as an instance variable name (NameError)
5
- YAML::ENGINE.yamler = 'syck' if RUBY_VERSION >= '1.9.1'
6
-
7
2
  require 'yaml/store'
8
3
 
9
4
  module Braid
@@ -73,9 +68,7 @@ module Braid
73
68
 
74
69
  def valid?
75
70
  @db.transaction(true) do
76
- !@db.roots.any? do |path|
77
- @db[path]["url"].nil?
78
- end
71
+ !@db.roots.any? {|path| @db[path]["url"].nil?}
79
72
  end
80
73
  end
81
74
 
data/lib/braid/mirror.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module Braid
2
2
  class Mirror
3
- TYPES = %w(git svn)
4
3
  ATTRIBUTES = %w(url remote type branch squashed revision lock)
5
4
 
6
5
  class UnknownType < BraidError
@@ -8,11 +7,6 @@ module Braid
8
7
  "unknown type: #{super}"
9
8
  end
10
9
  end
11
- class CannotGuessType < BraidError
12
- def message
13
- "cannot guess type: #{super}"
14
- end
15
- end
16
10
  class PathRequired < BraidError
17
11
  def message
18
12
  "path is required"
@@ -33,12 +27,6 @@ module Braid
33
27
 
34
28
  branch = options["branch"] || "master"
35
29
 
36
- if type = options["type"] || extract_type_from_url(url)
37
- raise UnknownType, type unless TYPES.include?(type)
38
- else
39
- raise CannotGuessType, url
40
- end
41
-
42
30
  unless path = options["path"] || extract_path_from_url(url)
43
31
  raise PathRequired
44
32
  end
@@ -47,11 +35,10 @@ module Braid
47
35
  path = "vendor/plugins/#{path}"
48
36
  end
49
37
 
50
- remote = "#{branch}/braid/#{path}".gsub("_", '-') # stupid git svn changes all _ to ., weird
38
+ remote = "#{branch}/braid/#{path}"
51
39
  squashed = !options["full"]
52
- branch = nil if type == "svn"
53
40
 
54
- attributes = {"url" => url, "remote" => remote, "type" => type, "branch" => branch, "squashed" => squashed}
41
+ attributes = {"url" => url, "remote" => remote, "branch" => branch, "squashed" => squashed}
55
42
  self.new(path, attributes)
56
43
  end
57
44
 
@@ -59,11 +46,6 @@ module Braid
59
46
  path == comparison.path && attributes == comparison.attributes
60
47
  end
61
48
 
62
- def type
63
- # override Object#type
64
- attributes["type"]
65
- end
66
-
67
49
  def locked?
68
50
  !!lock
69
51
  end
@@ -90,12 +72,8 @@ module Braid
90
72
  end
91
73
 
92
74
  def fetch
93
- unless type == "svn"
94
- git_cache.fetch(url) if cached?
95
- git.fetch(remote)
96
- else
97
- git_svn.fetch(remote)
98
- end
75
+ git_cache.fetch(url) if cached?
76
+ git.fetch(remote)
99
77
  end
100
78
 
101
79
  def cached?
@@ -104,11 +82,7 @@ module Braid
104
82
 
105
83
  def base_revision
106
84
  if revision
107
- unless type == "svn"
108
- git.rev_parse(revision)
109
- else
110
- git_svn.commit_hash(remote, revision)
111
- end
85
+ git.rev_parse(revision)
112
86
  else
113
87
  inferred_revision
114
88
  end
@@ -156,18 +130,6 @@ module Braid
156
130
  hash
157
131
  end
158
132
 
159
- def self.extract_type_from_url(url)
160
- return nil unless url
161
- url.sub!(/\/$/, '')
162
-
163
- # check for git:// and svn:// URLs
164
- url_scheme = url.split(":").first
165
- return url_scheme if TYPES.include?(url_scheme)
166
-
167
- return "svn" if url[-6..-1] == "/trunk"
168
- return "git" if url[-4..-1] == ".git"
169
- end
170
-
171
133
  def self.extract_path_from_url(url)
172
134
  return nil unless url
173
135
  name = File.basename(url)
@@ -41,7 +41,7 @@ module Braid
41
41
  end
42
42
  end
43
43
 
44
- # The command proxy is meant to encapsulate commands such as git, git-svn and svn, that work with subcommands.
44
+ # The command proxy is meant to encapsulate commands such as git, that work with subcommands.
45
45
  class Proxy
46
46
  include Singleton
47
47
 
@@ -157,6 +157,7 @@ module Braid
157
157
  message_file = Tempfile.new("braid_commit")
158
158
  message_file.print("Braid: #{message}")
159
159
  message_file.flush
160
+ message_file.close
160
161
  cmd << " -F #{message_file.path}"
161
162
  end
162
163
  cmd << " #{args.join(' ')}" unless args.empty?
@@ -207,14 +208,10 @@ module Braid
207
208
  true
208
209
  end
209
210
 
210
- # Checks git and svn remotes.
211
+ # Checks git remotes.
211
212
  def remote_url(remote)
212
213
  key = "remote.#{remote}.url"
213
- begin
214
- invoke(:config, key)
215
- rescue ShellExecutionError
216
- invoke(:config, "svn-#{key}")
217
- end
214
+ invoke(:config, key)
218
215
  rescue ShellExecutionError
219
216
  nil
220
217
  end
@@ -320,52 +317,6 @@ module Braid
320
317
  end
321
318
  end
322
319
 
323
- class GitSvn < Proxy
324
- def self.command;
325
- "git svn";
326
- end
327
-
328
- def commit_hash(remote, revision)
329
- out = invoke(:log, "--show-commit --oneline", "-r #{revision}", remote)
330
- part = out.to_s.split("|")[1]
331
- part.strip!
332
- raise UnknownRevision, "r#{revision}" unless part
333
- git.rev_parse(part)
334
- end
335
-
336
- def fetch(remote)
337
- sh("git svn fetch #{remote} 2>&1 >/dev/null")
338
- end
339
-
340
- def init(remote, path)
341
- invoke(:init, "-R", remote, "--id=#{remote}", path)
342
- true
343
- end
344
-
345
- private
346
-
347
- def command(name)
348
- "#{self.class.command} #{name}"
349
- end
350
-
351
- def git
352
- Git.instance
353
- end
354
- end
355
-
356
- class Svn < Proxy
357
- def clean_revision(revision)
358
- revision.to_i if revision
359
- end
360
-
361
- def head_revision(path)
362
- # not using svn info because it's retarded and doesn't show the actual last changed rev for the url
363
- # git svn has no clue on how to get the actual HEAD revision number on it's own
364
- status, out, err = exec!("svn log -q --limit 1 #{path}")
365
- out.split(/\n/).find { |x| x.match /^r\d+/ }.split(" | ")[0][1..-1].to_i
366
- end
367
- end
368
-
369
320
  class GitCache
370
321
  include Singleton
371
322
 
@@ -407,14 +358,6 @@ module Braid
407
358
  Git.instance
408
359
  end
409
360
 
410
- def git_svn
411
- GitSvn.instance
412
- end
413
-
414
- def svn
415
- Svn.instance
416
- end
417
-
418
361
  def git_cache
419
362
  GitCache.instance
420
363
  end
data/lib/braid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Braid
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/braid.rb CHANGED
@@ -1,4 +1,3 @@
1
- $:.unshift dirname = File.dirname(__FILE__)
2
1
  require 'braid/version'
3
2
 
4
3
  module Braid
@@ -37,12 +36,15 @@ module Braid
37
36
  end
38
37
  end
39
38
 
40
- require dirname + '/core_ext'
39
+ #require 'braid/core_ext'
41
40
  require 'braid/operations'
42
41
  require 'braid/mirror'
43
42
  require 'braid/config'
44
43
  require 'braid/command'
45
-
46
- Dir[dirname + '/braid/commands/*'].each do |file|
47
- require file
48
- end
44
+ require 'braid/commands/add'
45
+ require 'braid/commands/diff'
46
+ require 'braid/commands/list'
47
+ require 'braid/commands/push'
48
+ require 'braid/commands/remove'
49
+ require 'braid/commands/setup'
50
+ require 'braid/commands/update'
@@ -1,52 +1,49 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
- describe_shared "Braid::Config, in general" do
4
- db = "tmp.yml"
5
-
3
+ describe "Braid::Config, when empty" do
6
4
  before(:each) do
7
- @config = Braid::Config.new(db)
5
+ @config = Braid::Config.new("tmp.yml")
8
6
  end
9
7
 
10
8
  after(:each) do
11
- FileUtils.rm(db) rescue nil
9
+ FileUtils.rm("tmp.yml") rescue nil
12
10
  end
13
- end
14
-
15
- describe "Braid::Config, when empty" do
16
- it_should_behave_like "Braid::Config, in general"
17
11
 
18
12
  it "should not get a mirror by name" do
19
- @config.get("path").should.be.nil
20
- lambda { @config.get!("path") }.should.raise(Braid::Config::MirrorDoesNotExist)
13
+ @config.get("path").should be_nil
14
+ lambda { @config.get!("path") }.should raise_error(Braid::Config::MirrorDoesNotExist)
21
15
  end
22
16
 
23
17
  it "should add a mirror and its params" do
24
18
  @mirror = build_mirror
25
19
  @config.add(@mirror)
26
- @config.get("path").path.should.not.be.nil
20
+ @config.get("path").path.should_not be_nil
27
21
  end
28
22
  end
29
23
 
30
24
  describe "Braid::Config, with one mirror" do
31
- it_should_behave_like "Braid::Config, in general"
32
-
33
25
  before(:each) do
26
+ @config = Braid::Config.new("tmp.yml")
34
27
  @mirror = build_mirror
35
28
  @config.add(@mirror)
36
29
  end
37
30
 
31
+ after(:each) do
32
+ FileUtils.rm("tmp.yml") rescue nil
33
+ end
34
+
38
35
  it "should get the mirror by name" do
39
36
  @config.get("path").should == @mirror
40
37
  @config.get!("path").should == @mirror
41
38
  end
42
39
 
43
40
  it "should raise when trying to overwrite a mirror on add" do
44
- lambda { @config.add(@mirror) }.should.raise(Braid::Config::PathAlreadyInUse)
41
+ lambda { @config.add(@mirror) }.should raise_error(Braid::Config::PathAlreadyInUse)
45
42
  end
46
43
 
47
44
  it "should remove the mirror" do
48
45
  @config.remove(@mirror)
49
- @config.get("path").should.be.nil
46
+ @config.get("path").should be_nil
50
47
  end
51
48
 
52
49
  it "should update the mirror with new params" do
@@ -57,6 +54,6 @@ describe "Braid::Config, with one mirror" do
57
54
 
58
55
  it "should raise when trying to update nonexistent mirror" do
59
56
  @mirror.instance_variable_set("@path", "other")
60
- lambda { @config.update(@mirror) }.should.raise(Braid::Config::MirrorDoesNotExist)
57
+ lambda { @config.update(@mirror) }.should raise_error(Braid::Config::MirrorDoesNotExist)
61
58
  end
62
59
  end
File without changes
File without changes
File without changes
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../integration_helper'
2
+
3
+ describe "Adding a mirror in a clean repository" do
4
+
5
+ before do
6
+ FileUtils.rm_rf(TMP_PATH)
7
+ FileUtils.mkdir_p(TMP_PATH)
8
+ end
9
+
10
+ describe "from a git repository" do
11
+ before do
12
+ @shiny = create_git_repo_from_fixture("shiny")
13
+ @skit1 = create_git_repo_from_fixture("skit1")
14
+ end
15
+
16
+ it "should add the files and commit" do
17
+ in_dir(@shiny) do
18
+ `#{BRAID_BIN} add #{@skit1}`
19
+ end
20
+
21
+ file_name = "skit1/layouts/layout.liquid"
22
+ output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
23
+ $?.should be_success
24
+
25
+ output = `git log --pretty=oneline`.split("\n")
26
+ output.length.should == 2
27
+ output[0].should =~ /Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/
28
+ end
29
+
30
+ it "should create .braids and add the mirror to it" do
31
+ in_dir(@shiny) do
32
+ `#{BRAID_BIN} add #{@skit1}`
33
+ end
34
+
35
+ braids = YAML::load_file("#{@shiny}/.braids")
36
+ braids["skit1"]["squashed"].should == true
37
+ braids["skit1"]["url"].should == @skit1
38
+ braids["skit1"]["revision"].should_not be_nil
39
+ braids["skit1"]["branch"].should == "master"
40
+ braids["skit1"]["remote"].should == "master/braid/skit1"
41
+ end
42
+ end
43
+ end
@@ -13,7 +13,7 @@ describe "Updating a mirror without conflicts" do
13
13
  @skit1 = create_git_repo_from_fixture("skit1")
14
14
 
15
15
  in_dir(@shiny) do
16
- `#{BRAID_BIN} add --type git #{@skit1}`
16
+ `#{BRAID_BIN} add #{@skit1}`
17
17
  end
18
18
 
19
19
  update_dir_from_fixture("skit1", "skit1.1")
@@ -37,7 +37,7 @@ describe "Updating a mirror without conflicts" do
37
37
 
38
38
  file_name = "layouts/layout.liquid"
39
39
  output = `diff -U 3 #{File.join(FIXTURE_PATH, "skit1.2", file_name)} #{File.join(TMP_PATH, "shiny", "skit1", file_name)}`
40
- $?.should.be.success
40
+ $?.should be_success
41
41
 
42
42
  output = `git log --pretty=oneline`.split("\n")
43
43
  output.length.should == 3
@@ -45,43 +45,4 @@ describe "Updating a mirror without conflicts" do
45
45
  end
46
46
 
47
47
  end
48
-
49
- describe "from a svn repository" do
50
- before do
51
- @shiny = create_git_repo_from_fixture("shiny")
52
- @skit1 = create_svn_repo_from_fixture("skit1")
53
- @skit1_wc = File.join(TMP_PATH, "skit1_wc")
54
-
55
- in_dir(@shiny) do
56
- `#{BRAID_BIN} add --type svn #{@skit1}`
57
- end
58
-
59
- update_dir_from_fixture("skit1_wc", "skit1.1")
60
- in_dir(@skit1_wc) do
61
- `svn commit -m "change default color"`
62
- end
63
-
64
- update_dir_from_fixture("skit1_wc", "skit1.2")
65
- in_dir(@skit1_wc) do
66
- `svn commit -m "add a happy note"`
67
- end
68
-
69
- end
70
-
71
- it "should add the files and commit" do
72
- in_dir(@shiny) do
73
- `#{BRAID_BIN} update skit1`
74
- end
75
-
76
- file_name = "layouts/layout.liquid"
77
- output = `diff -U 3 #{File.join(FIXTURE_PATH, "skit1.2", file_name)} #{File.join(TMP_PATH, "shiny", "skit1", file_name)}`
78
- $?.should.be.success
79
-
80
- output = `git log --pretty=oneline`.split("\n")
81
- output.length.should == 3
82
- output[0].should =~ /Braid: Update mirror 'skit1' to r3/
83
- end
84
-
85
- end
86
-
87
48
  end
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
- require 'test/spec'
3
- require 'mocha'
2
+ require 'rspec'
3
+ require 'mocha/api'
4
4
 
5
5
  require 'tempfile'
6
6
  require 'fileutils'
@@ -8,15 +8,11 @@ require 'pathname'
8
8
 
9
9
  TMP_PATH = File.join(Dir.tmpdir, "braid_integration")
10
10
  BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
11
- FIXTURE_PATH = File.join(BRAID_PATH, "test", "fixtures")
11
+ FIXTURE_PATH = File.join(BRAID_PATH, "spec", "fixtures")
12
12
  FileUtils.rm_rf(TMP_PATH)
13
13
  FileUtils.mkdir_p(TMP_PATH)
14
14
  BRAID_BIN = File.join(BRAID_PATH, "bin", "braid")
15
15
 
16
- #def exec(cmd)
17
- # `cd #{TMP} && #{cmd}`
18
- #end
19
-
20
16
  def in_dir(dir = TMP_PATH)
21
17
  Dir.chdir(dir)
22
18
  yield
@@ -49,22 +45,3 @@ def create_git_repo_from_fixture(fixture_name)
49
45
 
50
46
  git_repo
51
47
  end
52
-
53
- def create_svn_repo_from_fixture(fixture_name)
54
- svn_wc = File.join(TMP_PATH, fixture_name + "_wc")
55
- svn_repo = File.join(TMP_PATH, fixture_name)
56
- run_cmds(<<-EOD)
57
- svnadmin create #{svn_repo}
58
- svn co file://#{svn_repo} #{svn_wc}
59
- EOD
60
- update_dir_from_fixture(fixture_name + "_wc", fixture_name)
61
- in_dir(svn_wc) do
62
- run_cmds(<<-EOD)
63
- svn add *
64
- svn commit -m "initial commit of #{fixture_name}"
65
- EOD
66
- end
67
- "file://#{svn_repo}"
68
- end
69
-
70
-
@@ -6,35 +6,6 @@ describe "Braid::Mirror.new_from_options" do
6
6
  @mirror.branch.should == "master"
7
7
  end
8
8
 
9
- it "should default type to git, from protocol" do
10
- new_from_options("git://path")
11
- @mirror.type.should == "git"
12
- end
13
-
14
- it "should default type to git, if path ends in .git" do
15
- new_from_options("http://path.git")
16
- @mirror.type.should == "git"
17
- end
18
-
19
- it "should default type to svn, from protocol" do
20
- new_from_options("svn://path")
21
- @mirror.type.should == "svn"
22
- end
23
-
24
- it "should default type to svn, if path ends in /trunk" do
25
- new_from_options("http://path/trunk")
26
- @mirror.type.should == "svn"
27
- end
28
-
29
- it "should raise if no type can be guessed" do
30
- lambda { new_from_options("http://path") }.should.raise(Braid::Mirror::CannotGuessType)
31
- end
32
-
33
- it "should default mirror to previous to last path part, if last path part is /trunk" do
34
- new_from_options("http://path/trunk")
35
- @mirror.path.should == "path"
36
- end
37
-
38
9
  it "should default mirror to last path part, ignoring trailing .git" do
39
10
  new_from_options("http://path.git")
40
11
  @mirror.path.should == "path"
@@ -69,7 +40,7 @@ end
69
40
  describe "Braid::Mirror#base_revision" do
70
41
  it "should be inferred when no revision is set" do
71
42
  @mirror = build_mirror
72
- @mirror.revision.should.be.nil
43
+ @mirror.revision.should be_nil
73
44
  @mirror.expects(:inferred_revision).returns('b' * 40)
74
45
  @mirror.base_revision.should == 'b' * 40
75
46
  end
@@ -100,11 +71,11 @@ describe "Braid::Mirror#cached?" do
100
71
 
101
72
  it "should be true when the remote path matches the cache path" do
102
73
  git.expects(:remote_url).with(@mirror.remote).returns(git_cache.path(@mirror.url))
103
- @mirror.should.be.cached
74
+ @mirror.should be_cached
104
75
  end
105
76
 
106
77
  it "should be false if the remote does not point to the cache" do
107
78
  git.expects(:remote_url).with(@mirror.remote).returns(@mirror.url)
108
- @mirror.should.not.be.cached
79
+ @mirror.should_not be_cached
109
80
  end
110
81
  end
@@ -18,7 +18,7 @@ describe "Braid::Operations::Git#rev_parse" do
18
18
  it "should raise a revision error when the hash is not found" do
19
19
  ambiguous_revision = 'b' * 7
20
20
  git.expects(:exec).returns([1, ambiguous_revision, "fatal: ..."])
21
- lambda { git.rev_parse(ambiguous_revision) }.should.raise(Braid::Operations::UnknownRevision)
21
+ lambda { git.rev_parse(ambiguous_revision) }.should raise_error(Braid::Operations::UnknownRevision)
22
22
  end
23
23
  end
24
24
 
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
- require 'test/spec'
3
- require 'mocha'
2
+ require 'rspec'
3
+ require 'mocha/api'
4
4
 
5
5
  require File.dirname(__FILE__) + '/../lib/braid'
6
6
 
metadata CHANGED
@@ -1,89 +1,99 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: realityforge-braid
3
- version: !ruby/object:Gem::Version
4
- version: 0.7.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 63
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 8
9
+ - 0
10
+ version: 0.8.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Cristi Balan
9
14
  - Norbert Crombach
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2013-01-02 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2013-02-11 00:00:00 +11:00
20
+ default_executable: braid
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
16
23
  name: main
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: 4.7.3
23
- type: :runtime
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 37
31
+ segments:
32
+ - 4
33
+ - 7
34
+ - 3
30
35
  version: 4.7.3
31
- - !ruby/object:Gem::Dependency
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
32
39
  name: open4
33
- requirement: !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
34
42
  none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 21
47
+ segments:
48
+ - 1
49
+ - 0
50
+ - 1
38
51
  version: 1.0.1
39
52
  type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
40
56
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: 1.0.1
47
- - !ruby/object:Gem::Dependency
48
- name: test-spec
49
- requirement: !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
50
58
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: 0.10.0
59
+ requirements:
60
+ - - "="
61
+ - !ruby/object:Gem::Version
62
+ hash: 63
63
+ segments:
64
+ - 2
65
+ - 12
66
+ - 0
67
+ version: 2.12.0
55
68
  type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: 0.10.0
63
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
64
71
  name: mocha
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: 0.9.11
71
- type: :development
72
72
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
74
  none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 45
79
+ segments:
80
+ - 0
81
+ - 9
82
+ - 11
78
83
  version: 0.9.11
84
+ type: :development
85
+ version_requirements: *id004
79
86
  description: A simple tool for tracking vendor branches in git.
80
87
  email: evil@che.lu
81
- executables:
88
+ executables:
82
89
  - braid
83
90
  extensions: []
91
+
84
92
  extra_rdoc_files: []
85
- files:
93
+
94
+ files:
86
95
  - .gitignore
96
+ - .ruby-version
87
97
  - Gemfile
88
98
  - LICENSE
89
99
  - README.md
@@ -103,53 +113,55 @@ files:
103
113
  - lib/braid/mirror.rb
104
114
  - lib/braid/operations.rb
105
115
  - lib/braid/version.rb
106
- - lib/core_ext.rb
107
- - test/braid_test.rb
108
- - test/config_test.rb
109
- - test/fixtures/shiny/README
110
- - test/fixtures/skit1.1/layouts/layout.liquid
111
- - test/fixtures/skit1.2/layouts/layout.liquid
112
- - test/fixtures/skit1/layouts/layout.liquid
113
- - test/fixtures/skit1/preview.png
114
- - test/integration/adding_test.rb
115
- - test/integration/updating_test.rb
116
- - test/integration_helper.rb
117
- - test/mirror_test.rb
118
- - test/operations_test.rb
119
- - test/test_helper.rb
116
+ - spec/config_spec.rb
117
+ - spec/fixtures/shiny/README
118
+ - spec/fixtures/skit1.1/layouts/layout.liquid
119
+ - spec/fixtures/skit1.2/layouts/layout.liquid
120
+ - spec/fixtures/skit1/layouts/layout.liquid
121
+ - spec/fixtures/skit1/preview.png
122
+ - spec/integration/adding_spec.rb
123
+ - spec/integration/updating_spec.rb
124
+ - spec/integration_helper.rb
125
+ - spec/mirror_spec.rb
126
+ - spec/operations_spec.rb
127
+ - spec/test_helper.rb
128
+ has_rdoc: true
120
129
  homepage: http://evil.che.lu/projects/braid
121
130
  licenses: []
131
+
122
132
  post_install_message:
123
- rdoc_options:
133
+ rdoc_options:
124
134
  - --line-numbers
125
135
  - --inline-source
126
136
  - --title
127
137
  - braid
128
138
  - --main
129
- require_paths:
139
+ require_paths:
130
140
  - lib
131
- required_ruby_version: !ruby/object:Gem::Requirement
141
+ required_ruby_version: !ruby/object:Gem::Requirement
132
142
  none: false
133
- requirements:
134
- - - ! '>='
135
- - !ruby/object:Gem::Version
136
- version: '0'
137
- segments:
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
138
148
  - 0
139
- hash: 4601304509761184650
140
- required_rubygems_version: !ruby/object:Gem::Requirement
149
+ version: "0"
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
151
  none: false
142
- requirements:
143
- - - ! '>='
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- segments:
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
147
157
  - 0
148
- hash: 4601304509761184650
158
+ version: "0"
149
159
  requirements: []
160
+
150
161
  rubyforge_project: braid
151
- rubygems_version: 1.8.23
162
+ rubygems_version: 1.6.2
152
163
  signing_key:
153
164
  specification_version: 3
154
165
  summary: A simple tool for tracking vendor branches in git.
155
166
  test_files: []
167
+
data/lib/core_ext.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'yaml'
2
-
3
- class Hash
4
- def to_yaml(opts = {})
5
- YAML::quick_emit(object_id, opts) do |out|
6
- out.map(taguri, to_yaml_style) do |map|
7
- sort.each do |k, v|
8
- map.add(k, v)
9
- end
10
- end
11
- end
12
- end
13
- end
data/test/braid_test.rb DELETED
@@ -1,7 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- describe "Braid" do
4
- it "puts the lotion in the basket" do
5
- # dedicated to dblack
6
- end
7
- end
@@ -1,80 +0,0 @@
1
- require File.dirname(__FILE__) + '/../integration_helper'
2
-
3
- describe "Adding a mirror in a clean repository" do
4
-
5
- before do
6
- FileUtils.rm_rf(TMP_PATH)
7
- FileUtils.mkdir_p(TMP_PATH)
8
- end
9
-
10
- describe "from a git repository" do
11
- before do
12
- @shiny = create_git_repo_from_fixture("shiny")
13
- @skit1 = create_git_repo_from_fixture("skit1")
14
- end
15
-
16
- it "should add the files and commit" do
17
- in_dir(@shiny) do
18
- `#{BRAID_BIN} add --type git #{@skit1}`
19
- end
20
-
21
- file_name = "skit1/layouts/layout.liquid"
22
- output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
23
- $?.should.be.success
24
-
25
- output = `git log --pretty=oneline`.split("\n")
26
- output.length.should == 2
27
- output[0].should =~ /Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/
28
- end
29
-
30
- it "should create .braids and add the mirror to it" do
31
- in_dir(@shiny) do
32
- `#{BRAID_BIN} add --type git #{@skit1}`
33
- end
34
-
35
- braids = YAML::load_file("#{@shiny}/.braids")
36
- braids["skit1"]["squashed"].should == true
37
- braids["skit1"]["url"].should == @skit1
38
- braids["skit1"]["type"].should == "git"
39
- braids["skit1"]["revision"].should.not.be nil
40
- braids["skit1"]["branch"].should == "master"
41
- braids["skit1"]["remote"].should == "braid/skit1"
42
- end
43
- end
44
-
45
- describe "from an svn repository" do
46
- before do
47
- @shiny = create_git_repo_from_fixture("shiny")
48
- @skit1 = create_svn_repo_from_fixture("skit1")
49
- end
50
-
51
- it "should add the files and commit" do
52
- in_dir(@shiny) do
53
- `#{BRAID_BIN} add --type svn #{@skit1}`
54
- end
55
-
56
- file_name = "skit1/layouts/layout.liquid"
57
- output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
58
- $?.should.be.success
59
-
60
- output = `git log --pretty=oneline`.split("\n")
61
- output.length.should == 2
62
- output[0].should =~ /Braid: Add mirror 'skit1' at r1/
63
- end
64
-
65
- it "should create .braids and add the mirror to it" do
66
- in_dir(@shiny) do
67
- `#{BRAID_BIN} add --type svn #{@skit1}`
68
- end
69
-
70
- braids = YAML::load_file("#{@shiny}/.braids")
71
- braids["skit1"]["squashed"].should == true
72
- braids["skit1"]["url"].should == @skit1
73
- braids["skit1"]["type"].should == "svn"
74
- braids["skit1"]["revision"].should == 1
75
- braids["skit1"]["remote"].should == "braid/skit1"
76
- braids["skit1"]["branch"].should.be == nil
77
- end
78
- end
79
-
80
- end