diff options
Diffstat (limited to 'patchset.Make.go')
| -rw-r--r-- | patchset.Make.go | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/patchset.Make.go b/patchset.Make.go index fe8df83..75c4215 100644 --- a/patchset.Make.go +++ b/patchset.Make.go @@ -11,6 +11,7 @@ import ( "time" "github.com/google/uuid" + "go.wit.com/lib/hostname" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/httppb" "go.wit.com/log" @@ -22,6 +23,11 @@ func (p *Patches) HttpPostVerbose(baseURL string, route string) (*Patches, *http return p.HttpPost(baseURL, route) } +func (p *Set) HttpPostVerbose(baseURL string, route string) (*Set, *httppb.HttpRequest, error) { + p.PrintTable() + return p.HttpPost(baseURL, route) +} + func (p *Sets) HttpPostVerbose(baseURL string, route string) (*Sets, *httppb.HttpRequest, error) { p.PrintTable() return p.HttpPost(baseURL, route) @@ -32,7 +38,8 @@ func newPatchset(name string) *Set { pset.Name = name pset.Ctime = timestamppb.New(time.Now()) pset.Uuid = uuid.New().String() - pset.Hostname, _ = os.Hostname() + pset.Hostname, _ = hostname.Get() + pset.Patches = NewPatches() return pset } @@ -56,7 +63,7 @@ func (f *Forge) MakeDevelPatchSet(name string) (*Set, error) { if err != nil { return nil, err } - defer os.RemoveAll(dir) // clean up + // defer os.RemoveAll(dir) // clean up pset.TmpDir = dir all := f.Repos.SortByFullPath() @@ -72,6 +79,10 @@ func (f *Forge) MakeDevelPatchSet(name string) (*Set, error) { continue } + if repo.ActualGetDevelHash() == repo.ActualGetUserHash() { + continue + } + // make a patchset from user to devel // TODO: verify branches are otherwise exact pset.StartBranchName = repo.GetDevelBranchName() @@ -122,24 +133,23 @@ func (pset *Set) makePatchSetNew(repo *gitpb.Repo) error { return errors.New(fmt.Sprintf("git returned %d", r.Exit)) } if len(r.Stdout) == 0 { + log.Infof("No patches in %s (%s,%s)\n", repo.FullPath, repo.ActualGetDevelHash(), repo.ActualGetUserHash()) // git created no files to add return nil } - err = pset.addPatchFiles(repo) - pset.Ctime = timestamppb.New(time.Now()) + err = pset.addPatchFiles(repo, repoDir) + log.Infof("Added %d patches for %s len=%d\n", len(r.Stdout), repo.FullPath, pset.Patches.Len()) + pset.PrintTable() return err } // git show <original_commit_hash> | git patch-id // git cat-file -p <commit_hash> | grep tree // process each file in pDir/ -func (p *Set) addPatchFiles(repo *gitpb.Repo) error { - psetDir := repo.GetGoPath() - tmpDir := p.TmpDir - // log.Info("ADD PATCH FILES ADDED DIR", tmpDir) - fullDir := filepath.Join(tmpDir, psetDir) +func (p *Set) addPatchFiles(repo *gitpb.Repo, fullDir string) error { var baderr error + // log.Info("ADD PATCH FILES ADDED DIR", fullDir) filepath.Walk(fullDir, func(path string, info os.FileInfo, err error) error { if err != nil { // Handle possible errors, like permission issues @@ -161,20 +171,22 @@ func (p *Set) addPatchFiles(repo *gitpb.Repo) error { patch.Filename, _ = filepath.Rel(p.TmpDir, path) patch.Data = data if err := patch.parseData(); err != nil { + log.Info("parseData() failed", err) return err } if err := findPatchId(repo, patch); err != nil { + log.Info("findPatchId() failed", err) return err } patch.StartHash = repo.ActualDevelHash() patch.NewHash = "na" patch.Namespace = repo.GetGoPath() if p.Patches == nil { + log.Info("SHOULD NOT HAVE HAPPENED. p.Patches == nil") p.Patches = new(Patches) } p.Patches.Append(patch) - p.Patches.Uuid = uuid.New().String() - // log.Info("ADDED PATCH FILE", path) + log.Info("ADDED PATCH FILE", path) return nil }) return baderr @@ -272,7 +284,7 @@ func findPatchId(repo *gitpb.Repo, p *Patch) error { return fmt.Errorf("git-patch-id produced empty output") } - if fields[0] != p.CommitHash { + if fields[1] != p.CommitHash { return fmt.Errorf("patchid did not match %s != %v", p.CommitHash, fields) } |
