-
-
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
Allow multiple commit prefixes #4253
Allow multiple commit prefixes #4253
Conversation
func (a *CommitPrefixConfigs) UnmarshalYAML(value *yaml.Node) error { | ||
var multi []CommitPrefixConfig | ||
err := value.Decode(&multi) | ||
if err != nil { | ||
var single CommitPrefixConfig | ||
err := value.Decode(&single) | ||
if err != nil { | ||
return err | ||
} | ||
*a = []CommitPrefixConfig{single} | ||
} else { | ||
*a = multi | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that go-yaml has no way to express this behavior, so I created a newtype and put the behavior on it. Taken from the comments of go-yaml/yaml#100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this test doesn't cover much more than the existing integration tests, since the actual logic here is 5 LOC. I'm happy to remove if we don't want the duplication. Technically, it does test that we do the fallthrough to the 3rd commit prefix correctly.
# See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#predefined-commit-message-prefix | ||
commitPrefix: | ||
# pattern to match on. E.g. for 'feature/AB-123' to match on the AB-123 use "^\\w+\\/(\\w+-\\w+).*" | ||
pattern: "" | ||
|
||
# Replace directive. E.g. for 'feature/AB-123' to start the commit message with 'AB-123 ' use "[$1] " | ||
replace: "" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was automatically removed by go generate
. I guess since the element is now a sequence instead of a mapping. Is there some way we can tag the field in the config struct definition so that these details continue to show here?
@@ -271,6 +271,8 @@ type GitConfig struct { | |||
TruncateCopiedCommitHashesTo int `yaml:"truncateCopiedCommitHashesTo"` | |||
} | |||
|
|||
type CommitPrefixConfigs []CommitPrefixConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newtype just for yaml deserialization purposes to maintain backwards compatibility.
5168bb9
to
88fa09d
Compare
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
Closed in favor of #4261 |
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
This implementation, unlike that proposed in jesseduffield#4253 keeps the yaml schema easy, and does a migration from the single elements to a sequence of elements.
Addresses Set git.commitPrefix as a list instead of a dict to change several branch pattern into different commit messages prefixes #4194
The only interesting implementation detail was choosing to implement a backwards compatible yaml decoding, instead of choosing to do a migration on the user's configuration file. I have a half-finished version of that branch, if we would prefer.
go generate ./...
)