final commit before rolling a new release. (maybe)
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b9fec2e814
commit
805d3cdcc3
11
Makefile
11
Makefile
|
@ -1,9 +1,10 @@
|
|||
VERSION = $(shell git describe --tags)
|
||||
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||
|
||||
test: goimports build test
|
||||
full: clean auto goimports vet build test
|
||||
@echo everything worked and the example ran
|
||||
|
||||
full: clean goimports auto vet build
|
||||
test: goimports build test
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
|
@ -29,9 +30,9 @@ install:
|
|||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
auto:
|
||||
rm -f auto.pb.go
|
||||
./autogenpb --proto file.proto --package main
|
||||
rm -f auto.sort.pb.go auto.newsort.pb.go # auto.marshal.pb.go
|
||||
# rm -f auto.pb.go
|
||||
autogenpb --proto file.proto --package main
|
||||
# rm -f auto.sort.pb.go auto.newsort.pb.go # auto.marshal.pb.go
|
||||
|
||||
test:
|
||||
make -C example rawproto
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package forgepb;
|
||||
|
||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||
|
||||
message Patch {
|
||||
string filename = 1; // `autogenpb:unique`
|
||||
bytes data = 2; //
|
||||
string repoPath = 3; // path to the git repo
|
||||
string branchName = 4; //
|
||||
string branchHash = 5; //
|
||||
google.protobuf.Timestamp ctime = 7; // the git commit timestamp of this patch
|
||||
string commitHash = 8; // the git commit hash of this patch
|
||||
string startHash = 9; // the start commit hash
|
||||
repeated string Files = 10; // the filenames this patch changes
|
||||
}
|
||||
|
||||
message Patchs { // `autogenpb:marshal`
|
||||
string uuid = 1; // `autogenpb:uuid:0703df95-6a38-4422-994b-c55d3d6001f9` // todo: add file support
|
||||
string version = 2; // could be used for protobuf schema change violations?
|
||||
repeated Patch Patchs = 3;
|
||||
string name = 4; //
|
||||
string comment = 5; //
|
||||
string gitAuthorName = 6; //
|
||||
string gitAuthorEmail = 7; //
|
||||
google.protobuf.Timestamp ctime = 8; // create time of this patchset
|
||||
string tmpDir = 9; // temp dir
|
||||
string startBranchName = 10; //
|
||||
string endBranchName = 11; //
|
||||
string startBranchHash = 12; //
|
||||
string endBranchHash = 13; //
|
||||
}
|
33
newsort.go
33
newsort.go
|
@ -21,38 +21,5 @@ func (pb *Files) makeNewSortfile(pf *File) error {
|
|||
pf.appendUnique(f) // Append() enforce no unique keys
|
||||
pf.iterSortBy(f)
|
||||
pf.iterAll(f)
|
||||
// pf.iterSortAll(f, sortmap)
|
||||
|
||||
return nil
|
||||
|
||||
/*
|
||||
for _, s := range uniqueKeys {
|
||||
// log.Info("found unique key in .proto", s)
|
||||
sortmap["sortBy"] = s
|
||||
sortmap["sortKey"] = s
|
||||
|
||||
sortmap["append"] = sortmap["sortKey"]
|
||||
iterAppend(f, sortmap) // Append() enforce unique key argv.Append
|
||||
|
||||
iterDelete(f, sortmap)
|
||||
iterReplace(f, sortmap)
|
||||
iterFind(f, sortmap)
|
||||
}
|
||||
|
||||
for _, s := range argv.Sort {
|
||||
sortparts := strings.Split(s, ",")
|
||||
sortmap["sortBy"] = sortparts[0]
|
||||
sortmap["sortKey"] = sortparts[1]
|
||||
|
||||
iterSortBy(f, sortmap)
|
||||
|
||||
sortmap["append"] = sortmap["sortKey"]
|
||||
iterAppend(f, sortmap) // Append() enforce unique key argv.Append
|
||||
|
||||
iterDelete(f, sortmap)
|
||||
iterReplace(f, sortmap)
|
||||
iterFind(f, sortmap)
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
|
|
32
sort.go
32
sort.go
|
@ -142,20 +142,12 @@ func (pf *File) appendUnique(w io.Writer) {
|
|||
LOCK = pf.Bases.Lockname
|
||||
}
|
||||
|
||||
// append check for every key
|
||||
fmt.Fprintln(w, "// enforces "+BASE+" is unique")
|
||||
fmt.Fprintln(w, "func (all *"+MSG+") AppendUnique(newP *"+BASE+") bool {")
|
||||
// append -- no check at all
|
||||
fmt.Fprintln(w, "// just a simple Append() with no checking (but still uses the mutex lock)")
|
||||
fmt.Fprintln(w, "func (all *"+MSG+") Append(newP *"+BASE+") bool {")
|
||||
fmt.Fprintln(w, " "+LOCK+".RLock()")
|
||||
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
|
||||
fmt.Fprintln(w, "")
|
||||
fmt.Fprintln(w, " for _, p := range all."+MSG+" {")
|
||||
for _, KEY := range pf.Base.Unique {
|
||||
fmt.Fprintln(w, " if p."+KEY+" == newP."+KEY+" {")
|
||||
fmt.Fprintln(w, " return false")
|
||||
fmt.Fprintln(w, " }")
|
||||
}
|
||||
fmt.Fprintln(w, " }")
|
||||
fmt.Fprintln(w, "")
|
||||
fmt.Fprintln(w, " all."+MSG+" = append(all."+MSG+", newP)")
|
||||
fmt.Fprintln(w, " return true")
|
||||
fmt.Fprintln(w, "}")
|
||||
|
@ -180,12 +172,24 @@ func (pf *File) appendUnique(w io.Writer) {
|
|||
fmt.Fprintln(w, "")
|
||||
}
|
||||
|
||||
// append -- no check at all
|
||||
fmt.Fprintln(w, "// just a simple Append() with no checking (but still uses the mutex lock)")
|
||||
fmt.Fprintln(w, "func (all *"+MSG+") Append(newP *"+BASE+") bool {")
|
||||
// append check for every key
|
||||
if len(pf.Base.Unique) == 0 {
|
||||
// there are no keys defined
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(w, "// enforces "+BASE+" is unique")
|
||||
fmt.Fprintln(w, "func (all *"+MSG+") AppendUnique(newP *"+BASE+") bool {")
|
||||
fmt.Fprintln(w, " "+LOCK+".RLock()")
|
||||
fmt.Fprintln(w, " defer "+LOCK+".RUnlock()")
|
||||
fmt.Fprintln(w, "")
|
||||
fmt.Fprintln(w, " for _, p := range all."+MSG+" {")
|
||||
for _, KEY := range pf.Base.Unique {
|
||||
fmt.Fprintln(w, " if p."+KEY+" == newP."+KEY+" {")
|
||||
fmt.Fprintln(w, " return false")
|
||||
fmt.Fprintln(w, " }")
|
||||
}
|
||||
fmt.Fprintln(w, " }")
|
||||
fmt.Fprintln(w, "")
|
||||
fmt.Fprintln(w, " all."+MSG+" = append(all."+MSG+", newP)")
|
||||
fmt.Fprintln(w, " return true")
|
||||
fmt.Fprintln(w, "}")
|
||||
|
|
Loading…
Reference in New Issue