Skip to content

Commit

Permalink
Add config for soft-wrapping the commit message body
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaller committed Mar 9, 2024
1 parent 99ad600 commit cede021
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ git:
useConfig: false
commit:
signOff: false
autoWrapCommitMessage: true # automatic WYSIWYG wrapping of the commit message as you type
autoWrapWidth: 72 # if autoWrapCommitMessage is true, the width to wrap to
merging:
# only applicable to unix users
manualCommit: false
Expand Down
8 changes: 7 additions & 1 deletion pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ type PagingConfig struct {
type CommitConfig struct {
// If true, pass '--signoff' flag when committing
SignOff bool `yaml:"signOff"`
// Automatic WYSIWYG wrapping of the commit message as you type
AutoWrapCommitMessage bool `yaml:"autoWrapCommitMessage"`
// If autoWrapCommitMessage is true, the width to wrap to
AutoWrapWidth int `yaml:"autoWrapWidth"`
}

type MergingConfig struct {
Expand Down Expand Up @@ -658,7 +662,9 @@ func GetDefaultConfig() *UserConfig {
ExternalDiffCommand: "",
},
Commit: CommitConfig{
SignOff: false,
SignOff: false,
AutoWrapCommitMessage: true,
AutoWrapWidth: 72,
},
Merging: MergingConfig{
ManualCommit: false,
Expand Down
2 changes: 2 additions & 0 deletions pkg/gui/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ func (gui *Gui) createAllViews() error {
gui.Views.CommitDescription.FgColor = theme.GocuiDefaultTextColor
gui.Views.CommitDescription.Editable = true
gui.Views.CommitDescription.Editor = gocui.EditorFunc(gui.commitDescriptionEditor)
gui.Views.CommitDescription.TextArea.AutoWrap = gui.c.UserConfig.Git.Commit.AutoWrapCommitMessage
gui.Views.CommitDescription.TextArea.AutoWrapWidth = gui.c.UserConfig.Git.Commit.AutoWrapWidth

gui.Views.Confirmation.Visible = false
gui.Views.Confirmation.Editor = gocui.EditorFunc(gui.promptEditor)
Expand Down
10 changes: 10 additions & 0 deletions schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,16 @@
"signOff": {
"type": "boolean",
"description": "If true, pass '--signoff' flag when committing"
},
"autoWrapCommitMessage": {
"type": "boolean",
"description": "Automatic WYSIWYG wrapping of the commit message as you type",
"default": true
},
"autoWrapWidth": {
"type": "integer",
"description": "If autoWrapCommitMessage is true, the width to wrap to",
"default": 72
}
},
"additionalProperties": false,
Expand Down

0 comments on commit cede021

Please sign in to comment.