diff options
Diffstat (limited to 'repo.new.go')
| -rw-r--r-- | repo.new.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/repo.new.go b/repo.new.go index 48c588b..65aa251 100644 --- a/repo.new.go +++ b/repo.new.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "os" "os/exec" "path/filepath" "strings" @@ -117,19 +118,22 @@ func NewRepo(fullpath string) (*Repo, error) { repo.ReloadForce() repo.ValidateUTF8() if repo.Namespace == "" { + wd, _ := os.Getwd() + repo.Namespace = wd + } + + // fall back to URL? + if repo.Namespace == "" { giturl := repo.GetURL() if giturl == "" { log.Info(repo.FullPath, "Namespace & URL are both blank. Warn the user of a local repo.") return &repo, nil } // log.Info("GET Namespace from URL", giturl) - tmpURL, err := ParseGitURL(giturl) - if err != nil { - log.Info(repo.FullPath, "URL can not be parsed for namespace") - return &repo, nil + if tmpURL, err := ParseGitURL(giturl); err == nil { + // log.Info(repo.FullPath, "namespace might be:", tmpURL.Hostname(), tmpURL.Path) + repo.Namespace = filepath.Join(tmpURL.Hostname(), tmpURL.Path) } - // log.Info(repo.FullPath, "namespace might be:", tmpURL.Hostname(), tmpURL.Path) - repo.Namespace = filepath.Join(tmpURL.Hostname(), tmpURL.Path) } return &repo, nil } |
