From 2e95c77475e4348f4aa391b86974c1ff5afbfcc7 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Thu, 10 Aug 2023 13:18:37 -0700 Subject: [PATCH 1/2] Always assume origin is a GitHub instance. --- plugin/to-github.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/to-github.vim b/plugin/to-github.vim index 7d5b6f1..76f7933 100644 --- a/plugin/to-github.vim +++ b/plugin/to-github.vim @@ -59,12 +59,14 @@ function! s:copy_to_clipboard(url) endfunction function! ToGithub(count, line1, line2, ...) - let github_url = 'https://github.com' - let get_remote = 'git remote -v | grep -E "github\.com.*\(fetch\)" | head -n 1' + let get_remote = 'git remote -v | grep -E "^origin +.*\(fetch\)$" | head -n 1' " Uses literal tab stop in regex. + let get_host = 'sed "s/^origin\t[^@]\+@\([^:]\+\).*/\1/"' let get_username = 'sed -E "s/.*com[:\/](.*)\/.*/\\1/"' let get_repo = 'sed -E "s/.*com[:\/].*\/(.*).*/\\1/" | cut -d " " -f 1' let optional_ext = 'sed -E "s/\.git//"' + let github_url = 'https://' . s:run(get_remote, get_host) + " Get the username and repo. if len(a:000) == 0 let username = s:run(get_remote, get_username) From 4cbff5fc85e2570a9c4390fa771fca9b95612743 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Thu, 10 Aug 2023 14:54:39 -0700 Subject: [PATCH 2/2] Support HTTPS URLs in git remotes. --- plugin/to-github.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/to-github.vim b/plugin/to-github.vim index 76f7933..42cf061 100644 --- a/plugin/to-github.vim +++ b/plugin/to-github.vim @@ -60,7 +60,7 @@ endfunction function! ToGithub(count, line1, line2, ...) let get_remote = 'git remote -v | grep -E "^origin +.*\(fetch\)$" | head -n 1' " Uses literal tab stop in regex. - let get_host = 'sed "s/^origin\t[^@]\+@\([^:]\+\).*/\1/"' + let get_host = 'sed "s,^origin\t\+\([^@]\+@\|https://\)\([^/:]\+\).*,\2,"' let get_username = 'sed -E "s/.*com[:\/](.*)\/.*/\\1/"' let get_repo = 'sed -E "s/.*com[:\/].*\/(.*).*/\\1/" | cut -d " " -f 1' let optional_ext = 'sed -E "s/\.git//"'