evilchelu-braid 0.4.0 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/{License.txt → LICENSE} +1 -1
  2. data/README.rdoc +27 -0
  3. data/Rakefile +17 -4
  4. data/bin/braid +29 -24
  5. data/braid.gemspec +7 -7
  6. data/lib/braid.rb +15 -18
  7. data/lib/braid/command.rb +94 -44
  8. data/lib/braid/commands/add.rb +20 -31
  9. data/lib/braid/commands/diff.rb +4 -3
  10. data/lib/braid/commands/remove.rb +8 -12
  11. data/lib/braid/commands/setup.rb +13 -18
  12. data/lib/braid/commands/update.rb +47 -48
  13. data/lib/braid/config.rb +54 -101
  14. data/lib/braid/mirror.rb +181 -0
  15. data/lib/braid/operations.rb +229 -204
  16. data/{spec/braid_spec.rb → test/braid_test.rb} +1 -1
  17. data/test/config_test.rb +62 -0
  18. data/test/fixtures/shiny/README +3 -0
  19. data/test/fixtures/skit1.1/layouts/layout.liquid +219 -0
  20. data/test/fixtures/skit1.2/layouts/layout.liquid +221 -0
  21. data/test/fixtures/skit1/layouts/layout.liquid +219 -0
  22. data/test/fixtures/skit1/preview.png +0 -0
  23. data/test/integration/adding_test.rb +80 -0
  24. data/test/integration/updating_test.rb +87 -0
  25. data/test/integration_helper.rb +69 -0
  26. data/test/mirror_test.rb +118 -0
  27. data/test/operations_test.rb +74 -0
  28. data/test/test_helper.rb +15 -0
  29. metadata +30 -33
  30. data/History.txt +0 -4
  31. data/Manifest.txt +0 -32
  32. data/README.txt +0 -53
  33. data/config/hoe.rb +0 -68
  34. data/config/requirements.rb +0 -17
  35. data/lib/braid/exceptions.rb +0 -33
  36. data/lib/braid/version.rb +0 -9
  37. data/script/destroy +0 -14
  38. data/script/generate +0 -14
  39. data/setup.rb +0 -1585
  40. data/spec/config_spec.rb +0 -117
  41. data/spec/operations_spec.rb +0 -48
  42. data/spec/spec.opts +0 -3
  43. data/spec/spec_helper.rb +0 -11
  44. data/tasks/deployment.rake +0 -27
  45. data/tasks/environment.rake +0 -7
  46. data/tasks/rspec.rake +0 -32
  47. data/tasks/website.rake +0 -9
