public
Rubygem
Fork of defunkt/github-gem
Description: The official `github` command line helper for simplifying your GitHub experience.
Homepage: http://github.com
Clone URL: git://github.com/rubyist/github-gem.git
Search Repo:
Be more lenient in accepting SSH urls

We should accept URLs beginning with ssh://
Also accept ones without the git@ as .ssh/config could specify that
kballard (author)
Sun May 11 00:55:12 -0700 2008
commit  bf1aaf6cca044b58bf74c2d7eaddb04764cb90dd
tree    c03f6c824e3961f8bf81f30a1da45cfe85a965b1
parent  48230cb74f66f03c4c10b8b64914d01a29de2c19
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 GitHub.helper :user_and_repo_from do |url|
0
   case url
0
   when %r|^git://github\.com/([^/]+/[^/]+)$|: $1.split('/')
0
- when %r|^git@github\.com:([^/]+/[^/]+)$|: $1.split('/')
0
+ when %r|^(?:ssh://)?(?:git@)?github\.com:([^/]+/[^/]+)$|: $1.split('/')
0
   else ['', '']
0
   end
0
 end
...
13
14
15
 
 
 
 
 
 
16
17
18
...
23
24
25
 
 
 
 
26
27
...
13
14
15
16
17
18
19
20
21
22
23
24
...
29
30
31
32
33
34
35
36
37
0
@@ -13,6 +13,12 @@ describe "The user_and_repo_from helper" do
0
     @helper.user_and_repo_from("git@github.com:mojombo/god.git").should == ["mojombo", "god.git"]
0
   end
0
 
0
+ it "should parse a non-standard ssh-based url" do
0
+ @helper.user_and_repo_from("ssh://git@github.com:mojombo/god.git").should == ["mojombo", "god.git"]
0
+ @helper.user_and_repo_from("github.com:mojombo/god.git").should == ["mojombo", "god.git"]
0
+ @helper.user_and_repo_from("ssh://github.com:mojombo/god.git").should == ["mojombo", "god.git"]
0
+ end
0
+
0
   it "should return nothing for other urls" do
0
     @helper.user_and_repo_from("home:path/to/repo.git").should == ['', '']
0
   end
0
@@ -23,5 +29,9 @@ describe "The user_and_repo_from helper" do
0
 
0
   it "should return nothing for invalid ssh-based urls" do
0
     @helper.user_and_repo_from("git@github.com:kballard").should == ['', '']
0
+ @helper.user_and_repo_from("git@github.com:kballard/test/repo.git").should == ['', '']
0
+ @helper.user_and_repo_from("ssh://git@github.com:kballard").should == ['', '']
0
+ @helper.user_and_repo_from("github.com:kballard").should == ['', '']
0
+ @helper.user_and_repo_from("ssh://github.com:kballard").should == ['', '']
0
   end
0
 end

Comments

    No one has commented yet.