cleaning up .git/config parsing

This commit is contained in:
Jeff Carr 2025-09-11 13:40:48 -05:00
parent cb60421374
commit e395456c53
3 changed files with 16 additions and 1 deletions

View File

@ -15,7 +15,6 @@ message GitBranch { // `autogenpb:nomutex`
string name = 3; // the branch name from the config file
}
// readGitConfig reads and parses the .git/config file
message GitConfig { // `autogenpb:nomutex`
map<string, string> core = 1; // map[origin] = "https:/git.wit.org/gui/gadgets"
map<string, GitRemote> remotes = 2; // map[origin] = "https:/git.wit.org/gui/gadgets"

View File

@ -100,3 +100,19 @@ func (all *Repos) NewRepo(fullpath string, namespace string) (*Repo, error) {
// todo: use Repos.Lock()
return nil, errors.New("gitpb.NewRepo() append failed " + fullpath)
}
func NewRepo(fullpath string) (*Repo, error) {
// add a new one here
newr := Repo{
FullPath: fullpath,
}
newr.Times = new(GitTimes)
// everything happens in here
newr.Reload()
newr.ValidateUTF8()
if newr.Namespace == "" {
log.Info("GET Namespace from URL", newr.GetURL())
}
return &newr, nil
}