@@ -0,0 +1,118 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ describe "Braid::Mirror.new_from_options" do
4
+ it "should default branch to master" do
5
+ new_from_options("git://path")
6
+ @mirror.branch.should == "master"
7
+ end
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
+ it "should default mirror to last path part, ignoring trailing .git" do
39
+ new_from_options("http://path.git")
40
+ @mirror.path.should == "path"
41
+ end
42
+ end
43
+
44
+ describe "Braid::Mirror#diff" do
45
+ before(:each) do
46
+ @mirror = build_mirror("revision" => 'a' * 40)
47
+ @mirror.stubs(:base_revision).returns(@mirror.revision) # bypass rev_parse
48
+ end
49
+
50
+ def set_hashes(remote_hash, local_hash)
51
+ git.expects(:rev_parse).with("#{@mirror.revision}:").returns(remote_hash)
52
+ git.expects(:tree_hash).with(@mirror.path).returns(local_hash)
53
+ end
54
+
55
+ it "should return an empty string when the hashes match" do
56
+ set_hashes('b' * 40, 'b' * 40)
57
+ git.expects(:diff_tree).never
58
+ @mirror.diff.should == ""
59
+ end
60
+
61
+ it "should generate a diff when the hashes do not match" do
62
+ set_hashes('b' * 40, 'c' * 40)
63
+ diff = "diff --git a/path b/path\n"
64
+ git.expects(:diff_tree).with('b' * 40, 'c' * 40, @mirror.path).returns(diff)
65
+ @mirror.diff.should == diff
66
+ end
67
+ end
68
+
69
+ describe "Braid::Mirror#base_revision" do
70
+ it "should be inferred when no revision is set" do
71
+ @mirror = build_mirror
72
+ @mirror.revision.should.be.nil
73
+ @mirror.expects(:inferred_revision).returns('b' * 40)
74
+ @mirror.send(:base_revision).should == 'b' * 40
75
+ end
76
+
77
+ it "should be the parsed hash for git mirrors" do
78
+ @mirror = build_mirror("revision" => 'a' * 7)
79
+ git.expects(:rev_parse).with('a' * 7).returns('a' * 40)
80
+ @mirror.send(:base_revision).should == 'a' * 40
81
+ end
82
+ end
83
+
84
+ describe "Braid::Mirror#inferred_revision" do
85
+ it "should return the last commit before the most recent update" do
86
+ @mirror = new_from_options("git://path")
87
+ git.expects(:rev_list).times(2).returns(
88
+ "#{'a' * 40}\n",
89
+ "commit #{'b' * 40}\n#{'t' * 40}\n"
90
+ )
91
+ git.expects(:tree_hash).with(@mirror.path, 'a' * 40).returns('t' * 40)
92
+ @mirror.send(:inferred_revision).should == 'b' * 40
93
+ end
94
+ end
95
+
96
+ describe "Braid::Mirror#cached_url" do
97
+ it "should return a valid local cache name" do
98
+ @mirror = new_from_options("git://remoteurl/path/to/repo.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"
106
+ end
107
+ end
108
+
109
+ describe "Braid::Mirror#init_or_fetch_local_cache" do
110
+ it "should " do
111
+ @mirror = new_from_options("git@remoteurl/path/to/repo.git")
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
114
+ end
115
+
116
+ end
117
+
118
+
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ describe "Braid::Operations::Git#remote_exists?" do
4
+ before(:each) do
5
+ File.expects(:readlines).returns(["[remote \"braid/git/one\"]\n", "[svn-remote \"braid/git/two\"]\n"])
6
+ end
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
18
+ end
19
+ end
20
+
21
+ describe "Braid::Operations::Git#rev_parse" do
22
+ it "should return the full hash when a hash is found" do
23
+ full_revision = 'a' * 40
24
+ git.expects(:exec).returns([0, full_revision, ""])
25
+ git.rev_parse('a' * 7).should == full_revision
26
+ end
27
+
28
+ it "should raise a revision error when the hash is not found" do
29
+ ambiguous_revision = 'b' * 7
30
+ git.expects(:exec).returns([1, ambiguous_revision, "fatal: ..."])
31
+ lambda { git.rev_parse(ambiguous_revision) }.should.raise(Braid::Operations::UnknownRevision)
32
+ end
33
+ end
34
+
35
+ describe "Braid::Operations::Git#version" do
36
+ ACTUAL_VERSION = "1.5.5.1.98.gf0ec4"
37
+
38
+ before(:each) do
39
+ git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", ""])
40
+ end
41
+
42
+ it "should extract from git --version output" do
43
+ git.version.should == ACTUAL_VERSION
44
+ end
45
+ end
46
+
47
+ describe "Braid::Operations::Git#require_version" do
48
+ REQUIRED_VERSION = "1.5.4.5"
49
+ PASS_VERSIONS = %w(1.5.4.6 1.5.5 1.6 1.5.4.5.2 1.5.5.1.98.gf0ec4)
50
+ FAIL_VERSIONS = %w(1.5.4.4 1.5.4 1.5.3 1.4.5.6)
51
+
52
+ def set_version(str)
53
+ git.expects(:exec).returns([0, "git version #{str}\n", ""])
54
+ end
55
+
56
+ it "should return true for higher revisions" do
57
+ PASS_VERSIONS.each do |version|
58
+ set_version(version)
59
+ git.require_version(REQUIRED_VERSION).should == true
60
+ end
61
+ end
62
+
63
+ it "should return false for lower revisions" do
64
+ FAIL_VERSIONS.each do |version|
65
+ set_version(version)
66
+ git.require_version(REQUIRED_VERSION).should == false
67
+ end
68
+ end
69
+ end
70
+
71
+ describe "Braid::Operations::GitCache#init_or_fetch" do
72
+ it "should initialize or fetch a local clone of the given url in the given directory" do
73
+ end
74
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'test/spec'
3
+ require 'mocha'
4
+
5
+ require File.dirname(__FILE__) + '/../lib/braid'
6
+
7
+ def new_from_options(url, options = {})
8
+ @mirror = Braid::Mirror.new_from_options(url, options)
9
+ end
10
+
11
+ def build_mirror(options = {})
12
+ Braid::Mirror.new("path", options)
13
+ end
14
+
15
+ include Braid::Operations::VersionControl
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.0
4
+ version: 0.4.10
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-05-01 00:00:00 -07:00
13
+ date: 2008-09-23 00:00:00 -07:00
14
14
  default_executable: braid
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -31,27 +31,17 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.9.6
33
33
  version:
34
- description: Braid is a simple tool to help track git and svn vendor branches in a git repository
34
+ description: A simple tool for tracking vendor branches in git.
35
35
  email: evil@che.lu
36
36
  executables:
37
37
  - braid
38
38
  extensions: []
39
39
 
40
40
  extra_rdoc_files:
41
- - History.txt
42
- - License.txt
43
- - Manifest.txt
44
- - README.txt
41
+ - README.rdoc
45
42
  files:
46
- - History.txt
47
- - License.txt
48
- - Manifest.txt
49
- - README.txt
50
- - Rakefile
51
43
  - bin/braid
52
- - config/hoe.rb
53
- - config/requirements.rb
54
- - lib/braid.rb
44
+ - braid.gemspec
55
45
  - lib/braid/command.rb
56
46
  - lib/braid/commands/add.rb
57
47
  - lib/braid/commands/diff.rb
@@ -59,28 +49,35 @@ files:
59
49
  - lib/braid/commands/setup.rb
60
50
  - lib/braid/commands/update.rb
61
51
  - lib/braid/config.rb
62
- - lib/braid/exceptions.rb
52
+ - lib/braid/mirror.rb
63
53
  - lib/braid/operations.rb
64
- - lib/braid/version.rb
65
- - braid.gemspec
66
- - script/destroy
67
- - script/generate
68
- - setup.rb
69
- - spec/braid_spec.rb
70
- - spec/config_spec.rb
71
- - spec/operations_spec.rb
72
- - spec/spec.opts
73
- - spec/spec_helper.rb
74
- - tasks/deployment.rake
75
- - tasks/environment.rake
76
- - tasks/rspec.rake
77
- - tasks/website.rake
54
+ - lib/braid.rb
55
+ - LICENSE
56
+ - Rakefile
57
+ - README.rdoc
58
+ - test/braid_test.rb
59
+ - test/config_test.rb
60
+ - test/fixtures/shiny/README
61
+ - test/fixtures/skit1/layouts/layout.liquid
62
+ - test/fixtures/skit1/preview.png
63
+ - test/fixtures/skit1.1/layouts/layout.liquid
64
+ - test/fixtures/skit1.2/layouts/layout.liquid
65
+ - test/integration/adding_test.rb
66
+ - test/integration/updating_test.rb
67
+ - test/integration_helper.rb
68
+ - test/mirror_test.rb
69
+ - test/operations_test.rb
70
+ - test/test_helper.rb
78
71
  has_rdoc: true
79
72
  homepage: http://evil.che.lu/projects/braid
80
73
  post_install_message:
81
74
  rdoc_options:
75
+ - --line-numbers
76
+ - --inline-source
77
+ - --title
78
+ - braid
82
79
  - --main
83
- - README.txt
80
+ - README.rdoc
84
81
  require_paths:
85
82
  - lib
86
83
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -98,9 +95,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
95
  requirements: []
99
96
 
100
97
  rubyforge_project: braid
101
- rubygems_version: 1.0.1
98
+ rubygems_version: 1.2.0
102
99
  signing_key:
103
100
  specification_version: 2
104
- summary: Braid is a simple tool to help track git and svn vendor branches in a git repository
101
+ summary: A simple tool for tracking vendor branches in git.
105
102
  test_files: []
106
103
 
@@ -1,4 +0,0 @@
1
- == 0.1.0 2007-08-23
2
-
3
- * 1 major enhancement:
4
- * Initial release
@@ -1,32 +0,0 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- bin/braid
7
- config/hoe.rb
8
- config/requirements.rb
9
- lib/braid.rb
10
- lib/braid/command.rb
11
- lib/braid/commands/add.rb
12
- lib/braid/commands/diff.rb
13
- lib/braid/commands/remove.rb
14
- lib/braid/commands/setup.rb
15
- lib/braid/commands/update.rb
16
- lib/braid/config.rb
17
- lib/braid/exceptions.rb
18
- lib/braid/operations.rb
19
- lib/braid/version.rb
20
- braid.gemspec
21
- script/destroy
22
- script/generate
23
- setup.rb
24
- spec/braid_spec.rb
25
- spec/config_spec.rb
26
- spec/operations_spec.rb
27
- spec/spec.opts
28
- spec/spec_helper.rb
29
- tasks/deployment.rake
30
- tasks/environment.rake
31
- tasks/rspec.rake
32
- tasks/website.rake
data/README.txt DELETED
@@ -1,53 +0,0 @@
1
- = Braid
2
-
3
- http://evil.che.lu/projects/braid/
4
-
5
- == Description
6
-
7
- Braid is a simple tool to help track git and svn vendor branches in a git
8
- repository.
9
-
10
- In purpose, it's similar to piston, but it's especially built on top of git
11
- commands. This allows better integration with git and easier management of
12
- merges.
13
-
14
- Braid is "hosted on github":http://github.com/evilchelu/braid.
15
-
16
- *NOTE:* You will need at least git 1.5.4.5+ to run braid. You'll also need the
17
- open4 and main gems.
18
-
19
- == Install with rubygems
20
-
21
- gem sources -a http://gems.github.com/ # only need to do this once
22
- gem install evilchelu-braid
23
-
24
- == Install from the git repository
25
-
26
- Get a clone of the git repository using:
27
-
28
- git clone git://github.com/evilchelu/braid.git
29
- cd braid
30
- rake install_gem
31
- braid --help # see usage
32
-
33
- === Usage
34
-
35
- braid help
36
- braid help COMMANDNAME
37
-
38
- For more usage examples, documentation, feature requests and bug reporting,
39
- check out the "braid wiki":http://github.com/evilchelu/braid/wikis.
40
-
41
- === Contributing
42
-
43
- If you want to send a patch in, please fork the project on github, commit your
44
- changes and send a pull request.
45
-
46
- === Mad props
47
-
48
- Braid used to be quite lame before "Norbert Crombach":http://primetheory.org/
49
- ("github":http://github.com/norbert) resuscitated it by contribuing a bunch of
50
- code.
51
-
52
- He rocks! Go buy him a beer.
53
-
@@ -1,68 +0,0 @@
1
- require 'braid/version'
2
-
3
- AUTHOR = ["Cristi Balan", "Norbert Crombach"]
4
- EMAIL = "evil@che.lu"
5
- DESCRIPTION = "Braid is a simple tool to help track git and svn vendor branches in a git repository"
6
- GEM_NAME = 'braid' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'braid' # The unix name for your project
8
- HOMEPATH = "http://evil.che.lu/projects/braid"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
-
11
- @config_file = "~/.rubyforge/user-config.yml"
12
- @config = nil
13
- RUBYFORGE_USERNAME = "unknown"
14
- def rubyforge_username
15
- unless @config
16
- begin
17
- @config = YAML.load(File.read(File.expand_path(@config_file)))
18
- rescue
19
- puts <<-EOS
20
- ERROR: No rubyforge config file found: #{@config_file}"
21
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
- - See http://newgem.rubyforge.org/rubyforge.html for more details
23
- EOS
24
- exit
25
- end
26
- end
27
- RUBYFORGE_USERNAME.replace @config["username"]
28
- end
29
-
30
-
31
- REV = nil
32
- VERS = Braid::VERSION::STRING + (REV ? ".#{REV}" : "")
33
- RDOC_OPTS = ['--quiet', '--title', 'braid documentation',
34
- "--opname", "index.html",
35
- "--line-numbers",
36
- "--main", "README",
37
- "--inline-source"]
38
-
39
- class Hoe
40
- def extra_deps
41
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
42
- @extra_deps
43
- end
44
- end
45
-
46
- # Generate all the Rake tasks
47
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
48
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
49
- p.author = AUTHOR
50
- p.description = DESCRIPTION
51
- p.email = EMAIL
52
- p.summary = DESCRIPTION
53
- p.url = HOMEPATH
54
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
55
- p.test_globs = ["test/**/test_*.rb"]
56
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
57
-
58
- # == Optional
59
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
60
- p.extra_deps = [ ['main', '>=2.8.0'], ['open4', '>=0.9.6'] ]
61
-
62
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
63
-
64
- end
65
-
66
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
67
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
68
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')