tommcdo/vim-fubitive

Does not work with branches containing slashes "/"

vianney-g opened this issue · 1 comments

If a branch contains a slash, :Gbrowse leads to a 404 page.

This is because of a bitbucket api limitation: https://jira.atlassian.com/browse/BCLOUD-9969?focusedCommentId=2598330&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2598330

There is no straightforward fix for that. Escaping slashes with %2F does not work.
The only fix I see would be to replace the branch name by the commit hash.

Try applying this patch.

diff --git a/plugin/fubitive.vim b/plugin/fubitive.vim
index 22d79b5..18d88e1 100644
--- a/plugin/fubitive.vim
+++ b/plugin/fubitive.vim
@@ -49,6 +49,7 @@ function! s:bitbucket_url(opts, ...) abort
           \ ? substitute(root . '/src/' . commit . '/' . path, '/$', '', '')
           \ : substitute(root . '/browse/' . path . '?at=' . commit, '/$', '', '')
   elseif get(a:opts, 'type', '') ==# 'blob' || a:opts.path =~# '[^/]$'
+    let commit = fugitive#RevParse('HEAD')
     let url = is_cloud
           \ ? root . '/src/' . commit . '/' . path
           \ : root . '/browse/' . path . '?at=' . commit