blastr 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -1
- data/lib/blastr.rb +1 -1
- data/lib/scm/git.rb +5 -1
- data/lib/scm/scm.rb +4 -6
- data/lib/scm/svn.rb +1 -1
- data/test/test_scm_url_matching.rb +34 -7
- metadata +1 -1
data/History.txt
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
== 0.0.16 2009-02-22
|
2
|
+
|
3
|
+
* Added support for HTTP-based, SSH-based, Rsync-based, and file system-based Git URLs.
|
4
|
+
|
1
5
|
== 0.0.15 2009-02-21
|
2
6
|
|
3
|
-
* Added support for local Mercurial repositories.
|
7
|
+
* Added preliminary support for local Mercurial repositories.
|
4
8
|
|
5
9
|
== 0.0.14 2009-02-20
|
6
10
|
|
data/lib/blastr.rb
CHANGED
data/lib/scm/git.rb
CHANGED
@@ -35,7 +35,11 @@ module Blastr::SourceControl
|
|
35
35
|
def name; "Git"; end
|
36
36
|
|
37
37
|
def self.understands_url?(url)
|
38
|
-
|
38
|
+
patterns = [ /^(git:)(.*)$/, /^(.*)(\.git)(\/?)$/ ]
|
39
|
+
patterns.each do |regex|
|
40
|
+
return true if url =~ regex
|
41
|
+
end
|
42
|
+
false
|
39
43
|
end
|
40
44
|
|
41
45
|
def initialize(git_url)
|
data/lib/scm/scm.rb
CHANGED
@@ -18,12 +18,10 @@ module Blastr::SourceControl
|
|
18
18
|
@@implementations = []
|
19
19
|
|
20
20
|
def self.implementation_for(url)
|
21
|
-
@@implementations.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
raise "No SCM implementation found that would understand #{url}"
|
21
|
+
matching_implementations = @@implementations.find_all { |impl| impl.understands_url?(url) }
|
22
|
+
raise "No SCM implementation found that would understand #{url}" if matching_implementations.empty?
|
23
|
+
raise "Ambiguous SCM URL #{url} - please prefix it with the type of repository ('svn:', 'git:', 'hg:')" if matching_implementations.size > 1
|
24
|
+
return matching_implementations.first.new(url)
|
27
25
|
end
|
28
26
|
|
29
27
|
def self.register_implementation(implementation)
|
data/lib/scm/svn.rb
CHANGED
@@ -2,10 +2,40 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
2
|
|
3
3
|
class TestScmURLMatching < Test::Unit::TestCase
|
4
4
|
|
5
|
-
GIT_URLS = [
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
GIT_URLS = [
|
6
|
+
"git://foo.com/bar.git",
|
7
|
+
"git:/path/to/repo",
|
8
|
+
"git:http://repo.com/project",
|
9
|
+
"http://github.com/user/project.git",
|
10
|
+
"http://github.com/user/project.git/",
|
11
|
+
"https://github.com/user/project.git",
|
12
|
+
"rsync://host.xz/repo.git",
|
13
|
+
"rsync://host.xz/repo.git/",
|
14
|
+
"ssh://host.xz/repo.git/",
|
15
|
+
"host.xz/repo.git",
|
16
|
+
"host.xz/repo.git/",
|
17
|
+
"user@host.xz/repo.git",
|
18
|
+
"user@host.xz/repo.git/",
|
19
|
+
"ssh://user@host.xz/repo.git/",
|
20
|
+
"ssh://user@host.xz:1234/path/to/repo.git",
|
21
|
+
"file:///path/to/local/repo.git",
|
22
|
+
"file:///path/to/local/repo.git/",
|
23
|
+
"/path/to/repo.git",
|
24
|
+
"/path/to/repo.git/" ]
|
25
|
+
MERCURIAL_URLS = [
|
26
|
+
"hg:http://foo.com/hg",
|
27
|
+
"hg:http://foo.com/hg/",
|
28
|
+
"hg:/tmp/hg/repo",
|
29
|
+
"hg:/tmp/hg/repo/" ]
|
30
|
+
SVN_URLS = [
|
31
|
+
"http://foo.com/repo",
|
32
|
+
"http://foo.com/repo/",
|
33
|
+
"https://foo.com/repo",
|
34
|
+
"https://foo.com/repo/",
|
35
|
+
"svn:http://foo.com/svn",
|
36
|
+
"svn:http://foo.com/svn/",
|
37
|
+
"svn:https://foo.com/svn",
|
38
|
+
"svn://foo.com/svn" ]
|
9
39
|
|
10
40
|
def test_subversion
|
11
41
|
assert_urls_are_understood_by(Blastr::SourceControl::Subversion, SVN_URLS)
|
@@ -24,8 +54,5 @@ class TestScmURLMatching < Test::Unit::TestCase
|
|
24
54
|
list_of_urls.each do |url|
|
25
55
|
assert scm.understands_url?(url), "#{url} should be understood by #{scm}!"
|
26
56
|
end
|
27
|
-
ALL_URLS.reject {|url| list_of_urls.include?(url) }.each do |url|
|
28
|
-
assert scm.understands_url?(url) == false, "#{url} should not be understood by #{scm}!"
|
29
|
-
end
|
30
57
|
end
|
31
58
|
end
|