diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2017-05-05 22:15:17 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2017-05-05 22:15:17 +0200 |
| commit | a54004fbd960e4851f1f249ce0d030cf56b20f1b (patch) | |
| tree | 62189d3fb0ad5205cc5a160a008057a3e21d31d0 /pkg/rtree/remote.go | |
| parent | 22d80eda906d1958dfde5072717a12995ee6df2d (diff) | |
| download | gofu-a54004fbd960e4851f1f249ce0d030cf56b20f1b.tar.gz | |
propagate errors upwards properly
Diffstat (limited to 'pkg/rtree/remote.go')
| -rw-r--r-- | pkg/rtree/remote.go | 18 |
1 files changed, 10 insertions, 8 deletions
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 } |
