diff --git a/docs/Config.md b/docs/Config.md index c083fcb50..bfc4b2186 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -21,6 +21,7 @@ merging: # only applicable to unix users manualCommit: false + skipHookPrefix: WIP update: method: prompt # can be: prompt | background | never days: 14 # how often an update is checked for diff --git a/pkg/commands/git.go b/pkg/commands/git.go index ae2281ee9..265d6553e 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -334,8 +334,8 @@ func (c *GitCommand) usingGpg() bool { } // Commit commits to git -func (c *GitCommand) Commit(message string) (*exec.Cmd, error) { - command := fmt.Sprintf("git commit -m %s", c.OSCommand.Quote(message)) +func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error) { + command := fmt.Sprintf("git commit %s -m %s", flags, c.OSCommand.Quote(message)) if c.usingGpg() { return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command), nil } diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index ac8e52c8c..b35294a11 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -248,6 +248,7 @@ func GetDefaultConfig() []byte { git: merging: manualCommit: false + skipHookPrefix: 'WIP' update: method: prompt # can be: prompt | background | never days: 14 # how often a update is checked for diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 0f7e4ffcc..62892f09b 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -30,7 +30,12 @@ func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error { if message == "" { return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr")) } - ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.Commit(message)) + flags := "" + skipHookPrefix := gui.Config.GetUserConfig().GetString("git.skipHookPrefix") + if skipHookPrefix != "" && strings.HasPrefix(message, skipHookPrefix) { + flags = "--no-verify" + } + ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.Commit(message, flags)) if err != nil { return err }