public
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/francois/piston.git
Search Repo:
Piston::Git::Commit#validate! implementation.

Git doesn't allow us to do many validation checks.  As long as we can talk 
to a remote repository from the URL, we assume we're OK.
francois (author)
Tue May 13 17:17:53 -0700 2008
commit  1d52246f7acabb0fdec2f555430702840146d418
tree    744b3fa8d01e231c8493bedd58a04a48fccff70c
parent  0d066f30f00db013c1dd0ac62b464156dc061b92
...
5
6
7
 
 
 
8
9
10
...
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
...
5
6
7
8
9
10
11
12
13
...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
0
@@ -5,6 +5,9 @@
0
 module Piston
0
   module Git
0
     class Commit < Piston::Revision
0
+ class InvalidCommit < RuntimeError; end
0
+ class Gone < InvalidCommit; end
0
+
0
       alias_method :commit, :revision
0
 
0
       def client
0
@@ -13,6 +16,19 @@
0
 
0
       def git(*args)
0
         client.git(*args)
0
+ end
0
+
0
+ def recalled_commit_id
0
+ recalled_values[Piston::Git::COMMIT]
0
+ end
0
+
0
+ def validate!
0
+ begin
0
+ data = git(:ls_remote, @repository.url)
0
+ self
0
+ rescue Piston::Git::Client::CommandError
0
+ raise Piston::Git::Commit::Gone, "Repository at #{@repository.url} does not exist anymore"
0
+ end
0
       end
0
 
0
       def name
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -1 +1,34 @@
0
+require File.dirname(__FILE__) + "/../../../test_helper"
0
+
0
+class TestGitCommitValidation < Test::Unit::TestCase
0
+ def setup
0
+ @repository = mock("repository")
0
+ @repository.stubs(:url).returns("git://my-git-repos/my-project.git")
0
+ end
0
+
0
+ def test_is_invalid_if_cannot_ls_remote_repository
0
+ commit = new_commit("HEAD")
0
+ commit.expects(:git).with(:ls_remote, @repository.url).raises(Piston::Git::Client::CommandError)
0
+ assert_raise Piston::Git::Commit::Gone do
0
+ commit.validate!
0
+ end
0
+ end
0
+
0
+ def test_is_valid_when_ls_remote_succeeds
0
+ commit = new_commit("HEAD")
0
+ commit.expects(:git).with(:ls_remote, @repository.url).returns(INFO)
0
+ assert_nothing_raised do
0
+ commit.validate!
0
+ end
0
+ end
0
+
0
+ protected
0
+ def new_commit(commit, recalled_values={})
0
+ Piston::Git::Commit.new(@repository, commit, recalled_values)
0
+ end
0
+
0
+ INFO = <<EOF
0
+a7c46c702243f145a4089b0cb33d189870f1ae53 HEAD
0
+EOF
0
+end

Comments

    No one has commented yet.