summaryrefslogtreecommitdiff
path: root/repo.new.go
diff options
context:
space:
mode:
Diffstat (limited to 'repo.new.go')
-rw-r--r--repo.new.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/repo.new.go b/repo.new.go
index c48fde7..bd8af6a 100644
--- a/repo.new.go
+++ b/repo.new.go
@@ -2,6 +2,8 @@ package gitpb
import (
"errors"
+ "net/url"
+ "path/filepath"
"go.wit.com/log"
)
@@ -103,16 +105,29 @@ func (all *Repos) NewRepo(fullpath string, namespace string) (*Repo, error) {
func NewRepo(fullpath string) (*Repo, error) {
// add a new one here
- newr := Repo{
+ repo := Repo{
FullPath: fullpath,
}
- newr.Times = new(GitTimes)
+ repo.Times = new(GitTimes)
// everything happens in here
- newr.Reload()
- newr.ValidateUTF8()
- if newr.Namespace == "" {
- log.Info("GET Namespace from URL", newr.GetURL())
+ repo.Reload()
+ repo.ValidateUTF8()
+ 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 := url.Parse(giturl)
+ if err != nil {
+ log.Info(repo.FullPath, "URL parse failed", giturl, err)
+ return &repo, nil
+ }
+ // log.Info(repo.FullPath, "namespace might be:", tmpURL.Hostname(), tmpURL.Path)
+ repo.Namespace = filepath.Join(tmpURL.Hostname(), tmpURL.Path)
+ // log.Info(repo.FullPath, "Namesapce =", repo.Namespace)
}
- return &newr, nil
+ return &repo, nil
}