-
-
Save espizo/e7c415860d5d1bc36aa2384f974c974e to your computer and use it in GitHub Desktop.
Extract issue id from branch name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" get reference for the current issue from git branch name | |
" assumes your branch name looks like 1337-fixing-a-lot-of-stuff | |
" | |
function GitBranchIssue(fixes) | |
let current_branch = system("git rev-parse --abbrev-ref HEAD") | |
let ref = substitute(current_branch, '^.\+\/\(\d\+\).\+$', '\1', '') | |
if a:fixes == 'true' | |
let prefix = 'fixes' | |
else | |
let prefix = 'refs' | |
endif | |
return prefix . ' #' . ref | |
endfunction | |
iab REFS <C-R>=GitBranchIssue('false')<CR> | |
iab FIXES <C-R>=GitBranchIssue('true')<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment