mlightner-braid 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.textile +120 -0
- data/Rakefile +17 -0
- data/bin/braid +249 -0
- data/braid.gemspec +25 -0
- data/lib/braid.rb +29 -0
- data/lib/braid/command.rb +131 -0
- data/lib/braid/commands/add.rb +42 -0
- data/lib/braid/commands/diff.rb +13 -0
- data/lib/braid/commands/list.rb +32 -0
- data/lib/braid/commands/remove.rb +33 -0
- data/lib/braid/commands/setup.rb +34 -0
- data/lib/braid/commands/update.rb +102 -0
- data/lib/braid/config.rb +101 -0
- data/lib/braid/mirror.rb +173 -0
- data/lib/braid/operations.rb +390 -0
- data/test/braid_test.rb +7 -0
- data/test/config_test.rb +62 -0
- data/test/fixtures/shiny/README +3 -0
- data/test/fixtures/skit1.1/layouts/layout.liquid +219 -0
- data/test/fixtures/skit1.2/layouts/layout.liquid +221 -0
- data/test/fixtures/skit1/layouts/layout.liquid +219 -0
- data/test/fixtures/skit1/preview.png +0 -0
- data/test/integration/adding_test.rb +80 -0
- data/test/integration/updating_test.rb +87 -0
- data/test/integration_helper.rb +70 -0
- data/test/mirror_test.rb +110 -0
- data/test/operations_test.rb +66 -0
- data/test/test_helper.rb +15 -0
- metadata +103 -0
data/test/mirror_test.rb
ADDED
@@ -0,0 +1,110 @@
|
|
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.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.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?" do
|
97
|
+
before(:each) do
|
98
|
+
@mirror = new_from_options("git://path")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should be true when the remote path matches the cache path" do
|
102
|
+
git.expects(:remote_url).with(@mirror.remote).returns(git_cache.path(@mirror.url))
|
103
|
+
@mirror.should.be.cached
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should be false if the remote does not point to the cache" do
|
107
|
+
git.expects(:remote_url).with(@mirror.remote).returns(@mirror.url)
|
108
|
+
@mirror.should.not.be.cached
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
describe "Braid::Operations::Git#remote_url" do
|
4
|
+
it "should use git config" do
|
5
|
+
# FIXME weak test
|
6
|
+
git.expects(:invoke).with(:config, 'remote.braid/git/one.url').returns("git://path")
|
7
|
+
git.remote_url("braid/git/one").should == "git://path"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Braid::Operations::Git#rev_parse" do
|
12
|
+
it "should return the full hash when a hash is found" do
|
13
|
+
full_revision = 'a' * 40
|
14
|
+
git.expects(:exec).returns([0, full_revision, ""])
|
15
|
+
git.rev_parse('a' * 7).should == full_revision
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should raise a revision error when the hash is not found" do
|
19
|
+
ambiguous_revision = 'b' * 7
|
20
|
+
git.expects(:exec).returns([1, ambiguous_revision, "fatal: ..."])
|
21
|
+
lambda { git.rev_parse(ambiguous_revision) }.should.raise(Braid::Operations::UnknownRevision)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "Braid::Operations::Git#version" do
|
26
|
+
ACTUAL_VERSION = "1.5.5.1.98.gf0ec4"
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
git.expects(:exec).returns([0, "git version #{ACTUAL_VERSION}\n", ""])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should extract from git --version output" do
|
33
|
+
git.version.should == ACTUAL_VERSION
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "Braid::Operations::Git#require_version" do
|
38
|
+
REQUIRED_VERSION = "1.5.4.5"
|
39
|
+
PASS_VERSIONS = %w(1.5.4.6 1.5.5 1.6 1.5.4.5.2 1.5.5.1.98.gf0ec4)
|
40
|
+
FAIL_VERSIONS = %w(1.5.4.4 1.5.4 1.5.3 1.4.5.6)
|
41
|
+
|
42
|
+
def set_version(str)
|
43
|
+
git.expects(:exec).returns([0, "git version #{str}\n", ""])
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return true for higher revisions" do
|
47
|
+
PASS_VERSIONS.each do |version|
|
48
|
+
set_version(version)
|
49
|
+
git.require_version(REQUIRED_VERSION).should == true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should return false for lower revisions" do
|
54
|
+
FAIL_VERSIONS.each do |version|
|
55
|
+
set_version(version)
|
56
|
+
git.require_version(REQUIRED_VERSION).should == false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "Braid::Operations::GitCache#path" do
|
62
|
+
it "should use the local cache directory and strip characters" do
|
63
|
+
git_cache.path("git://path").should == File.join(Braid.local_cache_dir, "git___path")
|
64
|
+
git_cache.path("git@domain:repository.git").should == File.join(Braid.local_cache_dir, "git_domain_repository.git")
|
65
|
+
end
|
66
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -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
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mlightner-braid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cristi Balan
|
8
|
+
- Norbert Crombach
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2008-10-29 00:00:00 -07:00
|
14
|
+
default_executable: braid
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: main
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.8.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: open4
|
27
|
+
version_requirement:
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.6
|
33
|
+
version:
|
34
|
+
description: A simple tool for tracking vendor branches in git.
|
35
|
+
email: evil@che.lu
|
36
|
+
executables:
|
37
|
+
- braid
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- bin/braid
|
44
|
+
- braid.gemspec
|
45
|
+
- lib/braid/command.rb
|
46
|
+
- lib/braid/commands/list.rb
|
47
|
+
- lib/braid/commands/add.rb
|
48
|
+
- lib/braid/commands/diff.rb
|
49
|
+
- lib/braid/commands/remove.rb
|
50
|
+
- lib/braid/commands/setup.rb
|
51
|
+
- lib/braid/commands/update.rb
|
52
|
+
- lib/braid/config.rb
|
53
|
+
- lib/braid/mirror.rb
|
54
|
+
- lib/braid/operations.rb
|
55
|
+
- lib/braid.rb
|
56
|
+
- LICENSE
|
57
|
+
- Rakefile
|
58
|
+
- README.textile
|
59
|
+
- test/braid_test.rb
|
60
|
+
- test/config_test.rb
|
61
|
+
- test/fixtures/shiny/README
|
62
|
+
- test/fixtures/skit1/layouts/layout.liquid
|
63
|
+
- test/fixtures/skit1/preview.png
|
64
|
+
- test/fixtures/skit1.1/layouts/layout.liquid
|
65
|
+
- test/fixtures/skit1.2/layouts/layout.liquid
|
66
|
+
- test/integration/adding_test.rb
|
67
|
+
- test/integration/updating_test.rb
|
68
|
+
- test/integration_helper.rb
|
69
|
+
- test/mirror_test.rb
|
70
|
+
- test/operations_test.rb
|
71
|
+
- test/test_helper.rb
|
72
|
+
has_rdoc: false
|
73
|
+
homepage: http://evil.che.lu/projects/braid
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options:
|
76
|
+
- --line-numbers
|
77
|
+
- --inline-source
|
78
|
+
- --title
|
79
|
+
- braid
|
80
|
+
- --main
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: "0"
|
94
|
+
version:
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project: braid
|
98
|
+
rubygems_version: 1.2.0
|
99
|
+
signing_key:
|
100
|
+
specification_version: 2
|
101
|
+
summary: A simple tool for tracking vendor branches in git.
|
102
|
+
test_files: []
|
103
|
+
|