summaryrefslogtreecommitdiffstats
path: root/branches_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-06-05 18:49:10 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-06-05 18:49:10 +1000
commit9c018c61388c0a37b3c8efaf5841debaba1c76fe (patch)
tree318a4e456332e56301a6b022a20146bf1149302d /branches_panel.go
parentd1ead5b0cf4fb400c7d89a6320621f409b999ab5 (diff)
factoring out error panel creation
Diffstat (limited to 'branches_panel.go')
-rw-r--r--branches_panel.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/branches_panel.go b/branches_panel.go
index 172f5d011..58620f049 100644
--- a/branches_panel.go
+++ b/branches_panel.go
@@ -9,7 +9,7 @@ import (
func handleBranchPress(g *gocui.Gui, v *gocui.View) error {
branch := getSelectedBranch(v)
if output, err := gitCheckout(branch.Name, false); err != nil {
- createSimpleConfirmationPanel(g, v, "Error", output)
+ createErrorPanel(g, output)
}
return refreshSidePanels(g, v)
}
@@ -18,7 +18,7 @@ func handleForceCheckout(g *gocui.Gui, v *gocui.View) error {
branch := getSelectedBranch(v)
return createConfirmationPanel(g, v, "Force Checkout Branch", "Are you sure you want force checkout? You will lose all local changes (y/n)", func(g *gocui.Gui, v *gocui.View) error {
if output, err := gitCheckout(branch.Name, true); err != nil {
- createSimpleConfirmationPanel(g, v, "Error", output)
+ createErrorPanel(g, output)
}
return refreshSidePanels(g, v)
}, nil)
@@ -27,9 +27,8 @@ func handleForceCheckout(g *gocui.Gui, v *gocui.View) error {
func handleNewBranch(g *gocui.Gui, v *gocui.View) error {
branch := state.Branches[0]
createPromptPanel(g, v, "New Branch Name (Branch is off of "+branch.Name+")", func(g *gocui.Gui, v *gocui.View) error {
- // TODO: make sure the buffer is stripped of whitespace
- if output, err := gitNewBranch(v.Buffer()); err != nil {
- return createSimpleConfirmationPanel(g, v, "Error", output)
+ if output, err := gitNewBranch(trimmedContent(v)); err != nil {
+ return createErrorPanel(g, output)
}
refreshSidePanels(g, v)
return handleCommitSelect(g, v)
@@ -49,8 +48,7 @@ func handleBranchSelect(g *gocui.Gui, v *gocui.View) error {
return renderString(g, "main", "No branches for this repo")
}
go func() {
- lineNumber := getItemPosition(v)
- branch := state.Branches[lineNumber]
+ branch := getSelectedBranch(v)
diff, _ := getBranchDiff(branch.Name, branch.BaseBranch)
renderString(g, "main", diff)
}()