forged/doList.go

58 lines
1.3 KiB
Go

package main
import (
"fmt"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
func doList() error {
log.Info("do list here")
if err := loadConfigfile(); err != nil {
badExit(err)
}
for pset := range me.all.IterAll() {
showPatchsets(pset)
}
return nil
}
func showPatchsets(pb *forgepb.Patchset) error {
author := "Author: " + pb.GitAuthorName
author += " <" + pb.GitAuthorEmail + ">"
// author := "Author: " + os.Getenv("GIT_AUTHOR_NAME")
// author += " <" + os.Getenv("GIT_AUTHOR_EMAIL") + ">"
fmt.Println(pb.Name, pb.Comment, author)
for i, patches := range pb.Patches.Patches {
log.Info("\tnew patches:", i, patches.CommitHash, patches.Namespace)
}
/*
for patch := range pb.IterAll() {
comment := cleanSubject(patch.Comment)
log.Info("\tnew patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
}
*/
return nil
}
// returns true if the patch already exists in the protobuf
func findPatch(newpatch *forgepb.Patch) bool {
// log.Info("\tlook for patch:", newpatch.CommitHash, newpatch.Namespace)
for pset := range me.all.IterAll() {
for _, patch := range pset.Patches.Patches {
if patch.CommitHash == newpatch.CommitHash {
// log.Info("\tfound pset!!!!!!", pset.Uuid, patch.Namespace)
return true
}
}
}
return false
}