From a54004fbd960e4851f1f249ce0d030cf56b20f1b Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 5 May 2017 22:15:17 +0200 Subject: propagate errors upwards properly --- pkg/rtree/remote.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'pkg/rtree/remote.go') diff --git a/pkg/rtree/remote.go b/pkg/rtree/remote.go index a2a2ab3..380fc80 100644 --- a/pkg/rtree/remote.go +++ b/pkg/rtree/remote.go @@ -25,8 +25,6 @@ import ( "path/filepath" "regexp" "strings" - - "github.com/majewsky/gofu/pkg/util" ) //remoteAlias describes an alias that can be used in a Git remote URL (as @@ -42,7 +40,10 @@ func init() { cmd := exec.Command("git", "config", "--global", "-l") var buf bytes.Buffer cmd.Stdout = &buf - util.FatalIfError(cmd.Run()) + err := cmd.Run() + if err != nil { + panic(err) + } rx := regexp.MustCompile(`^url\.([^=]+)\.insteadof=(.+)$`) for _, line := range strings.Split(string(buf.Bytes()), "\n") { @@ -92,15 +93,16 @@ var scpSyntaxRx = regexp.MustCompile(`^(?:[^/@:]+@)?([^/:]+\.[^/:]+):(.+)$`) // "https://example.org/foo/bar" -> "example.org/foo/bar" // "git@example.org:foo/bar" -> "example.org/foo/bar" // -func CheckoutPathForRemoteURL(remoteURL string) string { +func CheckoutPathForRemoteURL(remoteURL string) (string, error) { match := scpSyntaxRx.FindStringSubmatch(remoteURL) if match != nil { //match[1] is the hostname, match[2] is the path to the repo - return filepath.Join(match[1], match[2]) + return filepath.Join(match[1], match[2]), nil } u, err := url.Parse(remoteURL) - util.FatalIfError(err) - - return filepath.Join(u.Hostname(), u.Path) + if err != nil { + return "", err + } + return filepath.Join(u.Hostname(), u.Path), nil } -- cgit v1.3.1