1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 15:19:12 +08:00

Extend permalink clipboard copy support (#3422)

Now supports non-standard ssh remotes (ie - not github.com)

Also, now by default copies the permalink WRT the current head's SHA,
 as opposed to to name of the current branch
This commit is contained in:
Matthew Strasiotto 2020-03-29 11:34:09 +11:00 committed by GitHub
parent 13b28149d8
commit 9f738a804b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,13 +150,15 @@ fu! SpaceVim#util#CopyToClipboard(...) abort
if len(remotes) > 0
let remote = remotes[0]
if stridx(remote, '@') > -1
let repo_url = 'https://github.com/'. split(split(remote,' ')[0],':')[1]
let repo_url = split(split(remote, '@')[1], ':')[0]
let repo_url = 'https://'. repo_url. '/'. split(split(remote,' ')[0],':')[1]
let repo_url = strpart(repo_url, 0, len(repo_url) - 4)
else
let repo_url = split(remote,' ')[0]
let repo_url = strpart(repo_url, stridx(repo_url, 'http'),len(repo_url) - 4 - stridx(repo_url, 'http'))
endif
let f_url =repo_url. '/blob/'. branch[:-2] . '/'. strpart(expand('%:p'), len(repo_home) + 1, len(expand('%:p')))
let head_sha = systemlist('git rev-parse HEAD')[0]
let f_url =repo_url. '/blob/'. head_sha. '/'. strpart(expand('%:p'), len(repo_home) + 1, len(expand('%:p')))
if s:SYSTEM.isWindows
let f_url = substitute(f_url, '\', '/', 'g')
endif