diff --git a/features/browse.feature b/features/browse.feature index accfa3878c76532e5f1b5976746bad468abf0aec..f61159a624bf4142d65b1bc5835947a925f7ba4d 100644 --- a/features/browse.feature +++ b/features/browse.feature @@ -73,9 +73,9 @@ Feature: hub browse Scenario: Complex branch Given I am in "git://github.com/mislav/dotfiles.git" git repo - And I am on the "foo/bar" branch with upstream "origin/baz/qux" + And I am on the "foo/bar" branch with upstream "origin/baz/qux/moo" When I successfully run `hub browse` - Then "open https://github.com/mislav/dotfiles/tree/baz/qux" should be run + Then "open https://github.com/mislav/dotfiles/tree/baz/qux/moo" should be run Scenario: Wiki repo Given I am in "git://github.com/defunkt/hub.wiki.git" git repo diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index 5823025cd05aeb09ca0a3df072ee4eb6c00e84dc..1652f7b4f526debcdd2b8227e9008a356a173d37 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -649,9 +649,9 @@ module Hub # $ hub browse -- wiki path = case subpage = args.shift when 'commits' - "/commits/#{CGI.escape(branch.short_name).sub("%2F", "/")}" + "/commits/#{branch_in_url(branch)}" when 'tree', NilClass - "/tree/#{CGI.escape(branch.short_name).sub("%2F", "/")}" if branch and !branch.master? + "/tree/#{branch_in_url(branch)}" if branch and !branch.master? else "/#{subpage}" end @@ -660,6 +660,11 @@ module Hub end end + def branch_in_url(branch) + require 'CGI' + CGI.escape(branch.short_name).gsub("%2F", "/") + end + # $ hub compare 1.0..fix # > open https://github.com/CURRENT_REPO/compare/1.0...fix # $ hub compare refactor