From 0d3a193ab5ed54f411b217ea26ba53d6bcd6fc57 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 13 Apr 2019 13:56:31 +1000 Subject: Add 'w' keybinding in files panel to commit as a WIP If your git.skipHookPrefix is set to, say, WIP, in your config, then hitting 'w' in the files panel will bring up the commit message panel with 'WIP' pre-filled, so you just need to hit enter to confirm (or add some more to the message) in order to commit your changes with the --no-verify flag, meaning the pre-commit hook will be skipped --- pkg/gui/files_panel.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg/gui/files_panel.go') diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index b0b2db156..caab1bede 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -274,6 +274,22 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { return gui.refreshFiles() } +func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error { + skipHookPreifx := gui.Config.GetUserConfig().GetString("git.skipHookPrefix") + if skipHookPreifx == "" { + return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("SkipHookPrefixNotConfigured")) + } + + if err := gui.renderString(g, "commitMessage", skipHookPreifx); err != nil { + return err + } + if err := gui.getCommitMessageView().SetCursor(len(skipHookPreifx), 0); err != nil { + return err + } + + return gui.handleCommitPress(g, filesView) +} + func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { if len(gui.stagedFiles()) == 0 && gui.State.WorkingTreeState == "normal" { return gui.createErrorPanel(g, gui.Tr.SLocalize("NoStagedFilesToCommit")) -- cgit v1.2.3