sodapopcan / vim-twiggy

Git branch management for Vim
280 stars 15 forks source link

Square brackets in commit message breaks detecting remote #25

Closed kristijanhusak closed 5 years ago

kristijanhusak commented 5 years ago

Hi,

I noticed that Twiggy cannot properly detect remote when commit message contains square brackets.

For example, for my projects, i prefix all commit messages with jira ticket name:

[MP-123] Fix reports.

This causes twiggy to set MP-123 as a remote, which causes push failures with message:

Remote does not exist 
sodapopcan commented 5 years ago

Ah yes, that makes sense.

I'm not going to be able to get to this for a few days. If you're viml savvy and feel like sending a PR, it very likely has to do with this section: https://github.com/sodapopcan/vim-twiggy/blob/master/autoload/twiggy.vim#L199-L203. Otherwise, I'll try and get to it later in the week.

Thanks for the report!

kristijanhusak commented 5 years ago

I have idea how to solve it, but no enough time to dedicate myself to it. Using custom format when listing branches, something like this:

git branch -vv --no-color \
--format="%(HEAD)!!>><<!!%(objectname:short)!!>><<!!%(refname:short)!!>><<!!%(subject)!!>><<!!%(push:remotename)!!>><<!!%(upstream:track)"

later splitting it by !!>><<!! would give us everything that we need to generate a branch dictionary. Not sure what to use for delimiter, this is really ugly, but i assume it won't happen in commit message. I maybe missed something, but the general idea is here.

sodapopcan commented 5 years ago

So I finally sat down to take a look. I actually thought it was going to be easier than it is and your solution is actually very helpful! I will try and fix this weekend. Sorry for the delay!

sodapopcan commented 5 years ago

I ended up using a double-tab as a delimiter—I figure that is pretty damn safe.

kristijanhusak commented 5 years ago

Works like a charm! Thanks!