-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Set git.commitPrefix as a list instead of a dict to change several branch pattern into different commit messages prefixes #4194
Comments
Is the idea that different repos use different patterns, or would you want multiple patterns used on the one repo? Cos if it's the former, the proper fix is to just support per-repo configuration (which I am pretty sure we are yet to support) |
Hello! |
I see, and would you like the first matching pattern to be the one that's used? |
yes could be as simple as that, if the one is not matched lets try the second on etc. |
Okay I'm cool with that. Should be easy enough to implement. Would you be up for raising a PR @ginolegigot ? |
i can barely write a print in go but can try. If someone feels ready tho, feel free to take it |
I've got a local branch setting up this config with a slice of elements in the config, but that is a breaking change. There doesn't appear to be a free way to communicate to yaml that it should unmarahall as a slice, or a slice of length 1. go-yaml/yaml#100 Would you rather I:
|
Got a PR for this! #4253 Chose option 2 of the above list |
I'm not excited about option 2, since your custom unmarshalling code then doesn't match the generated schema, and that's a problem. Not just for generating My suggestion would be to add a new config option This is similar to what we did for the branch colors in #4130. Actually, in this case it seems that we could do better and auto-migrate the config from |
I couldn't migrate the name to I noticed a decent chunk of similar code in the migrations. Each possible migration unmarshalls, does its checks, and then re-marshalls. It has to check for empty documents and such every time. Would you be open to a refactoring PR that parses the document into a single |
I thought about that back when I wrote the code, and I swear I had a reason for doing it this way. If I could only remember what the reason was... I think the reason might have been that it's more robust this way to decide whether we have to write the file back; with your approach, each migration needs an extra bool return value that communicates back whether something was changed. Not sure that's a good reason though. (Alternatively, we could make a deep copy of the yaml node and then a DeepEquals afterwards to see if something changed; also awkward.) So yes, I think I wouldn't be opposed to refactoring this if you find it important enough. |
Fixed by #4261. |
- **PR Description** In the solving of #4194 we had some discussion about the repeated marshalling and unmarshalling of the content in our migrations. #4194 (comment). I was feeling the itch to see if there was a meaningful performance impact to that, and this is the results! I added a benchmark first that uses the entirety of `Config.md`. This ensures a worst-case scenario for the repeated parsing, and probably at least 1 user has done this for their config. Here were the benchmark results prior and after this PR: ## Before ``` $ go test ./pkg/config/ -bench=. -benchmem -count=10 goos: linux goarch: amd64 pkg: github.com/jesseduffield/lazygit/pkg/config cpu: Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz BenchmarkMigrationOnLargeConfiguration-8 85 18165916 ns/op 1501442 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 50 21024442 ns/op 1501473 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 75 18814769 ns/op 1501509 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 60 17886812 ns/op 1501434 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 97 17767498 ns/op 1501448 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 62 18749923 ns/op 1501478 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 62 19248265 ns/op 1501467 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 92 14771199 ns/op 1501423 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 67 16345152 ns/op 1501440 B/op 19316 allocs/op BenchmarkMigrationOnLargeConfiguration-8 98 16785737 ns/op 1501472 B/op 19316 allocs/op PASS ok github.com/jesseduffield/lazygit/pkg/config 14.474s ``` so somewhere in the range of 14 to 21 ms added to startup time. ## After ``` $ go test ./pkg/config/ -bench=. -benchmem -count=10 goos: linux goarch: amd64 pkg: github.com/jesseduffield/lazygit/pkg/config cpu: Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz BenchmarkMigrationOnLargeConfiguration-8 440 2936145 ns/op 265800 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 428 3099183 ns/op 265787 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 355 3074069 ns/op 265785 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 478 3031144 ns/op 265792 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 375 2795470 ns/op 265785 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 406 2688491 ns/op 265791 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 375 3092990 ns/op 265791 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 379 2789022 ns/op 265785 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 417 3108530 ns/op 265785 B/op 3928 allocs/op BenchmarkMigrationOnLargeConfiguration-8 487 2848502 ns/op 265788 B/op 3928 allocs/op PASS ok github.com/jesseduffield/lazygit/pkg/config 15.352s ``` So somewhere between 2.6 and 3.1 ms. Is that a meaningful speedup? I'm not sure, but it's something! I had to add the bit of complexity mentioned in the comment to track whether we had made any changes, but that doesn't feel fundamentally much more complex to me, since we were already implicitly tracking that fact with whether the string file changed. - **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)) * [ ] 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)) * [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig)) * [ ] Docs have been updated if necessary * [X] You've read through your own file changes for silly mistakes etc
Is your feature request related to a problem? Please describe.
Hello! Would it be possible to set commitPrefix as a list so we can change/transform several branch patterns into several commit message prefix pattern ?
Describe the solution you'd like
For example something like this:
Currently we have:
Thanks for your reading !
The text was updated successfully, but these errors were encountered: