srmeyers / git-prefix

Visual Studio Code Extension - Prefix commit message with value in branch name.
https://marketplace.visualstudio.com/items?itemName=srmeyers.git-prefix
MIT License
22 stars 14 forks source link

Regex match not extracting correct expression #30

Open dbersan opened 6 months ago

dbersan commented 6 months ago

I have a branch name like ABCD-1223

And the Pattern is set to: ^([A-Z]{3,5})-([0-9]{3,5})

When I run the Prefix commit message, the prefix is set to ABCD, even though:

image
DaVince commented 3 months ago

I'm having issues with this as well. When my branch is named hotfix/ABCD-1234-fix-this-or-that and my regex is set to (ABCD-\d+), it will enter this text:

hotfix/ABCD-1234: -fix-this-or-that

But it should be:

ABCD-1234: 

According to regexr, my regex is fine:

image

My settings are:

image
PKief commented 3 months ago

hotfix/ABCD-1234-fix-this-or-that

Please enter this .*(ABCD-\d+).* as value for your Regex, then it will work

image

{
  "gitPrefix.pattern": ".*(ABCD-\\d+).*",
  "gitPrefix.replacement": "$1:"
}
DaVince commented 3 months ago

hotfix/ABCD-1234-fix-this-or-that

Please enter this .*(ABCD-\d+).* as value for your Regex, then it will work

image

{
  "gitPrefix.pattern": ".*(ABCD-\\d+).*",
  "gitPrefix.replacement": "$1:"
}

Thanks PKief, good workaround. I do still hope it gets fixed to work as expected so no one in the future has to be confused about this.