summaryrefslogtreecommitdiff
path: root/repo.new.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-18 06:11:20 -0500
committerJeff Carr <[email protected]>2025-08-18 06:11:20 -0500
commit1ead02a6d3a76a71853eead2099b65fc320a1a43 (patch)
treea0f10c6106fb8c9f033f884b2f73c020c2a04996 /repo.new.go
parent68af638f9ece1a67075d5022a1361821e0f03b9a (diff)
experiement with ~/.cache/forge/
Diffstat (limited to 'repo.new.go')
-rw-r--r--repo.new.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/repo.new.go b/repo.new.go
index 64cf897..5e3f8b4 100644
--- a/repo.new.go
+++ b/repo.new.go
@@ -68,3 +68,30 @@ func (all *Repos) AppendByGoPath(newr *Repo) bool {
all.Append(newr)
return true
}
+
+func (all *Repos) NewRepo(fullpath string, namespace string) (*Repo, error) {
+ if r := all.FindByFullPath(fullpath); r != nil {
+ log.Info("gitpb.NewRepo() might already have namespace", r.GetNamespace())
+ log.Info("gitpb.NewRepo() already has FullPath", r.FullPath)
+ // already had this gopath
+ return r, errors.New("gitpb.NewRepo() duplicate path " + fullpath)
+ }
+
+ // add a new one here
+ newr := Repo{
+ FullPath: fullpath,
+ Namespace: namespace,
+ }
+ newr.Times = new(GitTimes)
+
+ // everything happens in here
+ newr.Reload()
+
+ if all.AppendByFullPath(&newr) {
+ // worked
+ return &newr, nil
+ }
+
+ // todo: use Repos.Lock()
+ return nil, errors.New("gitpb.NewRepo() append failed " + fullpath)
+}