Skip to content

Commit 95940ee

Browse files
committed
Ignore commit prefixes with an empty pattern
Before we changed the commitPrefix config to a list in #4261, we had this bug where the defaults section in Config.md would erroneously list the default for commitPrefix as git: commitPrefix: pattern: "" replace: "" This was not correct, commitPrefix was a pointer, and the default for that was nil, which is not the same. Now, some people copied and pasted the entire defaults section into their config files, setting the commitPrefix to an empty pattern (which is not the same as not setting it at all). And this caused the branch name to be filled in to the subject field for every commit; see for example #3632. New users copying the defaults section into their config file in the current version no longer have this problem because now that commitPrefix is a list, it is no longer included in the defaults section. However, the migration that we added in #4261 would happily carry over those empty strings into a list entry, so people migrating from an older version still have the broken config in their config files. To work around the issue, ignore commit prefix settings whose pattern is an empty string. I can't imagine a valid reason why people would actually want to set the pattern to an empty string, so I assume this only comes from the broken defaults problem described above.
1 parent c735a5e commit 95940ee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/gui/controllers/helpers/working_tree_helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ func (self *WorkingTreeHelper) HandleCommitPress() error {
155155
commitPrefixConfigs := self.commitPrefixConfigsForRepo()
156156
for _, commitPrefixConfig := range commitPrefixConfigs {
157157
prefixPattern := commitPrefixConfig.Pattern
158+
if prefixPattern == "" {
159+
continue
160+
}
158161
prefixReplace := commitPrefixConfig.Replace
159162
branchName := self.refHelper.GetCheckedOutRef().Name
160163
rgx, err := regexp.Compile(prefixPattern)

0 commit comments

Comments
 (0)