diff --git a/lib/hub/context.rb b/lib/hub/context.rb index c91f7285b9c9c4d50d92fe4dd0b0cb6361735fad..4750221fe8c4cf22725d09231189215b7c4e3b85 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 71695464913462120922c2de6b07ad3b4b816e6a..4bf3ae9c8c79642da9ccf602bf11ef97a8cdd93a 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