summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--stat.SortCtime.go4
-rw-r--r--stat.makeRemote.go19
-rw-r--r--stat.proto47
-rw-r--r--tableStats.go2
5 files changed, 50 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index 2d7b8dd..6bcf688 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,12 @@
all: goimports proto vet
proto:
- autogenpb # generates the .pb.go files
+ autogenpb # generates the .pb.go files
@echo This GO code passes the compile checks
proto-renumber: clean
- autogenpb --renumber
+ autogenpb --renumber # must exits after renumbering & not generate .pb.go files
+ autogenpb # generate the *.pb.go files
make goimports vet
repo.pb.go: repo.proto
diff --git a/stat.SortCtime.go b/stat.SortCtime.go
index ccf4b48..b8045d2 100644
--- a/stat.SortCtime.go
+++ b/stat.SortCtime.go
@@ -25,8 +25,8 @@ type sortStatCtime []*Stat
func (a sortStatCtime) Len() int { return len(a) }
func (a sortStatCtime) Less(i, j int) bool {
- itime := a[i].Ctime.AsTime()
- jtime := a[j].Ctime.AsTime()
+ itime := a[i].CommitTime.AsTime()
+ jtime := a[j].CommitTime.AsTime()
return itime.Before(jtime)
}
func (a sortStatCtime) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
diff --git a/stat.makeRemote.go b/stat.makeRemote.go
index a5d746a..0dbd7a3 100644
--- a/stat.makeRemote.go
+++ b/stat.makeRemote.go
@@ -5,9 +5,11 @@ import (
"path/filepath"
"strings"
+ "go.wit.com/lib/cobol"
"go.wit.com/lib/config"
"go.wit.com/lib/env"
"go.wit.com/log"
+ timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
// loads what is on disk already. that is all
@@ -52,9 +54,9 @@ func (r *Repo) MakeRemote(remoteName string) (*Stats, error) {
var counter int
for _, line := range cmdout.Stdout {
line = strings.TrimSpace(line)
- parts := strings.Fields(line)
- if len(parts) != 2 {
- log.Printf("Repo: %s\n", r.FullPath)
+ parts := strings.Split(line, standardSeperator)
+ if len(parts) != 5 {
+ log.Printf("Repo: %s len(%d)\n", r.FullPath, len(parts))
log.Printf("CMD: %v\n", cmd)
log.Printf("LINE:%s\n", line)
return stats, errors.New(line)
@@ -65,6 +67,17 @@ func (r *Repo) MakeRemote(remoteName string) (*Stats, error) {
counter += 1
newstat := new(Stat)
newstat.Hash = parts[0]
+ newstat.TreeHash = parts[1]
+ t, err := cobol.GetTime(parts[2])
+ _ = err
+ if t != nil {
+ newstat.AuthorTime = timestamppb.New(*t)
+ }
+ t, err = cobol.GetTime(parts[3])
+ if t != nil {
+ newstat.CommitTime = timestamppb.New(*t)
+ }
+ newstat.SanitizedSubject = parts[4]
stats.Append(newstat)
}
if counter > 0 {
diff --git a/stat.proto b/stat.proto
index bb5dcfa..e98d73e 100644
--- a/stat.proto
+++ b/stat.proto
@@ -5,6 +5,9 @@ syntax = "proto3";
package gitpb;
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
+//
+// this is dumb, but works for now. duplicate information is stored sometimes
+// this is however, fast. TODO: redo this .proto file someday
message GitRef {
enum RefType {
@@ -13,28 +16,34 @@ message GitRef {
REMOTE = 2;
TAG = 3;
}
- string name = 1; //
- string remote = 2; // blank unless REMOTE
- RefType type = 3; // is set by git as the master branch
- string subject = 4; // git tag subject
+ string name = 1; //
+ string remote = 2; // blank unless REMOTE
+ RefType type = 3; // is set by git as the master branch
+ string subject = 4; // git tag subject
}
+// TODO: use patch.proto instead
message Stat {
- string patchId = 1; // `autogenpb:unique` `autogenpb:sort`
- string hash = 2; // `autogenpb:unique` `autogenpb:sort`
- google.protobuf.Timestamp ctime = 3; // `autogenpb:unique` `autogenpb:sort`
- string name = 4; //
- string remote = 5; // blank unless REMOTE
- string subject = 6; // git tag subject
- repeated GitRef refs = 7; //
+ string patchId = 1; // `autogenpb:unique` `autogenpb:sort`
+ string hash = 2; // `autogenpb:unique` `autogenpb:sort`
+ string treeHash = 3; // `autogenpb:unique` `autogenpb:sort`
+ google.protobuf.Timestamp authorTime = 4; // `autogenpb:unique` `autogenpb:sort`
+ google.protobuf.Timestamp commitTime = 5; // `autogenpb:unique` `autogenpb:sort`
+ string sanitizedSubject = 6; //
+ string name = 7; //
+ string remote = 8; // blank unless REMOTE
+ string subject = 9; // git tag subject
+ GitRef.RefType type = 10; // is set by git as the master branch
+ repeated GitRef refs = 11; // this is dumb, but works for now. duplicate information is stored sometimes
}
// normally stored as .git/*.pb cache files
-message Stats { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:http`
- string uuid = 1; // `autogenpb:uuid:ba236558-f8a1-4c47-a14a-8856a24d3f72`
- string version = 2; // `autogenpb:version:v0.0.3`
- repeated Stat stats = 3;
- string filename = 4; // `autogenpb:save` -- this enables autogenerated pb.Load() and pb.Save()
- string head = 5; // the current origin hash
- google.protobuf.Timestamp mtime = 6; // mtime for .git/
- string name = 7; // the current origin hash
+// TODO: use patch.proto instead
+message Stats { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:http`
+ string uuid = 1; // `autogenpb:uuid:ba236558-f8a1-4c47-a14a-8856a24d3f72`
+ string version = 2; // `autogenpb:version:v0.0.3`
+ repeated Stat stats = 3;
+ string filename = 4; // `autogenpb:save` -- this enables autogenerated pb.Load() and pb.Save()
+ string head = 5; // the current origin hash
+ google.protobuf.Timestamp mtime = 6; // mtime for .git/
+ string name = 7; // the current origin hash
}
diff --git a/tableStats.go b/tableStats.go
index 3bd209a..20e1c63 100644
--- a/tableStats.go
+++ b/tableStats.go
@@ -37,7 +37,7 @@ func (pb *Stats) MakeTable(name string) *StatsTable {
col.Header.Name = "Git Hash"
col = t.AddStringFunc("age", func(r *Stat) string {
- return cobol.Time(r.Ctime)
+ return cobol.Time(r.CommitTime)
})
col.Width = 28