aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-13 12:43:47 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-13 12:43:47 +0200
commitfb0f5530f100e8ae3b8561fe5dcfd19edc181b15 (patch)
tree1e7a3d63d4d02e4dab56a0ee58aae5317401e706
parentf569e6aacc0690e7b1bebf33a10a8e0d154937df (diff)
downloadgit-bug-fb0f5530f100e8ae3b8561fe5dcfd19edc181b15.tar.gz
catch a lot of error not being checked
-rw-r--r--bug/clocks.go11
-rw-r--r--commands/root.go4
-rw-r--r--commands/webui.go11
-rw-r--r--termui/input_popup.go5
-rw-r--r--termui/show_bug.go17
-rw-r--r--tests/bug_actions_test.go30
6 files changed, 48 insertions, 30 deletions
diff --git a/bug/clocks.go b/bug/clocks.go
index 5ffa094a..47cd1509 100644
--- a/bug/clocks.go
+++ b/bug/clocks.go
@@ -12,8 +12,15 @@ func Witnesser(repo *repository.GitRepo) error {
return b.Err
}
- repo.CreateWitness(b.Bug.createTime)
- repo.EditWitness(b.Bug.editTime)
+ err := repo.CreateWitness(b.Bug.createTime)
+ if err != nil {
+ return err
+ }
+
+ err = repo.EditWitness(b.Bug.editTime)
+ if err != nil {
+ return err
+ }
}
return nil
diff --git a/commands/root.go b/commands/root.go
index 83722781..9aece1d4 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -28,7 +28,9 @@ It use the same internal storage so it doesn't pollute your project. As you woul
// even if we just display the help. This is to make sure that we check
// the repository and give the user early feedback.
Run: func(cmd *cobra.Command, args []string) {
- cmd.Help()
+ if err := cmd.Help(); err != nil {
+ os.Exit(1)
+ }
},
// Load the repo before any command execution
diff --git a/commands/webui.go b/commands/webui.go
index 66cc2a9d..d64bca53 100644
--- a/commands/webui.go
+++ b/commands/webui.go
@@ -87,7 +87,10 @@ func runWebUI(cmd *cobra.Command, args []string) error {
fmt.Printf("Graphql API: http://%s/graphql\n", addr)
fmt.Printf("Graphql Playground: http://%s/playground\n", addr)
- open.Run(webUiAddr)
+ err = open.Run(webUiAddr)
+ if err != nil {
+ fmt.Println(err)
+ }
err = srv.ListenAndServe()
if err != nil && err != http.ErrServerClosed {
@@ -188,7 +191,11 @@ func (gufh *gitUploadFileHandler) ServeHTTP(rw http.ResponseWriter, r *http.Requ
}
rw.Header().Set("Content-Type", "application/json")
- rw.Write(js)
+ _, err = rw.Write(js)
+ if err != nil {
+ http.Error(rw, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
var webUICmd = &cobra.Command{
diff --git a/termui/input_popup.go b/termui/input_popup.go
index c8299d2a..db0ec619 100644
--- a/termui/input_popup.go
+++ b/termui/input_popup.go
@@ -55,7 +55,10 @@ func (ip *inputPopup) layout(g *gocui.Gui) error {
v.Frame = true
v.Title = ip.title
v.Editable = true
- v.Write([]byte(ip.preload))
+ _, err = v.Write([]byte(ip.preload))
+ if err != nil {
+ return err
+ }
}
if _, err := g.SetCurrentView(inputPopupView); err != nil {
diff --git a/termui/show_bug.go b/termui/show_bug.go
index eb112674..d2e4fc09 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -422,7 +422,10 @@ func (sb *showBug) saveAndBack(g *gocui.Gui, v *gocui.View) error {
if err != nil {
return err
}
- ui.activateWindow(ui.bugTable)
+ err = ui.activateWindow(ui.bugTable)
+ if err != nil {
+ return err
+ }
return nil
}
@@ -468,8 +471,6 @@ func (sb *showBug) scrollDown(g *gocui.Gui, v *gocui.View) error {
}
func (sb *showBug) selectPrevious(g *gocui.Gui, v *gocui.View) error {
- defer sb.focusView(g)
-
var selectable []string
if sb.isOnSide {
selectable = sb.sideSelectableView
@@ -485,7 +486,7 @@ func (sb *showBug) selectPrevious(g *gocui.Gui, v *gocui.View) error {
}
sb.selected = selectable[maxInt(i-1, 0)]
- return nil
+ return sb.focusView(g)
}
}
@@ -493,12 +494,10 @@ func (sb *showBug) selectPrevious(g *gocui.Gui, v *gocui.View) error {
sb.selected = selectable[0]
}
- return nil
+ return sb.focusView(g)
}
func (sb *showBug) selectNext(g *gocui.Gui, v *gocui.View) error {
- defer sb.focusView(g)
-
var selectable []string
if sb.isOnSide {
selectable = sb.sideSelectableView
@@ -509,7 +508,7 @@ func (sb *showBug) selectNext(g *gocui.Gui, v *gocui.View) error {
for i, name := range selectable {
if name == sb.selected {
sb.selected = selectable[minInt(i+1, len(selectable)-1)]
- return nil
+ return sb.focusView(g)
}
}
@@ -517,7 +516,7 @@ func (sb *showBug) selectNext(g *gocui.Gui, v *gocui.View) error {
sb.selected = selectable[0]
}
- return nil
+ return sb.focusView(g)
}
func (sb *showBug) left(g *gocui.Gui, v *gocui.View) error {
diff --git a/tests/bug_actions_test.go b/tests/bug_actions_test.go
index 19359e33..b8720842 100644
--- a/tests/bug_actions_test.go
+++ b/tests/bug_actions_test.go
@@ -73,7 +73,7 @@ func TestPushPull(t *testing.T) {
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
// A --> remote --> B
@@ -92,7 +92,7 @@ func TestPushPull(t *testing.T) {
// B --> remote --> A
bug2, err := operations.Create(rene, "bug2", "message")
checkErr(t, err)
- bug2.Commit(repoB)
+ err = bug2.Commit(repoB)
checkErr(t, err)
_, err = bug.Push(repoB, "origin")
@@ -141,7 +141,7 @@ func _RebaseTheirs(t testing.TB) {
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
// A --> remote
@@ -158,7 +158,7 @@ func _RebaseTheirs(t testing.TB) {
operations.Comment(bug2, rene, "message2")
operations.Comment(bug2, rene, "message3")
operations.Comment(bug2, rene, "message4")
- bug2.Commit(repoB)
+ err = bug2.Commit(repoB)
checkErr(t, err)
// B --> remote
@@ -199,7 +199,7 @@ func _RebaseOurs(t testing.TB) {
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
// A --> remote
@@ -213,19 +213,19 @@ func _RebaseOurs(t testing.TB) {
operations.Comment(bug1, rene, "message2")
operations.Comment(bug1, rene, "message3")
operations.Comment(bug1, rene, "message4")
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
operations.Comment(bug1, rene, "message5")
operations.Comment(bug1, rene, "message6")
operations.Comment(bug1, rene, "message7")
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
operations.Comment(bug1, rene, "message8")
operations.Comment(bug1, rene, "message9")
operations.Comment(bug1, rene, "message10")
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
// remote --> A
@@ -271,7 +271,7 @@ func _RebaseConflict(t testing.TB) {
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
// A --> remote
@@ -285,19 +285,19 @@ func _RebaseConflict(t testing.TB) {
operations.Comment(bug1, rene, "message2")
operations.Comment(bug1, rene, "message3")
operations.Comment(bug1, rene, "message4")
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
operations.Comment(bug1, rene, "message5")
operations.Comment(bug1, rene, "message6")
operations.Comment(bug1, rene, "message7")
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
operations.Comment(bug1, rene, "message8")
operations.Comment(bug1, rene, "message9")
operations.Comment(bug1, rene, "message10")
- bug1.Commit(repoA)
+ err = bug1.Commit(repoA)
checkErr(t, err)
bug2, err := bug.ReadLocalBug(repoB, bug1.Id())
@@ -306,19 +306,19 @@ func _RebaseConflict(t testing.TB) {
operations.Comment(bug2, rene, "message11")
operations.Comment(bug2, rene, "message12")
operations.Comment(bug2, rene, "message13")
- bug2.Commit(repoB)
+ err = bug2.Commit(repoB)
checkErr(t, err)
operations.Comment(bug2, rene, "message14")
operations.Comment(bug2, rene, "message15")
operations.Comment(bug2, rene, "message16")
- bug2.Commit(repoB)
+ err = bug2.Commit(repoB)
checkErr(t, err)
operations.Comment(bug2, rene, "message17")
operations.Comment(bug2, rene, "message18")
operations.Comment(bug2, rene, "message19")
- bug2.Commit(repoB)
+ err = bug2.Commit(repoB)
checkErr(t, err)
// A --> remote