summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-04-13 13:56:31 +1000
committerJesse Duffield <jessedduffield@gmail.com>2019-04-13 14:38:17 +1000
commit0d3a193ab5ed54f411b217ea26ba53d6bcd6fc57 (patch)
treecd928846c4a9dbb6ff1fbd02af81ac7aadcec30b /pkg/gui
parentab9fa291a8be2426463a25a545f08816dbc838b0 (diff)
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
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/files_panel.go16
-rw-r--r--pkg/gui/gui.go4
-rw-r--r--pkg/gui/keybindings.go7
3 files changed, 25 insertions, 2 deletions
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"))
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 0990779a7..8eacd3cf3 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -408,7 +408,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
if gui.getCommitMessageView() == nil {
// doesn't matter where this view starts because it will be hidden
- if commitMessageView, err := g.SetView("commitMessage", 0, 0, width/2, height/2, 0); err != nil {
+ if commitMessageView, err := g.SetView("commitMessage", width, height, width*2, height*2, 0); err != nil {
if err.Error() != "unknown view" {
return err
}
@@ -422,7 +422,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
if check, _ := g.View("credentials"); check == nil {
// doesn't matter where this view starts because it will be hidden
- if credentialsView, err := g.SetView("credentials", 0, 0, width/2, height/2, 0); err != nil {
+ if credentialsView, err := g.SetView("credentials", width, height, width*2, height*2, 0); err != nil {
if err.Error() != "unknown view" {
return err
}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 0387b6028..6bb32ea59 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -154,6 +154,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Modifier: gocui.ModNone,
Handler: gui.handleCommitPress,
Description: gui.Tr.SLocalize("CommitChanges"),
+ },
+ {
+ ViewName: "files",
+ Key: 'w',
+ Modifier: gocui.ModNone,
+ Handler: gui.handleWIPCommitPress,
+ Description: gui.Tr.SLocalize("commitChangesWithoutHook"),
}, {
ViewName: "files",
Key: 'A',