public this repo is viewable by everyone
Description: Simple tool to help track git and svn vendor branches in a git repository
Homepage: http://evil.che.lu/projects/braid
Clone URL: git://github.com/evilchelu/braid.git
check for required git svn version 1.5.4.5
evilchelu (author)
5 days ago
commit  367c3ec43109e105d7e2178e5693bd3ccc8f6a15
tree    2cf9aa2836f1185ad8ce051cb25a929cf44bdaea
parent  126eec929f306cdd67ccc19a49316ce3a378c4bc
...
14
15
16
 
17
18
19
...
14
15
16
17
18
19
20
0
@@ -14,6 +14,7 @@ module Braid
0
   WORK_BRANCH = "braid/track"
0
   CONFIG_FILE = ".braids"
0
   REQUIRED_GIT_VERSION = "1.5.4.5"
0
+ REQUIRED_GIT_SVN_VERSION = "1.5.4.5"
0
 end
0
 
0
 require 'braid/version'
...
8
9
10
11
 
 
12
13
14
...
17
18
19
20
21
 
 
 
 
 
 
22
23
24
...
8
9
10
 
11
12
13
14
15
...
18
19
20
 
 
21
22
23
24
25
26
27
28
29
0
@@ -8,7 +8,8 @@ module Braid
0
       include Operations::Git
0
 
0
       def run(command, *args)
0
- raise Braid::Git::VersionTooLow unless verify_git_version(REQUIRED_GIT_VERSION)
0
+ raise Braid::Git::GitVersionTooLow unless verify_version("git", REQUIRED_GIT_VERSION)
0
+ raise Braid::Git::GitSvnVersionTooLow unless verify_version("git svn", REQUIRED_GIT_SVN_VERSION)
0
 
0
         klass = Braid::Commands.const_get(command.to_s.capitalize)
0
         klass.new.run(*args)
0
@@ -17,8 +18,12 @@ module Braid
0
         msg "Local changes are present. You have to commit or stash them before running braid commands."
0
         msg "Exiting."
0
 
0
- rescue Braid::Git::VersionTooLow => e
0
- msg "This version of braid requires at least git #{REQUIRED_GIT_VERSION}. You have #{extract_git_version}."
0
+ rescue Braid::Git::GitVersionTooLow => e
0
+ msg "This version of braid requires at least git #{REQUIRED_GIT_VERSION}. You have #{extract_version("git")}."
0
+ msg "Exiting."
0
+
0
+ rescue Braid::Git::GitSvnVersionTooLow => e
0
+ msg "This version of braid requires at least git svn #{REQUIRED_GIT_SVN_VERSION}. You have #{extract_version("git svn")}."
0
         msg "Exiting."
0
 
0
       rescue => e
...
23
24
25
26
 
 
27
28
29
...
23
24
25
 
26
27
28
29
30
0
@@ -23,7 +23,8 @@ module Braid
0
 
0
   class Git
0
     class UnknownRevision < Braid::Exception; end
0
- class VersionTooLow < Braid::Exception; end
0
+ class GitVersionTooLow < Braid::Exception; end
0
+ class GitSvnVersionTooLow < Braid::Exception; end
0
     class LocalChangesPresent < Braid::Exception; end
0
   end
0
 
...
116
117
118
119
120
121
 
 
 
122
123
124
 
125
126
 
127
128
129
...
116
117
118
 
 
 
119
120
121
122
123
 
124
125
 
126
127
128
129
0
@@ -116,14 +116,14 @@ module Braid
0
         end
0
       end
0
 
0
- def extract_git_version
0
- status, out, err = exec!("git --version")
0
- return out.sub(/^git version/, "").strip
0
+ def extract_version(cmd)
0
+ status, out, err = exec!("#{cmd} --version")
0
+ return out.sub(/^.* version/, "").strip
0
       end
0
 
0
- def verify_git_version(required)
0
+ def verify_version(cmd, required)
0
         required_version = required.split(".")
0
- actual_version = extract_git_version.split(".")
0
+ actual_version = extract_version(cmd).split(".")
0
         actual_version.each_with_index do |actual_piece, idx|
0
           required_piece = required_version[idx]
0
 
...
20
21
22
23
 
24
25
26
 
 
 
 
 
27
28
29
30
 
31
32
33
34
35
36
37
38
 
 
39
40
41
42
43
44
45
 
 
46
47
48
...
20
21
22
 
23
24
25
 
26
27
28
29
30
31
32
33
 
34
35
36
37
38
39
40
 
 
41
42
43
44
45
46
47
 
 
48
49
50
51
52
0
@@ -20,29 +20,33 @@ describe "Braid::Operations::Mirror#find_remote" do
0
   end
0
 end
0
 
0
-describe Braid::Operations::Helpers, "extract_git_version" do
0
+describe Braid::Operations::Helpers, "extract_version" do
0
   it "should extract from git --version output" do
0
     self.stub!(:exec!).and_return([0, "git version 1.5.5.1.98.gf0ec4\n", ""])
0
- extract_git_version.should == "1.5.5.1.98.gf0ec4"
0
+ extract_version("git").should == "1.5.5.1.98.gf0ec4"
0
+ end
0
+ it "should extract from git svn --version output" do
0
+ self.stub!(:exec!).and_return([0, "git-svn version 1.5.5.1.98.gf0ec4\n", ""])
0
+ extract_version("git svn").should == "1.5.5.1.98.gf0ec4"
0
   end
0
 end
0
 
0
-describe Braid::Operations::Helpers, "verify_git_version against 1.5.4.5" do
0
+describe Braid::Operations::Helpers, "verify_version against 1.5.4.5" do
0
   required_version = "1.5.4.5"
0
   should_pass = %w(1.5.4.6 1.5.5 1.6 1.5.4.5.2 1.5.5.1.98.gf0ec4)
0
   should_not_pass = %w(1.5.4.4 1.5.4 1.5.3 1.4.5.6)
0
 
0
   should_pass.each do |actual_version|
0
     it "should be true for #{actual_version}" do
0
- self.stub!(:extract_git_version).and_return(actual_version)
0
- verify_git_version("1.5.4.5").should == true
0
+ self.should_receive(:extract_version).with("some git executable").and_return(actual_version)
0
+ verify_version("some git executable", "1.5.4.5").should == true
0
     end
0
   end
0
 
0
   should_not_pass.each do |actual_version|
0
     it "should be false for #{actual_version}" do
0
- self.stub!(:extract_git_version).and_return(actual_version)
0
- verify_git_version("1.5.4.5").should == false
0
+ self.should_receive(:extract_version).with("some git executable").and_return(actual_version)
0
+ verify_version("some git executable", "1.5.4.5").should == false
0
     end
0
   end
0
 end

Comments

    No one has commented yet.