summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-02-11 22:46:27 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-02-11 22:46:27 +1100
commit6430ab6ac9297142416ff4bbf6420161356742c6 (patch)
treecdcb83f01ad23a92dae7f4be69aaaa35a8c6a19a /pkg
parent75ab8ec4d95b96fc9b8182154910609832265c3b (diff)
parente09f3905e962be254bffb9736f88799e61fa5fcf (diff)
Merge branch 'master' into feature/rebasing
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/exec_live_default.go2
-rw-r--r--pkg/commands/git.go7
-rw-r--r--pkg/commands/os.go18
-rw-r--r--pkg/commands/pull_request.go3
-rw-r--r--pkg/git/patch_modifier.go3
-rw-r--r--pkg/gui/commits_panel.go3
-rw-r--r--pkg/gui/gui.go7
-rw-r--r--pkg/gui/options_menu_panel.go2
-rw-r--r--pkg/gui/staging_panel.go2
-rw-r--r--pkg/test/test.go2
-rw-r--r--pkg/updates/updates.go3
-rw-r--r--pkg/utils/utils.go3
-rw-r--r--pkg/utils/utils_test.go37
13 files changed, 56 insertions, 36 deletions
diff --git a/pkg/commands/exec_live_default.go b/pkg/commands/exec_live_default.go
index dfdff5308..2d0b78c21 100644
--- a/pkg/commands/exec_live_default.go
+++ b/pkg/commands/exec_live_default.go
@@ -5,7 +5,7 @@ package commands
import (
"bufio"
"bytes"
- "errors"
+ "github.com/go-errors/errors"
"os"
"os/exec"
"strings"
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 4858aa85c..9182c4441 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -1,7 +1,6 @@
package commands
import (
- "errors"
"fmt"
"io/ioutil"
"os"
@@ -11,6 +10,8 @@ import (
"strings"
"github.com/fatih/color"
+ "github.com/go-errors/errors"
+
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/sirupsen/logrus"
@@ -31,11 +32,11 @@ func navigateToRepoRootDirectory(stat func(string) (os.FileInfo, error), chdir f
}
if !os.IsNotExist(err) {
- return err
+ return errors.Wrap(err, 0)
}
if err = chdir(".."); err != nil {
- return err
+ return errors.Wrap(err, 0)
}
}
}
diff --git a/pkg/commands/os.go b/pkg/commands/os.go
index 186887b5d..a1f936dc1 100644
--- a/pkg/commands/os.go
+++ b/pkg/commands/os.go
@@ -1,13 +1,14 @@
package commands
import (
- "errors"
"io/ioutil"
"os"
"os/exec"
"regexp"
"strings"
+ "github.com/go-errors/errors"
+
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/mgutz/str"
@@ -122,7 +123,7 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
// errors like 'exit status 1' are not very useful so we'll create an error
// from the combined output
if outputString == "" {
- return "", err
+ return "", errors.Wrap(err, 0)
}
return outputString, errors.New(outputString)
}
@@ -201,12 +202,12 @@ func (c *OSCommand) Unquote(message string) string {
func (c *OSCommand) AppendLineToFile(filename, line string) error {
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
- return err
+ return errors.Wrap(err, 0)
}
defer f.Close()
_, err = f.WriteString("\n" + line)
- return err
+ return errors.Wrap(err, 0)
}
// CreateTempFile writes a string to a new temp file and returns the file's name
@@ -214,16 +215,16 @@ func (c *OSCommand) CreateTempFile(filename, content string) (string, error) {
tmpfile, err := ioutil.TempFile("", filename)
if err != nil {
c.Log.Error(err)
- return "", err
+ return "", errors.Wrap(err, 0)
}
if _, err := tmpfile.WriteString(content); err != nil {
c.Log.Error(err)
- return "", err
+ return "", errors.Wrap(err, 0)
}
if err := tmpfile.Close(); err != nil {
c.Log.Error(err)
- return "", err
+ return "", errors.Wrap(err, 0)
}
return tmpfile.Name(), nil
@@ -231,7 +232,8 @@ func (c *OSCommand) CreateTempFile(filename, content string) (string, error) {
// RemoveFile removes a file at the specified path
func (c *OSCommand) RemoveFile(filename string) error {
- return os.Remove(filename)
+ err := os.Remove(filename)
+ return errors.Wrap(err, 0)
}
// FileExists checks whether a file exists at the specified path
diff --git a/pkg/commands/pull_request.go b/pkg/commands/pull_request.go
index 043a3c07d..7f0a55334 100644
--- a/pkg/commands/pull_request.go
+++ b/pkg/commands/pull_request.go
@@ -1,9 +1,10 @@
package commands
import (
- "errors"
"fmt"
"strings"
+
+ "github.com/go-errors/errors"
)
// Service is a service that repository is on (Github, Bitbucket, ...)
diff --git a/pkg/git/patch_modifier.go b/pkg/git/patch_modifier.go
index 3c523232e..f27040775 100644
--- a/pkg/git/patch_modifier.go
+++ b/pkg/git/patch_modifier.go
@@ -1,11 +1,12 @@
package git
import (
- "errors"
"regexp"
"strconv"
"strings"
+ "github.com/go-errors/errors"
+
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/sirupsen/logrus"
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 53e979ac4..0c557b15d 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -1,9 +1,10 @@
package gui
import (
- "errors"
"fmt"
+ "github.com/go-errors/errors"
+
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/utils"
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 28ecdaebe..70b39529b 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -6,7 +6,6 @@ import (
// "io"
// "io/ioutil"
- "errors"
"io/ioutil"
"log"
"os"
@@ -14,6 +13,8 @@ import (
"strings"
"time"
+ "github.com/go-errors/errors"
+
// "strings"
"github.com/fatih/color"
@@ -587,7 +588,9 @@ func (gui *Gui) RunWithSubprocesses() {
gui.SubProcess.Stdin = nil
gui.SubProcess = nil
} else {
- log.Panicln(err)
+ newErr := errors.Wrap(err, 0)
+ stackTrace := newErr.ErrorStack()
+ log.Panicln(stackTrace)
}
}
}
diff --git a/pkg/gui/options_menu_panel.go b/pkg/gui/options_menu_panel.go
index f7019ed8e..307ac5700 100644
--- a/pkg/gui/options_menu_panel.go
+++ b/pkg/gui/options_menu_panel.go
@@ -4,6 +4,8 @@ import (
"errors"
"strings"
+ "github.com/go-errors/errors"
+
"github.com/jesseduffield/gocui"
)
diff --git a/pkg/gui/staging_panel.go b/pkg/gui/staging_panel.go
index 777da08c2..099dd5da8 100644
--- a/pkg/gui/staging_panel.go
+++ b/pkg/gui/staging_panel.go
@@ -1,7 +1,7 @@
package gui
import (
- "errors"
+ "github.com/go-errors/errors"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/git"
diff --git a/pkg/test/test.go b/pkg/test/test.go
index 6346ac556..b3db699d0 100644
--- a/pkg/test/test.go
+++ b/pkg/test/test.go
@@ -1,7 +1,7 @@
package test
import (
- "errors"
+ "github.com/go-errors/errors"
"os"
"os/exec"
"path/filepath"
diff --git a/pkg/updates/updates.go b/pkg/updates/updates.go
index a08a2edcc..a4ec67e27 100644
--- a/pkg/updates/updates.go
+++ b/pkg/updates/updates.go
@@ -2,7 +2,6 @@ package updates
import (
"encoding/json"
- "errors"
"fmt"
"io/ioutil"
"net/http"
@@ -13,6 +12,8 @@ import (
"strings"
"time"
+ "github.com/go-errors/errors"
+
"github.com/kardianos/osext"
getter "github.com/jesseduffield/go-getter"
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
index 390f85f70..60985dd0b 100644
--- a/pkg/utils/utils.go
+++ b/pkg/utils/utils.go
@@ -2,7 +2,6 @@ package utils
import (
"encoding/json"
- "errors"
"fmt"
"log"
"os"
@@ -11,6 +10,8 @@ import (
"strings"
"time"
+ "github.com/go-errors/errors"
+
"github.com/fatih/color"
)
diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go
index f7545f5e9..ee502c1f8 100644
--- a/pkg/utils/utils_test.go
+++ b/pkg/utils/utils_test.go
@@ -1,7 +1,6 @@
package utils
import (
- "errors"
"testing"
"github.com/stretchr/testify/assert"
@@ -233,9 +232,9 @@ func TestGetDisplayStringArrays(t *testing.T) {
// TestRenderDisplayableList is a function.
func TestRenderDisplayableList(t *testing.T) {
type scenario struct {
- input []Displayable
- expectedString string
- expectedError error
+ input []Displayable
+ expectedString string
+ expectedErrorMessage string
}
scenarios := []scenario{
@@ -245,7 +244,7 @@ func TestRenderDisplayableList(t *testing.T) {
Displayable(&myDisplayable{[]string{}}),
},
"\n",
- nil,
+ "",
},
{
[]Displayable{
@@ -253,7 +252,7 @@ func TestRenderDisplayableList(t *testing.T) {
Displayable(&myDisplayable{[]string{"c", "d"}}),
},
"aa b\nc d",
- nil,
+ "",
},
{
[]Displayable{
@@ -261,23 +260,27 @@ func TestRenderDisplayableList(t *testing.T) {
Displayable(&myDisplayable{[]string{"b", "c"}}),
},
"",
- errors.New("Each item must return the same number of strings to display"),
+ "Each item must return the same number of strings to display",
},
}
for _, s := range scenarios {
str, err := renderDisplayableList(s.input)
assert.EqualValues(t, s.expectedString, str)
- assert.EqualValues(t, s.expectedError, err)
+ if s.expectedErrorMessage != "" {
+ assert.EqualError(t, err, s.expectedErrorMessage)
+ } else {
+ assert.NoError(t, err)
+ }
}
}
// TestRenderList is a function.
func TestRenderList(t *testing.T) {
type scenario struct {
- input interface{}
- expectedString string
- expectedError error
+ input interface{}
+ expectedString string
+ expectedErrorMessage string
}
scenarios := []scenario{
@@ -287,7 +290,7 @@ func TestRenderList(t *testing.T) {
{[]string{"c", "d"}},
},
"aa b\nc d",
- nil,
+ "",
},
{
[]*myStruct{
@@ -295,19 +298,23 @@ func TestRenderList(t *testing.T) {
{},
},
"",
- errors.New("item does not implement the Displayable interface"),
+ "item does not implement the Displayable interface",
},
{
&myStruct{},
"",
- errors.New("RenderList given a non-slice type"),
+ "RenderList given a non-slice type",
},
}
for _, s := range scenarios {
str, err := RenderList(s.input)
assert.EqualValues(t, s.expectedString, str)
- assert.EqualValues(t, s.expectedError, err)
+ if s.expectedErrorMessage != "" {
+ assert.EqualError(t, err, s.expectedErrorMessage)
+ } else {
+ assert.NoError(t, err)
+ }
}
}