You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the commitPrefix(es) pattern and replace config, the expectation is that any non-match should not result in the replace being returned. For e.g. if I have pattern: "^(JIRA-\\d+)-.*" replace: "$1: " and my branch name is master then the return should just be an empty string, not master.
To Reproduce
Steps to reproduce the behavior:
Set commitPrefix pattern and replace in config.yaml
Create a branch that doesn't match your pattern
Start a commit
Notice the branch name is in the commit box even though there was no match
Expected behavior
There should be no commit prefix if there was no regex match
phaze-ZA
changed the title
Use MatchString before ReplaceAllString in HandleCommitPress
Commit prefix is added even when there is no regex match
Jul 1, 2024
- **PR Description**
Currently if a branch name does not match a regex pattern defined in the
config.yaml (commitPrefix/es) the commit message box is populated with
the branch name as is - this does not match expectations. A prefix
should only be added if there is a match on the regex pattern.
This PR seeks to change that by checking for a match before calling
ReplaceAllString - see Issue #3695
- **Please check if the PR fulfills these requirements**
* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [-] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [-] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
Describe the bug
When using the commitPrefix(es) pattern and replace config, the expectation is that any non-match should not result in the replace being returned. For e.g. if I have
pattern: "^(JIRA-\\d+)-.*" replace: "$1: "
and my branch name ismaster
then the return should just be an empty string, notmaster
.To Reproduce
Steps to reproduce the behavior:
commitPrefix
pattern and replace in config.yamlExpected behavior
There should be no commit prefix if there was no regex match
Screenshots
Version info:
commit=6fcb7eb8bb616c170506312870b3bf15f3dbe37c, build date=2024-05-19T10:15:28Z, build source=binaryRelease, version=0.42.0, os=darwin, arch=arm64, git version=2.39.3 (Apple Git-146)
git version=2.39.3 (Apple Git-146)
Additional context
I've set up a couple of Go Playgrounds to demonstrate more or less the expected behaviour.
Expected: https://go.dev/play/p/se9Sex7v9YG
Current: https://go.dev/play/p/6Kt1NM9ZA2t
Just change the branch_name variable to see your thingy things
This would be the area that requires changing:
lazygit/pkg/gui/controllers/helpers/working_tree_helper.go
Lines 147 to 165 in 63a523c
The text was updated successfully, but these errors were encountered: