summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--humanTable.go70
-rw-r--r--init.go2
-rw-r--r--patch.proto69
-rw-r--r--patchset.Make.go12
-rw-r--r--patchset.config.go25
-rw-r--r--patchset.new.go6
-rw-r--r--patchset.proto92
-rw-r--r--set.proto32
-rw-r--r--structs.go2
10 files changed, 169 insertions, 153 deletions
diff --git a/Makefile b/Makefile
index 0479cf4..c9403cc 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
# go install
-all: forgeConfig.pb.go patchset.pb.go goimports vet
+all: forgeConfig.pb.go patch.pb.go set.pb.go goimports vet
generate: clean
autogenpb --proto patchset.proto
@@ -27,8 +27,14 @@ clean:
forgeConfig.pb.go: forgeConfig.proto
autogenpb --proto forgeConfig.proto
-patchset.pb.go: patchset.proto
- autogenpb --proto patchset.proto
+# patchset.pb.go: patchset.proto
+# autogenpb --proto patchset.proto
+
+patch.pb.go: patch.proto
+ autogenpb --proto patch.proto
+
+set.pb.go: set.proto
+ autogenpb --proto set.proto
protoc-test:
cd ~/go/src && protoc \
diff --git a/humanTable.go b/humanTable.go
index 8ececc2..2bbeda7 100644
--- a/humanTable.go
+++ b/humanTable.go
@@ -246,7 +246,7 @@ func (f *Forge) printForgedToTable(repo *gitpb.Repo, sizes []int) {
log.Info(cobol.TerminalChomp(start + " " + end))
}
-func (psets *Patchsets) PrintTable() {
+func (psets *Sets) PrintTable() {
if psets == nil {
return
}
@@ -257,29 +257,31 @@ func (psets *Patchsets) PrintTable() {
sizes := []int{12, 12, 3, 3, 40, 80, 2, 2, 2, 2}
log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args)))
- var countCONTENTS int
- var countPARTS int
- for x, pset := range psets.GetPatchsets() {
- log.Info(pset.Uuid, pset.Name, pset.State)
- if pset.State == "DONE" {
- // old patchset
- continue
- }
- cId := log.Sprintf("%d", x)
- countCONTENTS += 1
- for i, p := range pset.Patches.GetPatches() {
- var args []string
- partId := log.Sprintf("%d", i)
+ /*
+ var countCONTENTS int
+ var countPARTS int
+ for x, pset := range psets.GetSets() {
+ log.Info(pset.Patches.Uuid, pset.Patches.Name, pset.Patches.State)
+ if pset.State == "DONE" {
+ // old patchset
+ continue
+ }
+ cId := log.Sprintf("%d", x)
+ countCONTENTS += 1
+ for i, p := range pset.Patches.GetPatches() {
+ var args []string
+ partId := log.Sprintf("%d", i)
- _, fname := filepath.Split(p.GetFilename())
- args = []string{p.CommitHash, p.NewHash, cId, partId, fname, p.GetNamespace(), "", "", "", "", ""}
+ _, fname := filepath.Split(p.GetFilename())
+ args = []string{p.CommitHash, p.NewHash, cId, partId, fname, p.GetNamespace(), "", "", "", "", ""}
- start := cobol.StandardTableSize10(sizes, args)
- log.Info(cobol.TerminalChomp(start))
- countPARTS += 1
- }
- }
- log.Infof("Total Contents (%d) Parts (%d)\n", countCONTENTS, countPARTS)
+ start := cobol.StandardTableSize10(sizes, args)
+ log.Info(cobol.TerminalChomp(start))
+ countPARTS += 1
+ }
+ }
+ log.Infof("Total Contents (%d) Parts (%d)\n", countCONTENTS, countPARTS)
+ */
}
func (patches *Patches) PrintTable() {
@@ -293,17 +295,19 @@ func (patches *Patches) PrintTable() {
sizes := []int{12, 12, 3, 3, 40, 80, 2, 2, 2, 2}
log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args)))
- var countPARTS int
- for x, p := range patches.GetPatches() {
- var args []string
- partId := log.Sprintf("%d", x)
+ /*
+ var countPARTS int
+ for x, p := range patches.GetPatches() {
+ var args []string
+ partId := log.Sprintf("%d", x)
- _, fname := filepath.Split(p.GetFilename())
- args = []string{p.CommitHash, p.NewHash, partId, fname, p.GetNamespace(), "", "", "", "", ""}
+ _, fname := filepath.Split(p.GetFilename())
+ args = []string{p.CommitHash, p.NewHash, partId, fname, p.GetNamespace(), "", "", "", "", ""}
- start := cobol.StandardTableSize10(sizes, args)
- log.Info(cobol.TerminalChomp(start))
- countPARTS += 1
- }
- log.Infof("Total Patches (%d)\n", countPARTS)
+ start := cobol.StandardTableSize10(sizes, args)
+ log.Info(cobol.TerminalChomp(start))
+ countPARTS += 1
+ }
+ log.Infof("Total Patches (%d)\n", countPARTS)
+ */
}
diff --git a/init.go b/init.go
index 0b9b2f0..a29ecac 100644
--- a/init.go
+++ b/init.go
@@ -92,7 +92,7 @@ func (f *Forge) initFromConfig() {
f.Repos.ConfigLoad(f.Config.ReposPB)
// init the Patchsets
- f.Patchsets = NewPatchsets()
+ f.Patchsets = NewSets()
// todo: play with these / determine good values based on user's machine
if f.Config.RillX == 0 {
diff --git a/patch.proto b/patch.proto
new file mode 100644
index 0000000..42c0ef3
--- /dev/null
+++ b/patch.proto
@@ -0,0 +1,69 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+syntax = "proto3";
+
+package forgepb;
+
+import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
+
+// Forge doesn't need this kind of specificity
+// but this is what the patch files contain and how git sees them
+// message Blob {
+// string hunkLine = 1;
+// bytes data = 2;
+// }
+//
+// message File {
+// string filename = 1;
+// string hashLine = 2;
+// repeated Blob Blobs = 3;
+// }
+//
+// message Patch {
+// repeated File Files = 1;
+// string repoNamespace = 2;
+// string gH = 3;
+// string gaI = 4;
+// string gcI = 5;
+// }
+
+// git log -1 --format="%H %aI %cI %an %ae %cn %ce"
+
+message Patch {
+ string namespace = 1; // the base repo git namespace
+ bytes data = 2; // the raw data of the whole patch
+ string gH = 3; // Commit Hash (%H)
+ string gT = 4; // Tree Hash (%T)
+ string gP = 5; // Parent Hashes (%P)
+ string gs = 6; // Subject (%s)
+ string gaI = 7; // Author Date, ISO 8601 format (%aI)
+ string gan = 8; // Author Name (%an)
+ string gae = 9; // Author Email (%ae)
+ string gcI = 10; // Committer Date, ISO 8601 format (%cI)
+ string gcn = 11; // Committer Name (%cn)
+ string gce = 12; // Committer Email (%ce)
+ string gN = 13; // Commit Notes (%N)
+ string gGG = 14; // GPG Signature, raw (%GG)
+ string gGS = 15; // GPG Signer Name (%GS)
+ string gGK = 16; // GPG Key ID (%GK)
+ string newHash = 17; // new hash
+ string state = 18; // the 'state' of the patch
+ string filename = 19; // `autogenpb:unique` `autogenpb:sort`
+ string startHash = 20; // the start commit hash
+ string commitHash = 21; // the git commit hash of this patch `autogenpb:sort` `autogenpb:unique`
+ string comment = 22; // the git commit message (in patch form)
+ repeated string Files = 23; // the filenames this patch changes
+ google.protobuf.Timestamp ctime = 24; // create time of the patch
+ bool applied = 25; // have you applied this patch?
+ bool upstream = 26; // has this patch been applied upstream?
+ string patchId = 27; // patchId
+ string treeHash = 28; // final tree Hash
+}
+
+// this is a "PATCH: [1/x]" series
+message Patches { // `autogenpb:marshal` `autogenpb:gui:Patch` `autogenpb:http autogenpb:var:Patches`
+ string uuid = 1; // `autogenpb:uuid:2679065e-c81d-4a00-aca4-03c158a834fb`
+ string version = 2; // `autogenpb:version:v2.0.0`
+ repeated Patch patches = 3;
+ string Error = 4; // when passing these around, if there is an error, store it here
+}
diff --git a/patchset.Make.go b/patchset.Make.go
index 33a9207..fe8df83 100644
--- a/patchset.Make.go
+++ b/patchset.Make.go
@@ -22,13 +22,13 @@ func (p *Patches) HttpPostVerbose(baseURL string, route string) (*Patches, *http
return p.HttpPost(baseURL, route)
}
-func (p *Patchsets) HttpPostVerbose(baseURL string, route string) (*Patchsets, *httppb.HttpRequest, error) {
+func (p *Sets) HttpPostVerbose(baseURL string, route string) (*Sets, *httppb.HttpRequest, error) {
p.PrintTable()
return p.HttpPost(baseURL, route)
}
-func newPatchset(name string) *Patchset {
- pset := new(Patchset)
+func newPatchset(name string) *Set {
+ pset := new(Set)
pset.Name = name
pset.Ctime = timestamppb.New(time.Now())
pset.Uuid = uuid.New().String()
@@ -39,7 +39,7 @@ func newPatchset(name string) *Patchset {
// creates a patchset
// works from the user branches against the devel branches
-func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) {
+func (f *Forge) MakeDevelPatchSet(name string) (*Set, error) {
pset := newPatchset(name)
if os.Getenv("GIT_AUTHOR_NAME") == "" {
return nil, fmt.Errorf("GIT_AUTHOR_NAME not set")
@@ -85,7 +85,7 @@ func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) {
return pset, nil
}
-func (pset *Patchset) makePatchSetNew(repo *gitpb.Repo) error {
+func (pset *Set) makePatchSetNew(repo *gitpb.Repo) error {
startBranch := pset.StartBranchName
endBranch := pset.EndBranchName
repoDir := filepath.Join(pset.TmpDir, repo.GetGoPath())
@@ -134,7 +134,7 @@ func (pset *Patchset) makePatchSetNew(repo *gitpb.Repo) error {
// git show <original_commit_hash> | git patch-id
// git cat-file -p <commit_hash> | grep tree
// process each file in pDir/
-func (p *Patchset) addPatchFiles(repo *gitpb.Repo) error {
+func (p *Set) addPatchFiles(repo *gitpb.Repo) error {
psetDir := repo.GetGoPath()
tmpDir := p.TmpDir
// log.Info("ADD PATCH FILES ADDED DIR", tmpDir)
diff --git a/patchset.config.go b/patchset.config.go
index a156521..3762d55 100644
--- a/patchset.config.go
+++ b/patchset.config.go
@@ -14,7 +14,7 @@ import (
)
func (f *Forge) LoadPatchsets() error {
- f.Patchsets = NewPatchsets()
+ f.Patchsets = NewSets()
filename := filepath.Join(f.Config.PatchDir, "all-patches.pb")
@@ -39,7 +39,7 @@ func (f *Forge) InitPatchsets() error {
log.Info("LoadPatchsets() failed", err)
}
// TODO: check if Unmarshal failed here
- f.Patchsets = NewPatchsets()
+ f.Patchsets = NewSets()
f.findAutoPatchset() // adds the default values
return f.SavePatchsets()
}
@@ -54,7 +54,7 @@ func (f *Forge) SavePatchsets() error {
}
defer regfile.Close()
- newpb := proto.Clone(f.Patchsets).(*Patchsets)
+ newpb := proto.Clone(f.Patchsets).(*Sets)
if newpb == nil {
for pset := range f.Patchsets.IterAll() {
pset.ShowPatchsets()
@@ -79,7 +79,7 @@ func cleanSubject(line string) string {
return strings.TrimSpace(cleaned)
}
-func (pb *Patchset) ShowPatchsets() error {
+func (pb *Set) ShowPatchsets() error {
author := "Author: " + pb.GitAuthorName
author += " <" + pb.GitAuthorEmail + ">"
log.Printf("%-16s %s %s %s\n", string(pb.Uuid)[0:8], pb.Name, pb.Comment, author)
@@ -109,7 +109,7 @@ func (f *Forge) AddPatch(patch *Patch) bool {
}
// adds a patchset or just the patches
-func (f *Forge) AddPatchset(pb *Patchset) bool {
+func (f *Forge) AddPatchset(pb *Set) bool {
var changed bool
// if the name of the patchset is "forge auto commit"
// then just add all the patches
@@ -146,23 +146,18 @@ func (f *Forge) AddPatchset(pb *Patchset) bool {
}
}
- // Clone() this protobuf into me.forge.Patchsets
- var newpb *Patchset
- newpb = proto.Clone(pb).(*Patchset)
- if newpb != nil {
- f.Patchsets.Patchsets = append(f.Patchsets.Patchsets, newpb)
- }
+ f.Patchsets.Append(pb)
return true
}
-func (f *Forge) findAutoPatchset() *Patchset {
+func (f *Forge) findAutoPatchset() *Set {
for pset := range f.Patchsets.IterAll() {
if pset.Name == "forge auto commit" {
return pset
}
}
- var fauto *Patchset
+ var fauto *Set
log.Warn("findAutoPatchset() had to create 'forge auto commit'")
if fauto == nil {
fauto = makeDefaultPatchset()
@@ -171,8 +166,8 @@ func (f *Forge) findAutoPatchset() *Patchset {
return fauto
}
-func makeDefaultPatchset() *Patchset {
- fauto := new(Patchset)
+func makeDefaultPatchset() *Set {
+ fauto := new(Set)
fauto.Name = "forge auto commit"
fauto.Patches = NewPatches()
fauto.Uuid = uuid.New().String()
diff --git a/patchset.new.go b/patchset.new.go
index 00bfcc8..1a05427 100644
--- a/patchset.new.go
+++ b/patchset.new.go
@@ -1,9 +1,11 @@
package forgepb
+/*
// makes a new patches protobuf. These are all the patches on your machine.
-func NewPatches() *Patches {
- x := new(Patches)
+func NewPatches() *Patchs {
+ x := new(Patchs)
x.Uuid = "2679065e-c81d-4a00-aca4-03c158a834fb"
x.Version = "v2.0.0 go.wit.com/lib/protobuf/forgepb"
return x
}
+*/
diff --git a/patchset.proto b/patchset.proto
deleted file mode 100644
index 035b31d..0000000
--- a/patchset.proto
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
-
-syntax = "proto3";
-
-package forgepb;
-
-import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
-
-// Forge doesn't need this kind of specificity
-// but this is what the patch files contain and how git sees them
-// message Blob {
-// string hunkLine = 1;
-// bytes data = 2;
-// }
-//
-// message File {
-// string filename = 1;
-// string hashLine = 2;
-// repeated Blob Blobs = 3;
-// }
-//
-// message Patch {
-// repeated File Files = 1;
-// string repoNamespace = 2;
-// string gH = 3;
-// string gaI = 4;
-// string gcI = 5;
-// }
-
-// git log -1 --format="%H %aI %cI %an %ae %cn %ce"
-
-message Patch {
- string namespace = 1; // the base repo git namespace
- bytes data = 2; // the raw data of the whole patch
- string gH = 3; // Commit Hash (%H)
- string gT = 4; // Tree Hash (%T)
- string gP = 5; // Parent Hashes (%P)
- string gs = 6; // Subject (%s)
- string gaI = 7; // Author Date, ISO 8601 format (%aI)
- string gan = 8; // Author Name (%an)
- string gae = 9; // Author Email (%ae)
- string gcI = 10; // Committer Date, ISO 8601 format (%cI)
- string gcn = 11; // Committer Name (%cn)
- string gce = 12; // Committer Email (%ce)
- string gN = 13; // Commit Notes (%N)
- string gGG = 14; // GPG Signature, raw (%GG)
- string gGS = 15; // GPG Signer Name (%GS)
- string gGK = 16; // GPG Key ID (%GK)
- string newHash = 17; // new hash
- string state = 18; // the 'state' of the patch
- string filename = 19; // `autogenpb:unique` `autogenpb:sort`
- string startHash = 20; // the start commit hash
- string commitHash = 21; // the git commit hash of this patch `autogenpb:sort` `autogenpb:unique`
- string comment = 22; // the git commit message (in patch form)
- repeated string Files = 23; // the filenames this patch changes
- google.protobuf.Timestamp ctime = 24; // create time of the patch
- bool applied = 25; // have you applied this patch?
- bool upstream = 26; // has this patch been applied upstream?
- string patchId = 27; // patchId
- string treeHash = 28; // final tree Hash
-}
-
-// this is a "PATCH: [1/x]" series
-message Patches { // `autogenpb:marshal` `autogenpb:gui:Patch` `autogenpb:http`
- string uuid = 1; // `autogenpb:uuid:2679065e-c81d-4a00-aca4-03c158a834fb`
- string version = 2; // `autogenpb:version:v2.0.0`
- repeated Patch Patches = 3;
- string Error = 5; // when passing these around, if there is an error, store it here
-}
-
-message Patchset { // `autogenpb:marshal`
- Patches patches = 1; //
- string name = 2; // `autogenpb:sort`
- string comment = 3; //
- string gitAuthorName = 4; // `autogenpb:sort`
- string gitAuthorEmail = 5; //
- google.protobuf.Timestamp ctime = 6; // create time of the patchset
- string tmpDir = 7; // temp dir
- string startBranchName = 8; //
- string endBranchName = 9; //
- string startBranchHash = 10; //
- string endBranchHash = 11; //
- string state = 12; // the state of the patch
- string uuid = 13; // `autogenpb:sort` `autogenpb:unique`
- string hostname = 14; //
-}
-
-message Patchsets { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:nomutex` `autogenpb:http`
- string uuid = 1; // `autogenpb:uuid:be926ad9-f07f-484c-adf2-d96eeabf3079`
- string version = 2; // `autogenpb:version:v0.0.45`
- repeated Patchset Patchsets = 3;
-}
diff --git a/set.proto b/set.proto
new file mode 100644
index 0000000..3420bd0
--- /dev/null
+++ b/set.proto
@@ -0,0 +1,32 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+syntax = "proto3";
+
+package forgepb;
+
+import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
+import "patch.proto"; // Import the well-known type for Timestamp
+
+message Set { // `autogenpb:marshal`
+ Patches patches = 1; // `autogenpb:sort`
+ string uuid = 2;
+ google.protobuf.Timestamp ctime = 3; // when the patches were submitted
+ string submitter = 4; // who submitted these
+ string name = 5; // "fixes for foo"
+ string gitAuthorName = 6; // `autogenpb:sort`
+ string gitAuthorEmail = 7;
+ string hostname = 8;
+ string tmpDir = 9; // temp dir. deprecate this
+ string startBranchName = 10; // deprecate this
+ string endBranchName = 11; // deprecate this
+ string startBranchHash = 12; // deprecate this
+ string endBranchHash = 13; // deprecate this
+ string comment = 14; // deprecate this
+ string state = 15; // deprecate this
+}
+
+message Sets { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:nomutex` `autogenpb:http`
+ string uuid = 1; // `autogenpb:uuid:be926ad9-f07f-484c-adf2-d96eeabf3079`
+ string version = 2; // `autogenpb:version:v0.0.45`
+ repeated Set sets = 3;
+}
diff --git a/structs.go b/structs.go
index 1f446d9..0191d8a 100644
--- a/structs.go
+++ b/structs.go
@@ -12,7 +12,7 @@ type Forge struct {
once sync.Once
Config *ForgeConfigs // config repos for readonly, private, etc
Repos *gitpb.Repos // the repo protobufs
- Patchsets *Patchsets // patches that are in progress
+ Patchsets *Sets // patches that are in progress
hostname string // your hostname
goWork bool // means the user is currently using a go.work file
}