diff options
| author | Jeff Carr <[email protected]> | 2025-09-11 14:21:37 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-11 14:21:37 -0500 |
| commit | 1d8380b9e781ce7087dbd0d8bead69f11ced7527 (patch) | |
| tree | eba0f2a889c6232368d4118172caa54ac9e71bb4 /repo.new.go | |
| parent | e395456c536b2458563d5e872a73e8667cc08659 (diff) | |
pull out the namespace
Diffstat (limited to 'repo.new.go')
| -rw-r--r-- | repo.new.go | 29 |
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 } |
