Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6 from asceth/git_name

better regex for #name_from_git
  • Loading branch information...
commit a89f6140e55b6e11e0b9c7e932f3f788d65d0c20 2 parents 5e59b4e + 1e16911
@jasondew authored
Showing with 18 additions and 1 deletion.
  1. +1 −1  lib/ors/config.rb
  2. +17 −0 spec/ors/config_spec.rb
View
2  lib/ors/config.rb
@@ -58,7 +58,7 @@ def git
private
def name_from_git
- git.config["remote.origin.url"].gsub /.*?:(.*?).git/, '\1'
+ git.config["remote.origin.url"].gsub(/^[\w]*(@|:\/\/)[^\/:]*(\/|:)([a-zA-Z0-9\/]*)(.git)?$/i, '\3')
end
end
View
17 spec/ors/config_spec.rb
@@ -97,4 +97,21 @@ class ORS::ConfigTest; include ORS::Config; end
end
end
+ context "#name_from_git" do
+ {
+ "git://github.com/testing/github.git" => "testing/github",
+ "git://example.com/testing/gitlabhq.git" => "testing/gitlabhq",
+ "git://github.com/testing/github" => "testing/github",
+ "git@github.com:testing/github" => "testing/github",
+ "git@ghub.com:testing/gitlabhq.git" => "testing/gitlabhq",
+ "git@ghub.com:gitlabhq.git" => "gitlabhq",
+ "git://ghub.com/gitlabhq.git" => "gitlabhq"
+ }.each do |remote, name|
+ it "should handle a remote origin url such as #{remote}" do
+ mock(ORS::Config).git { mock!.config { {"remote.origin.url" => remote} }}
+ ORS::Config.send(:name_from_git).should == name
+ end
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.