From c69991f3a497e4d7175832a805b01948e4425411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Mon, 12 Dec 2011 12:57:31 +0100 Subject: [PATCH] GitHub remote urls don't have to necessarily end in ".git" --- lib/hub/context.rb | 5 +++-- test/hub_test.rb | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/hub/context.rb b/lib/hub/context.rb index c91f7285..4750221f 100644 --- a/lib/hub/context.rb +++ b/lib/hub/context.rb @@ -233,8 +233,9 @@ module Hub end def project - if urls.find { |u| u =~ %r{\bgithub\.com[:/](.+)/(.+).git$} } - GithubProject.new local_repo, $1, $2 + if urls.find { |u| u =~ %r{\bgithub\.com[:/](.+)/(.+)\z} } + owner = $1 + GithubProject.new local_repo, owner, $2.sub(/\.git$/, '') end end diff --git a/test/hub_test.rb b/test/hub_test.rb index 71695464..4bf3ae9c 100644 --- a/test/hub_test.rb +++ b/test/hub_test.rb @@ -1045,6 +1045,11 @@ config assert_command "browse --", "open https://github.com/defunkt/hub" end + def test_hub_browse_current_https_uri + stub_repo_url "https://github.com/defunkt/hub" + assert_command "browse", "open https://github.com/defunkt/hub" + end + def test_hub_browse_commit_from_current assert_command "browse -- commit/6616e4", "open https://github.com/defunkt/hub/commit/6616e4" end -- GitLab