add a date and a uuid to the patchset

This commit is contained in:
Jeff Carr 2025-02-02 13:31:05 -06:00
parent ab01c2cd60
commit 9baa477990
2 changed files with 10 additions and 1 deletions

View File

@ -6,9 +6,12 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"github.com/google/uuid"
"go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
) )
// creates a patchset // creates a patchset
@ -16,6 +19,8 @@ import (
func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) { func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) {
pset := new(Patchset) pset := new(Patchset)
pset.Name = name pset.Name = name
pset.Ctime = timestamppb.New(time.Now())
pset.Uuid = uuid.New().String()
if os.Getenv("GIT_AUTHOR_NAME") == "" { if os.Getenv("GIT_AUTHOR_NAME") == "" {
return nil, fmt.Errorf("GIT_AUTHOR_NAME not set") return nil, fmt.Errorf("GIT_AUTHOR_NAME not set")
} else { } else {
@ -142,7 +147,9 @@ func (pset *Patchset) makePatchSetNew(repo *gitpb.Repo) error {
return nil return nil
} }
return pset.addPatchFiles(repo) err = pset.addPatchFiles(repo)
pset.Ctime = timestamppb.New(time.Now())
return err
} }
// process each file in pDir/ // process each file in pDir/
@ -184,6 +191,7 @@ func (p *Patchset) addPatchFiles(repo *gitpb.Repo) error {
p.Patches = new(Patches) p.Patches = new(Patches)
} }
p.Patches.Append(patch) 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 nil
}) })

View File

@ -38,6 +38,7 @@ message Patchset { // `autogenpb:mars
string startBranchHash = 10; // string startBranchHash = 10; //
string endBranchHash = 11; // string endBranchHash = 11; //
string state = 12; // the state of the patch string state = 12; // the state of the patch
string uuid = 13; // identify each patchset somehow
} }
message Patchsets { // `autogenpb:marshal` message Patchsets { // `autogenpb:marshal`