jeremylightsmith-piston 1.9.3
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/.gitignore +6 -0
- data/History.txt +6 -0
- data/License.txt +20 -0
- data/Manifest.txt +86 -0
- data/README.txt +136 -0
- data/Rakefile +4 -0
- data/bin/piston +5 -0
- data/config/hoe.rb +76 -0
- data/config/requirements.rb +18 -0
- data/lib/piston.rb +18 -0
- data/lib/piston/cli.rb +279 -0
- data/lib/piston/commands.rb +4 -0
- data/lib/piston/commands/base.rb +44 -0
- data/lib/piston/commands/import.rb +69 -0
- data/lib/piston/commands/info.rb +14 -0
- data/lib/piston/commands/lock_unlock.rb +21 -0
- data/lib/piston/commands/update.rb +28 -0
- data/lib/piston/git.rb +12 -0
- data/lib/piston/git/client.rb +77 -0
- data/lib/piston/git/commit.rb +70 -0
- data/lib/piston/git/repository.rb +63 -0
- data/lib/piston/git/working_copy.rb +63 -0
- data/lib/piston/repository.rb +57 -0
- data/lib/piston/revision.rb +48 -0
- data/lib/piston/svn.rb +14 -0
- data/lib/piston/svn/client.rb +88 -0
- data/lib/piston/svn/repository.rb +67 -0
- data/lib/piston/svn/revision.rb +74 -0
- data/lib/piston/svn/working_copy.rb +55 -0
- data/lib/piston/version.rb +9 -0
- data/lib/piston/working_copy.rb +129 -0
- data/lib/subclass_responsibility_error.rb +2 -0
- data/log/.gitignore +0 -0
- data/samples/common.rb +19 -0
- data/samples/import_git_git.rb +39 -0
- data/samples/import_git_svn.rb +36 -0
- data/samples/import_svn_git.rb +29 -0
- data/samples/import_svn_svn.rb +24 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +40 -0
- data/tasks/environment.rake +7 -0
- data/tasks/samples.rake +6 -0
- data/tasks/test.rake +30 -0
- data/tasks/website.rake +17 -0
- data/test/integration/test_import_git_git.rb +96 -0
- data/test/integration/test_import_git_svn.rb +131 -0
- data/test/integration/test_import_svn_git.rb +52 -0
- data/test/integration/test_import_svn_svn.rb +43 -0
- data/test/integration_helpers.rb +33 -0
- data/test/test_helper.rb +56 -0
- data/test/unit/git/commit/test_checkout.rb +30 -0
- data/test/unit/git/commit/test_each.rb +36 -0
- data/test/unit/git/commit/test_rememberance.rb +20 -0
- data/test/unit/git/commit/test_validation.rb +33 -0
- data/test/unit/git/repository/test_at.rb +22 -0
- data/test/unit/git/repository/test_basename.rb +12 -0
- data/test/unit/git/repository/test_branchanme.rb +15 -0
- data/test/unit/git/repository/test_guessing.rb +32 -0
- data/test/unit/git/working_copy/test_copying.rb +28 -0
- data/test/unit/git/working_copy/test_creation.rb +26 -0
- data/test/unit/git/working_copy/test_existence.rb +21 -0
- data/test/unit/git/working_copy/test_finalization.rb +18 -0
- data/test/unit/git/working_copy/test_guessing.rb +34 -0
- data/test/unit/git/working_copy/test_rememberance.rb +25 -0
- data/test/unit/svn/repository/test_at.rb +18 -0
- data/test/unit/svn/repository/test_basename.rb +24 -0
- data/test/unit/svn/repository/test_guessing.rb +45 -0
- data/test/unit/svn/revision/test_checkout.rb +27 -0
- data/test/unit/svn/revision/test_each.rb +21 -0
- data/test/unit/svn/revision/test_rememberance.rb +42 -0
- data/test/unit/svn/revision/test_validation.rb +49 -0
- data/test/unit/svn/working_copy/test_copying.rb +29 -0
- data/test/unit/svn/working_copy/test_creation.rb +19 -0
- data/test/unit/svn/working_copy/test_existence.rb +26 -0
- data/test/unit/svn/working_copy/test_finalization.rb +21 -0
- data/test/unit/svn/working_copy/test_guessing.rb +17 -0
- data/test/unit/svn/working_copy/test_rememberance.rb +26 -0
- data/test/unit/test_import.rb +13 -0
- data/test/unit/test_info.rb +36 -0
- data/test/unit/test_lock_unlock.rb +46 -0
- data/test/unit/test_repository.rb +50 -0
- data/test/unit/test_revision.rb +30 -0
- data/test/unit/working_copy/test_guessing.rb +34 -0
- data/test/unit/working_copy/test_info.rb +13 -0
- data/test/unit/working_copy/test_rememberance.rb +48 -0
- data/test/unit/working_copy/test_validate.rb +68 -0
- data/website/index.html +11 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +228 -0
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
require "rubygems"
|
|
3
|
+
require "mocha"
|
|
4
|
+
require "log4r"
|
|
5
|
+
require "fileutils"
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
require "turn"
|
|
9
|
+
rescue LoadError
|
|
10
|
+
# NOP: ignore, this is not a real dependency
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require File.dirname(__FILE__) + "/../config/requirements"
|
|
14
|
+
|
|
15
|
+
module Test
|
|
16
|
+
module Unit
|
|
17
|
+
module Assertions
|
|
18
|
+
def deny(boolean, message = nil)
|
|
19
|
+
message = build_message message, '<?> is not false or nil.', boolean
|
|
20
|
+
assert_block message do
|
|
21
|
+
not boolean
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class TestCase
|
|
27
|
+
class << self
|
|
28
|
+
def logger
|
|
29
|
+
@@logger ||= Log4r::Logger["test"]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def logger
|
|
34
|
+
self.class.logger
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
LOG_DIR = Pathname.new(File.dirname(__FILE__) + "/../log") unless Object::const_defined?(:LOG_DIR)
|
|
41
|
+
LOG_DIR.mkdir rescue nil
|
|
42
|
+
|
|
43
|
+
Log4r::Logger.root.level = Log4r::DEBUG
|
|
44
|
+
|
|
45
|
+
Log4r::Logger.new("main")
|
|
46
|
+
Log4r::Logger.new("handler")
|
|
47
|
+
Log4r::Logger.new("handler::client")
|
|
48
|
+
Log4r::Logger.new("handler::client::out")
|
|
49
|
+
Log4r::Logger.new("test")
|
|
50
|
+
|
|
51
|
+
FileUtils.touch("#{LOG_DIR}/test.log")
|
|
52
|
+
Log4r::FileOutputter.new("log", :trunc => true, :filename => (LOG_DIR + "test.log").realpath.to_s)
|
|
53
|
+
|
|
54
|
+
Log4r::Logger["main"].add "log"
|
|
55
|
+
Log4r::Logger["handler"].add "log"
|
|
56
|
+
Log4r::Logger["test"].add "log"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitCommitCheckout < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@repos = mock("repos")
|
|
6
|
+
@repos.stubs(:url).returns("git://a.repos.com/project.git")
|
|
7
|
+
@reposdir = Pathname.new("tmp/.repos.tmp.git")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_clones_repository_at_indicated_path
|
|
11
|
+
@sha1 = "a9302"
|
|
12
|
+
@commit = Piston::Git::Commit.new(@repos, @sha1)
|
|
13
|
+
@commit.expects(:git).with(:clone, @repos.url, @reposdir)
|
|
14
|
+
@commit.expects(:git).with(:checkout, "-b", "my-#{@sha1}", @sha1)
|
|
15
|
+
@commit.expects(:git).with(:log, "-n", "1").returns("commit 922b12a6bcbb6f6a2cec60bcf5de17118086080a\nAuthor: Fran\303\247ois Beausoleil <francois@teksol.info>\nDate: Fri Mar 14 13:28:41 2008 -0400\n\n Changed how dependencies are found and managed, by using config/requirements.rb everywhere.\n \n Updated test/test_helper.rb where appropriate.\n")
|
|
16
|
+
Dir.expects(:chdir).with(@reposdir).yields
|
|
17
|
+
@commit.checkout_to(@reposdir)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_cloning_head_finds_head_commit
|
|
21
|
+
@sha1 = "HEAD"
|
|
22
|
+
@commit = Piston::Git::Commit.new(@repos, @sha1)
|
|
23
|
+
@commit.expects(:git).with(:clone, @repos.url, @reposdir)
|
|
24
|
+
@commit.expects(:git).with(:checkout, "-b", "my-#{@sha1}", @sha1)
|
|
25
|
+
@commit.expects(:git).with(:log, "-n", "1").returns("commit 922b12a6bcbb6f6a2cec60bcf5de17118086080a\nAuthor: Fran\303\247ois Beausoleil <francois@teksol.info>\nDate: Fri Mar 14 13:28:41 2008 -0400\n\n Changed how dependencies are found and managed, by using config/requirements.rb everywhere.\n \n Updated test/test_helper.rb where appropriate.\n")
|
|
26
|
+
Dir.expects(:chdir).with(@reposdir).yields
|
|
27
|
+
@commit.checkout_to(@reposdir)
|
|
28
|
+
assert_equal "922b12a6bcbb6f6a2cec60bcf5de17118086080a", @commit.sha1
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
require "find"
|
|
3
|
+
|
|
4
|
+
class TestGitCommitEach < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
@repos = mock("repository")
|
|
7
|
+
@repos.stubs(:url).returns("git://github.com/francois/arepos.git")
|
|
8
|
+
|
|
9
|
+
@tmpdir = Pathname.new("tmp/.arepos.tmp.git")
|
|
10
|
+
@tmpdir.rmtree rescue nil
|
|
11
|
+
@tmpdir.mkdir
|
|
12
|
+
@commit = Piston::Git::Commit.new(@repos, "ab"*20)
|
|
13
|
+
@commit.stubs(:git).returns("commit " + "ab" * 20)
|
|
14
|
+
@commit.checkout_to(@tmpdir)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def teardown
|
|
18
|
+
@tmpdir.rmtree
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_prunes_search_tree_on_dot_git_directory
|
|
22
|
+
@tmpdir.expects(:find).yields(@tmpdir + ".git")
|
|
23
|
+
assert_throws :prune do
|
|
24
|
+
@commit.each do |relpath|
|
|
25
|
+
# Can't assert anything
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_yields_paths_relative_to_working_copy
|
|
31
|
+
@tmpdir.expects(:find).yields(@tmpdir + "a.rb")
|
|
32
|
+
@commit.each do |relpath|
|
|
33
|
+
assert_equal Pathname.new("a.rb"), relpath
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitCommitRememberance < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@repos = mock("repository")
|
|
6
|
+
@repos.stubs(:url).returns("git://github.com/francois/arepos.git")
|
|
7
|
+
|
|
8
|
+
@reposdir = Pathname.new("tmp/repos.git")
|
|
9
|
+
@commit = Piston::Git::Commit.new(@repos, "ab"*20)
|
|
10
|
+
@values = @commit.remember_values
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_remembers_original_commit_sha1
|
|
14
|
+
assert_equal @values[Piston::Git::COMMIT], @commit.sha1
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_remembers_original_branch_name
|
|
18
|
+
assert_equal @values[Piston::Git::BRANCH], @commit.revision
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitCommitValidation < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@repository = mock("repository")
|
|
6
|
+
@repository.stubs(:url).returns("git://my-git-repos/my-project.git")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_is_invalid_if_cannot_ls_remote_repository
|
|
10
|
+
commit = new_commit("HEAD")
|
|
11
|
+
commit.expects(:git).with(:ls_remote, @repository.url).raises(Piston::Git::Client::CommandError)
|
|
12
|
+
assert_raise Piston::Git::Commit::Gone do
|
|
13
|
+
commit.validate!
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_is_valid_when_ls_remote_succeeds
|
|
18
|
+
commit = new_commit("HEAD")
|
|
19
|
+
commit.expects(:git).with(:ls_remote, @repository.url).returns(INFO)
|
|
20
|
+
assert_nothing_raised do
|
|
21
|
+
commit.validate!
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
def new_commit(commit, recalled_values={})
|
|
27
|
+
Piston::Git::Commit.new(@repository, commit, recalled_values)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
INFO = <<EOF
|
|
31
|
+
a7c46c702243f145a4089b0cb33d189870f1ae53 HEAD
|
|
32
|
+
EOF
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitRepositoryAt < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@repos = Piston::Git::Repository.new("git://a.repos.com/project.git")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_returns_a_piston_git_commit
|
|
9
|
+
Piston::Git::Commit.expects(:new).with(@repos, "a93029").returns(commit = mock("commit"))
|
|
10
|
+
assert_equal commit, @repos.at("a93029")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_returns_a_piston_git_commit_at_head_when_appropriate
|
|
14
|
+
Piston::Git::Commit.expects(:new).with(@repos, "HEAD").returns(commit = mock("commit"))
|
|
15
|
+
assert_equal commit, @repos.at(:head)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_returns_a_git_commit_using_recalled_values
|
|
19
|
+
Piston::Git::Commit.expects(:new).with(@repos, "a"*40).returns(commit = mock("commit"))
|
|
20
|
+
assert_equal commit, @repos.at(Piston::Git::COMMIT => "a"*40)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitRepositoryBasename < Test::Unit::TestCase
|
|
4
|
+
def test_basename_is_urls_last_component_minus_dot_git
|
|
5
|
+
assert_equal "piston", basename("git://github.com/francois/piston.git")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
def basename(url)
|
|
10
|
+
Piston::Git::Repository.new(url).basename
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitRepositoryBranchname < Test::Unit::TestCase
|
|
4
|
+
def test_branchname_is_nil_when_no_branch_in_url
|
|
5
|
+
assert_nil Piston::Git::Repository.new("git://github.com/francois/piston.git").branchname
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_branchname_is_branch_when_branch_in_url
|
|
9
|
+
assert_equal "branch", Piston::Git::Repository.new("git://github.com/francois/piston.git?branch").branchname
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_url_does_not_include_branchname
|
|
13
|
+
assert_equal "git://github.com/francois/piston.git", Piston::Git::Repository.new("git://github.com/francois/piston.git?branch").url
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitRepositoryGuessing < Test::Unit::TestCase
|
|
4
|
+
def test_understands_git_protocol
|
|
5
|
+
assert Piston::Git::Repository.understands_url?("git://github.com/francois/piston.git")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_understands_git_ssh_protocol
|
|
9
|
+
Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "git@github.com:francois/piston.git").returns("ab"*20 + " refs/heads/master")
|
|
10
|
+
assert Piston::Git::Repository.understands_url?("git@github.com:francois/piston.git")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_understand_http_when_heads_returned
|
|
14
|
+
Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "http://github.com/francois/piston.git").returns("ab"*20 + " refs/heads/master")
|
|
15
|
+
assert Piston::Git::Repository.understands_url?("http://github.com/francois/piston.git")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_does_not_understand_http_when_no_heads
|
|
19
|
+
Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "http://github.com/francois/piston.git").returns("")
|
|
20
|
+
deny Piston::Git::Repository.understands_url?("http://github.com/francois/piston.git")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_asks_url_when_ssh_protocol
|
|
24
|
+
Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "ssh://francois@github.com/francois/piston.git").returns("ab"*20 + " refs/heads/master")
|
|
25
|
+
assert Piston::Git::Repository.understands_url?("ssh://francois@github.com/francois/piston.git")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_asks_base_url_when_named_branch_in_url
|
|
29
|
+
Piston::Git::Repository.expects(:git).with("ls-remote", "--heads", "ssh://francois@github.com/francois/piston.git").returns("ab"*20 + " refs/heads/master")
|
|
30
|
+
assert Piston::Git::Repository.understands_url?("ssh://francois@github.com/francois/piston.git?convert")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitWorkingCopyCopying < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@wcdir = Pathname.new("tmp/wc")
|
|
6
|
+
@wc = Piston::Git::WorkingCopy.new(@wcdir)
|
|
7
|
+
@wc.stubs(:git)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def teardown
|
|
11
|
+
@wcdir.rmtree rescue nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_copies_file
|
|
15
|
+
files = ["file.rb"]
|
|
16
|
+
files.expects(:copy_to).with("file.rb", @wcdir + files.first)
|
|
17
|
+
@wc.copy_from(files)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_ensures_directories_are_created
|
|
21
|
+
files = ["file/a.rb"]
|
|
22
|
+
@wcdir.expects(:+).with(files.first).returns(target = mock("target"))
|
|
23
|
+
target.expects(:dirname).returns(target)
|
|
24
|
+
target.expects(:mkdir)
|
|
25
|
+
files.expects(:copy_to).with("file/a.rb", target)
|
|
26
|
+
@wc.copy_from(files)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitWorkingCopyCreation < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@wcdir = Pathname.new("tmp/wc")
|
|
6
|
+
@wcdir.rmtree rescue nil
|
|
7
|
+
@wc = Piston::Git::WorkingCopy.new(@wcdir)
|
|
8
|
+
@wc.stubs(:git)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def teardown
|
|
12
|
+
@wcdir.rmtree rescue nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_create_does_a_simple_mkpath
|
|
16
|
+
@wcdir.expects(:mkpath)
|
|
17
|
+
@wc.create
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_create_succeeds_even_if_mkpath_fails
|
|
21
|
+
@wcdir.expects(:mkpath).raises(Errno::EEXIST)
|
|
22
|
+
assert_nothing_raised do
|
|
23
|
+
@wc.create
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitWorkingCopyExistence < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@wcdir = Pathname.new("tmp/wc")
|
|
6
|
+
@wc = Piston::Git::WorkingCopy.new(@wcdir)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
@wcdir.rmtree rescue nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_exist_false_when_no_dir
|
|
14
|
+
deny @wc.exist?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_exist_true_when_dir_present
|
|
18
|
+
@wcdir.mkdir
|
|
19
|
+
assert @wc.exist?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitWorkingCopyFinalization < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@wcdir = Pathname.new("tmp/wc")
|
|
6
|
+
@wc = Piston::Git::WorkingCopy.new(@wcdir)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
@wcdir.rmtree rescue nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_finalize_adds_path_to_git
|
|
14
|
+
Dir.expects(:chdir).with(@wcdir).yields
|
|
15
|
+
@wc.expects(:git).with(:add, ".")
|
|
16
|
+
@wc.finalize
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitWorkingCopyGuessing < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@dir = Pathname.new("tmp/wc")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_does_git_status_on_directory
|
|
9
|
+
Dir.expects(:chdir).with(@dir).yields
|
|
10
|
+
Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
|
|
11
|
+
nothing to commit (working directory clean)
|
|
12
|
+
")
|
|
13
|
+
assert Piston::Git::WorkingCopy.understands_dir?(@dir)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_does_git_status_on_parent_directories_recursively
|
|
17
|
+
@wc = @dir
|
|
18
|
+
@tmp = @wc.parent
|
|
19
|
+
@root = @tmp.parent
|
|
20
|
+
|
|
21
|
+
Dir.expects(:chdir).with(@dir).raises(Errno::ENOENT)
|
|
22
|
+
Dir.expects(:chdir).with(@tmp).raises(Errno::ENOENT)
|
|
23
|
+
Dir.expects(:chdir).with(@root).yields
|
|
24
|
+
Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
|
|
25
|
+
nothing to commit (working directory clean)
|
|
26
|
+
")
|
|
27
|
+
assert Piston::Git::WorkingCopy.understands_dir?(@dir)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_denies_when_git_unavailable
|
|
31
|
+
Piston::Git::WorkingCopy.stubs(:git).raises(Piston::Git::Client::BadCommand)
|
|
32
|
+
deny Piston::Git::WorkingCopy.understands_dir?(@dir)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestGitWorkingCopyRememberance < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@wcdir = Pathname.new("tmp/wc")
|
|
6
|
+
@wcdir.mkdir rescue nil
|
|
7
|
+
@wc = Piston::Git::WorkingCopy.new(@wcdir)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def teardown
|
|
11
|
+
@wcdir.rmtree
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_creates_dot_piston_dot_yml_file
|
|
15
|
+
@wc.remember({}, "a" => "b")
|
|
16
|
+
assert((@wcdir + ".piston.yml").exist?)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_writes_values_as_yaml_under_handler_key
|
|
20
|
+
expected = {"a" => "b"}
|
|
21
|
+
@wc.remember({}, expected)
|
|
22
|
+
actual = YAML.load((@wcdir + ".piston.yml").read)
|
|
23
|
+
assert_equal expected, actual["handler"]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../test_helper"
|
|
2
|
+
|
|
3
|
+
class TestSvnRepositoryAt < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@repos = Piston::Svn::Repository.new("http://bla.com/svn/repos/trunk")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_instantiate_revision_at_head
|
|
9
|
+
Piston::Svn::Revision.expects(:new).with(@repos, "HEAD").returns(:newrev)
|
|
10
|
+
assert_equal :newrev, @repos.at(:head)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_instantiate_revision_using_recalled_values
|
|
14
|
+
recalled_values = {Piston::Svn::REMOTE_REV => 9123, Piston::Svn::UUID => "5ecf4fe2-1ee6-0310-87b1-e25e094e27de"}
|
|
15
|
+
Piston::Svn::Revision.expects(:new).with(@repos, 9123, recalled_values).returns(:newrev)
|
|
16
|
+
assert_equal :newrev, @repos.at(recalled_values)
|
|
17
|
+
end
|
|
18
|
+
end
|