diff options
| author | Jeff Carr <[email protected]> | 2025-07-08 17:13:58 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-07-08 17:19:19 -0500 |
| commit | 3588440aed55e81864c1afd2d96d6b037242befd (patch) | |
| tree | 332c7271795599f5b328e6122a5b9620cad37777 /doPatchsets.go | |
| parent | e57f48e64994dabbd5c50173044f7d95f899c663 (diff) | |
add /updatev0.0.7
Diffstat (limited to 'doPatchsets.go')
| -rw-r--r-- | doPatchsets.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/doPatchsets.go b/doPatchsets.go index e696910..90d11c6 100644 --- a/doPatchsets.go +++ b/doPatchsets.go @@ -205,6 +205,7 @@ func lookupRepos(msg []byte) (*gitpb.Repos, error) { } return newpb, nil } + /* save the git.pb files + if repo.Namespace == "" { + log.Infof("repo: ERROR. no namespace. %s\n", repo.FullPath) @@ -237,3 +238,58 @@ func lookupRepos(msg []byte) (*gitpb.Repos, error) { + + log.Infof("repo path: %s\n", repopath) */ + +func updateRepos(msg []byte) (*gitpb.Repos, error) { + log.Info("proto.Unmarshal() try message len", len(msg)) + m := gitpb.NewRepos() + if err := m.Unmarshal(msg); err != nil { + log.Info("gitpb.Repos.Unmarshal() failed. len(msg) =", len(msg), err) + return m, err + } + newpb := gitpb.NewRepos() + log.Info("GOT repos:", len(msg)) + for repo := range m.IterAll() { + log.Infof("repo:%s,%s\n", repo.Namespace, repo.FullPath) + if repo.Namespace == "" { + log.Info("todo: namespace empty for", repo.FullPath) + continue + // return nil, fmt.Errorf("todo: namespace empty for " + repo.FullPath) + } + + // save the git.pb files + repopath := filepath.Join("/home/forge", repo.Namespace) + if !shell.IsDir(repopath) { + if err := os.MkdirAll(repopath, os.ModePerm); err != nil { + log.Warn("mkdir fail", repo.Namespace, err) + continue + } + } + + filename := filepath.Join(repopath, "git.pb") + log.Infof("update repo file %s\n", repopath) + // if !shell.Exists(filename) { + data, err := repo.Marshal() + if err != nil { + log.Info("patchsets.Marshal() to wire failed", err) + continue + } + gitpbf, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) + defer gitpbf.Close() + if err != nil { + log.Info("filename open error:", filename, err) + continue + } + gitpbf.Write(data) + // } + + // log.Infof("repo path: %s\n", repopath) + } + + /* + // print out found git.pb files + for repo := range newpb.IterAll() { + log.Infof("updated repo:%-14s,%s\n", repo.GetMasterVersion(), repo.Namespace) + } + */ + return newpb, nil +} |
