From 7ffc7365df09ffe15b0d64e11b40fb4afc6b8049 Mon Sep 17 00:00:00 2001 From: Stefan Liebl Date: Mon, 13 Nov 2017 14:36:02 +0100 Subject: [PATCH] Gcommit: extract ticket number from branch name --- vimfiles.stefan/after/ftplugin/gitcommit.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vimfiles.stefan/after/ftplugin/gitcommit.vim b/vimfiles.stefan/after/ftplugin/gitcommit.vim index f6bae85..aec3530 100644 --- a/vimfiles.stefan/after/ftplugin/gitcommit.vim +++ b/vimfiles.stefan/after/ftplugin/gitcommit.vim @@ -1,5 +1,6 @@ " Stefans gitcommit-filetype-plugin -" add branch name to commit message -nnoremap gcc :execute 'normal i'.fugitive#head()A: -nnoremap ccc :Gcommit:execute 'normal i'.fugitive#head()A: +" add branch name to commit message, replace 'feature/DLCPRO-1234-abc' by 'DLCPRO-1234' +nnoremap gcc :execute 'normal i'.substitute(fugitive#head(), '\%(.*/\)*\([^-]\+-\d*\).*', '\1', '')A: +nnoremap ccc :Gcommit:execute 'normal i'.substitute(fugitive#head(), '\%(.*/\)*\([^-]\+-\d*\).*', '\1', '')A: +