public
Fork of francois/piston
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/tapajos/piston.git
Added exceptions to guard against relative paths. test_git_git tests 
against relative paths. Tests guard against .piston.yml file not 
existing.
btakita (author)
Tue Aug 26 01:41:35 -0700 2008
commit  05d2267078c0af528e6eff8a300d319044062d56
tree    56e9195138e14974aa9bfea1d9f570b656f60637
parent  d7085e9cf6282ef9ecfed1392408c92b2bc3e66c
...
34
35
36
37
 
 
 
 
 
 
38
39
40
...
34
35
36
 
37
38
39
40
41
42
43
44
45
0
@@ -34,7 +34,12 @@ module Piston
0
     attr_reader :path
0
 
0
     def initialize(path)
0
- @path = path.kind_of?(Pathname) ? path : Pathname.new(path)
0
+ if path.kind_of?(Pathname)
0
+ raise ArgumentError, "#{path} must be absolute" unless path.absolute?
0
+ @path = path
0
+ else
0
+ @path = Pathname.new(File.expand_path(path))
0
+ end
0
       logger.debug {"In)itialized on #{@path}"}
0
     end
0
 
...
1
2
3
4
 
5
6
7
8
 
9
10
11
...
15
16
17
18
19
 
 
20
21
22
23
24
25
26
27
28
 
 
 
29
30
31
...
67
68
69
70
71
72
 
 
 
73
74
75
...
1
2
3
 
4
5
6
7
 
8
9
10
11
...
15
16
17
 
 
18
19
20
21
22
23
24
25
 
 
 
26
27
28
29
30
31
...
67
68
69
 
 
 
70
71
72
73
74
75
0
@@ -1,11 +1,11 @@
0
 require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
0
 
0
 class TestGitGit < PistonTestCase
0
- attr_reader :root_path, :repos_path, :parent_path, :wc_path
0
+ attr_reader :root_path, :parent_path, :wc_path
0
 
0
   def setup
0
     super
0
- @root_path = mkpath("/tmp/import_git_git")
0
+ @root_path = mkpath("tmp/import_git_git")
0
 
0
     @parent_path = root_path + "parent"
0
     mkpath(parent_path)
0
@@ -15,17 +15,17 @@ class TestGitGit < PistonTestCase
0
 
0
     Dir.chdir(parent_path) do
0
       git(:init)
0
- File.open(parent_path + "README", "wb") {|f| f.write "Readme - first commit"}
0
- File.open(parent_path + "file_in_first_commit", "wb") {|f| f.write "file_in_first_commit"}
0
+ File.open("README", "wb") {|f| f.write "Readme - first commit"}
0
+ File.open("file_in_first_commit", "wb") {|f| f.write "file_in_first_commit"}
0
       git(:add, ".")
0
       git(:commit, "-m", "'first commit'")
0
     end
0
 
0
     Dir.chdir(wc_path) do
0
       git(:init)
0
- File.open(wc_path + "README", "wb") {|f| f.write "Hello World!"}
0
- (wc_path + "vendor").mkdir
0
- File.open(wc_path + "vendor/.gitignore", "wb") {|f| f.write "*.swp"}
0
+ File.open("README", "wb") {|f| f.write "Hello World!"}
0
+ Pathname.new("vendor").mkdir
0
+ File.open("vendor/.gitignore", "wb") {|f| f.write "*.swp"}
0
       git(:add, ".")
0
       git(:commit, "-m", "'first commit'")
0
     end
0
@@ -67,9 +67,9 @@ class TestGitGit < PistonTestCase
0
     end
0
 
0
     Dir.chdir(parent_path) do
0
- File.open(parent_path + "README", "wb") {|f| f.write "Readme - second commit"}
0
- FileUtils.rm(parent_path + "file_in_first_commit")
0
- File.open(parent_path + "file_in_second_commit", "wb") {|f| f.write "file_in_second_commit"}
0
+ File.open("README", "wb") {|f| f.write "Readme - second commit"}
0
+ FileUtils.rm("file_in_first_commit")
0
+ File.open("file_in_second_commit", "wb") {|f| f.write "file_in_second_commit"}
0
       git(:add, ".")
0
       git(:commit, "-m", "'second commit'")
0
     end
...
54
55
56
 
57
58
59
 
60
61
62
...
54
55
56
57
58
59
 
60
61
62
63
0
@@ -54,9 +54,10 @@ class PistonTestCase < Test::Unit::TestCase
0
 
0
   def mkpath(path_or_pathname)
0
     if path_or_pathname.is_a?(Pathname)
0
+ raise ArgumentError, "#{path_or_pathname.inspect} must be absolute" unless path_or_pathname.absolute?
0
       path = path_or_pathname
0
     else
0
- path = Pathname.new(path_or_pathname)
0
+ path = Pathname.new(File.expand_path(path_or_pathname))
0
     end
0
     path.mkpath
0
     pathnames.push(path)
...
3
4
5
6
7
 
 
8
9
10
11
12
13
...
3
4
5
 
 
6
7
8
9
 
10
11
12
0
@@ -3,11 +3,10 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
0
 class Piston::Git::TestGitWorkingCopyExistence < PistonTestCase
0
   def setup
0
     super
0
- @wcdir = Pathname.new("tmp/wc")
0
- @wc = Piston::Git::WorkingCopy.new(@wcdir)
0
+ @wc = Piston::Git::WorkingCopy.new("tmp/wc")
0
+ @wcdir = @wc.path
0
   end
0
 
0
-
0
   def test_exist_false_when_no_dir
0
     deny @wc.exist?
0
   end
...
3
4
5
6
 
7
8
9
...
12
13
14
15
 
16
17
18
...
3
4
5
 
6
7
8
9
...
12
13
14
 
15
16
17
18
0
@@ -3,7 +3,7 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
0
 class Piston::Svn::TestSvnWorkingCopyExistence < PistonTestCase
0
   def setup
0
     super
0
- @wcdir = Pathname.new("tmp/wc")
0
+ @wcdir = Pathname.new(File.expand_path("tmp/wc"))
0
     @wc = Piston::Svn::WorkingCopy.new(@wcdir)
0
   end
0
 
0
@@ -12,7 +12,7 @@ class Piston::Svn::TestSvnWorkingCopyExistence < PistonTestCase
0
   end
0
 
0
   def test_exist_false_when_dir_present_but_not_an_svn_wc
0
- @wcdir.mkdir
0
+ @wcdir.mkpath
0
     deny @wc.exist?
0
   end
0
 
...
3
4
5
6
7
8
9
 
 
 
10
11
12
...
3
4
5
 
6
7
 
8
9
10
11
12
13
0
@@ -3,10 +3,11 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../../test_helper")
0
 class Piston::Svn::TestMerging < PistonTestCase
0
   def setup
0
     super
0
- @wcdir = Pathname.new("tmp/wc")
0
     @repos = mock("repository")
0
     @repos.stubs(:url).returns("http://a.repos.com/svn/trunk")
0
- @wc = Piston::Svn::WorkingCopy.new(@wcdir)
0
+ @wc = Piston::Svn::WorkingCopy.new("tmp/wc")
0
+ @wcdir = @wc.path
0
+ pathnames << @wcdir
0
 
0
     @from = mock("fromrevision")
0
     @to = mock("torevision")
...
20
21
22
23
 
24
25
26
...
20
21
22
 
23
24
25
26
0
@@ -20,7 +20,7 @@ class TestWorkingCopyRememberance < PistonTestCase
0
   end
0
 
0
   def test_remember_calls_after_remember_with_path_to_piston_yml_file
0
- @wc.expects(:after_remember).with(@wcdir + ".piston.yml")
0
+ @wc.expects(:after_remember).with(Pathname.new(@wcdir + ".piston.yml"))
0
     @wc.remember({}, "a" => "b")
0
   end
0
 

Comments

    No one has commented yet.