experiement with ~/.cache/forge/

This commit is contained in:
Jeff Carr 2025-08-18 06:11:20 -05:00
parent 68af638f9e
commit 1ead02a6d3
2 changed files with 38 additions and 1 deletions

View File

@ -138,8 +138,18 @@ func (repo *Repo) readGitConfig() error {
default:
log.Log(WARN, "unknown submodule line:", line)
}
case "user":
// test, ok := rs.gitConfig.submodules[currentName]
switch key {
case "name":
log.Log(INFO, "name:", line)
case "email":
log.Log(INFO, "email:", line)
default:
log.Log(WARN, "unknown name line:", filename, line)
}
default:
log.Log(WARN, "unknown line:", line)
log.Log(WARN, "unknown line:", filename, line)
}
}

View File

@ -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)
}