-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify regex flavor and mechanics in docs #4105
Comments
I suspect that the regex flavor is not your problem here. Lazygit uses golang's regex package, so it uses the syntax described here. Are you aware that the |
some-front is one of my working folders. Its renamed for the sake of privacy. It doesn't match either in lazygit, so its not the naming problem. If its not flavor, than I suspect its something with yaml parsing or the prefix matching itself. |
Ok. In that case, it's just basic regex errors that make this not work for you. I'm not sure what lazygit or its documentation can do to help with this; regex is hard. 😄 I recommend https://regex101.com to test your patterns. Your first pattern doesn't work because of the double backslash; there's no reason to quote backslashes in yaml (unless you put them in double quotes, which is not a good idea for regex patterns. You'd have to escape too many things in the pattern.) Your second pattern does work for me; however, it results in a subject line of "[SHOP-1111] _foo_bar_baz", which I suspect is not what you want. Use The third pattern doesn't work because it anchors to the end of the string after Finally, one word about testing these in lazygit: I was briefly confused why changing the config while lazygit is running didn't seem to have any effect (normally, config changes are supposed to take effect immediately). The reason is lazygit's feature to remember a half-typed commit message when you abort committing. When I tested this, I staged a file, hit |
Yeah, lazygit config taking effect after restart is something to keep in mind. And likely to specify in docs. After I restarted changes took effect. BTW I'm using git flow, and I think it has its part in affecting overall regex story. Lets reproduce: Without capture groupProject: shopping-2 git:
commitPrefixes:
shopping-2:
pattern: ^feature/[A-Z]+-\d+
replace: '[$1] '
Regex101 test: [
[
{
"content": "feature/SHOP-1111",
"isParticipating": true,
"groupNum": 0,
"startPos": 0,
"endPos": 23
}
]
] Press
With capture groupProject: shopping-2 git:
commitPrefixes:
shopping-2:
pattern: ^feature/([A-Z]+-\d+)
replace: '[$1] ' Regex101 test: [
[
{
"content": "feature/SHOP-1111",
"isParticipating": true,
"groupNum": 0,
"startPos": 0,
"endPos": 17
},
{
"content": "SHOP-1111",
"isParticipating": true,
"groupNum": 1,
"startPos": 8,
"endPos": 17
}
]
] Press
To summarizeAs you can see, regex is acting strange. Without group it doesnt match SHOP-1111, and only returns brackets AND rest of branch name. That is something I dont understand, because we didn't specify it in config. But with grouping regex match seems to work. My overall goal was to capture |
No, config changes do take effect without restart. The fact that this doesn't work for the commit prefix patterns has to do with the preserve commit message functionality; the two interfere in ways that are hard to understand. Actually this may be a bug, I'll see if I can come up with an easy fix.
Huh? I don't see what that has to do with it.
That's how regex replacing works in go. When you use
Try this:
|
Here's a fix for this problem: #4110. |
Great! Thank you for the explanation, I managed to get my regex working. Also I made a doc PR that helps other users handle this issue #4114 |
Is your feature request related to a problem? Please describe.
Right now docs doesn't clarify what flavor of regex lazygit is using. It results in many hours of trying different combination that ends with frustration. We need a way to make this process less painfull.
Describe the solution you'd like
For a minimum requirement I suggest providing explanation of regex flavor that is being used. I tried Golang one, but failed. We need more examples with popular variants, and also some quickfixes for most popular prefix problems.
We can also add custom script with real time regex test, that runs on existing branches.
Describe alternatives you've considered
I considered using custom script, but it seems little bit overkill for what we are trying to achieve
Additional context
I tried this config
with this branches
None of them matched
The text was updated successfully, but these errors were encountered: