summaryrefslogtreecommitdiff
path: root/pkg/rtree/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/rtree/repo.go')
-rw-r--r--pkg/rtree/repo.go27
1 files changed, 5 insertions, 22 deletions
diff --git a/pkg/rtree/repo.go b/pkg/rtree/repo.go
index 12f087f..12afee0 100644
--- a/pkg/rtree/repo.go
+++ b/pkg/rtree/repo.go
@@ -27,8 +27,6 @@ import (
"path/filepath"
"regexp"
"strings"
-
- "github.com/majewsky/gofu/pkg/util"
)
//RootPath is the directory below which all repositories are located. Its value
@@ -38,7 +36,7 @@ var RootPath string
func init() {
gopath := os.Getenv("GOPATH")
if gopath == "" {
- util.FatalIfError(errors.New("$GOPATH is not set (rtree needs the GOPATH variable to know where to look for and place repos)"))
+ panic(errors.New("$GOPATH is not set (rtree needs the GOPATH variable to know where to look for and place repos)"))
}
RootPath = filepath.Join(gopath, "src")
}
@@ -97,16 +95,17 @@ func NewRepoFromAbsolutePath(path string) (repo Repo, err error) {
//NewRepoFromRemoteURL initializes a Repo instance for checking out a remote
//for the first time. The checkout does not happen until Checkout() is called.
-func NewRepoFromRemoteURL(remoteURL string) Repo {
+func NewRepoFromRemoteURL(remoteURL string) (Repo, error) {
+ checkoutPath, err := CheckoutPathForRemoteURL(ExpandRemoteURL(remoteURL))
return Repo{
- CheckoutPath: CheckoutPathForRemoteURL(ExpandRemoteURL(remoteURL)),
+ CheckoutPath: checkoutPath,
Remotes: []Remote{
{
Name: "origin",
URL: remoteURL,
},
},
- }
+ }, err
}
var remoteConfigRx = regexp.MustCompile(`remote\.([^=]+)\.url=(.+)`)
@@ -141,22 +140,6 @@ func ForeachPhysicalRepo(action func(repo Repo) error) error {
})
}
-//ExistsOnDisk returns true if the top directory of this repo exists.
-func (r Repo) ExistsOnDisk() bool {
- path := r.AbsolutePath()
- fi, err := os.Stat(path)
- if err == nil {
- if !fi.IsDir() {
- util.FatalIfError(fmt.Errorf("expected %s to be a directory, but it is not", path))
- }
- return true
- }
- if !os.IsNotExist(err) {
- util.FatalIfError(err)
- }
- return false
-}
-
//Checkout creates the repo in the given path with the given remotes. The
//working copy will only be initialized if there is an "origin" remote.
func (r Repo) Checkout() error {