updates for autogenpb
This commit is contained in:
parent
4a79cccffd
commit
3d260a0219
3
Makefile
3
Makefile
|
@ -23,6 +23,7 @@ redomod:
|
|||
rm -f go.*
|
||||
GO111MODULE= go mod init
|
||||
GO111MODULE= go mod tidy
|
||||
go mod edit -go=1.20
|
||||
|
||||
clean:
|
||||
rm -f *.pb.go
|
||||
|
@ -44,7 +45,7 @@ goDep.pb.go: goDep.proto
|
|||
cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/lib/protobuf/gitpb \
|
||||
--go_opt=MgoDep.proto=go.wit.com/lib/protobuf/gitpb \
|
||||
goDep.proto
|
||||
autogenpb --proto goDep.proto --sort "ByPath,GoPath" --no-marshal
|
||||
autogenpb --proto goDep.proto --sort "ByPath,GoPath" --sort "ByHash,Hash" --no-marshal
|
||||
|
||||
repo.pb.go: repo.proto
|
||||
cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/lib/protobuf/gitpb \
|
||||
|
|
|
@ -5,10 +5,10 @@ package gitpb;
|
|||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||
|
||||
message GitTag {
|
||||
string refname = 1; // tag name. treated as unique
|
||||
string refname = 1; // `autogenpb:unique` // tag name. treated as unique
|
||||
google.protobuf.Timestamp creatordate = 2; // git creatordate
|
||||
google.protobuf.Timestamp authordate = 3; // git author date
|
||||
string hash = 4; // git hash
|
||||
string hash = 4; // `autogenpb:unique` // git hash
|
||||
string subject = 5; // git tag subject
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ func (repo *Repo) GetLastTag() string {
|
|||
}
|
||||
|
||||
func (repo *Repo) GitMasterVersion() string {
|
||||
v, err := repo.gitVersionByName("master")
|
||||
bname := repo.GetMasterBranchName()
|
||||
v, err := repo.gitVersionByName(bname)
|
||||
/*
|
||||
count := repo.LenGitTags()
|
||||
log.Info(repo.GoPath, "tag count", count)
|
||||
|
@ -53,7 +54,8 @@ func (repo *Repo) GitMasterVersion() string {
|
|||
}
|
||||
|
||||
func (repo *Repo) GitDevelVersion() string {
|
||||
v, err := repo.gitVersionByName("devel")
|
||||
bname := repo.GetDevelBranchName()
|
||||
v, err := repo.gitVersionByName(bname)
|
||||
if err == nil {
|
||||
return v
|
||||
} else {
|
||||
|
@ -63,7 +65,8 @@ func (repo *Repo) GitDevelVersion() string {
|
|||
}
|
||||
|
||||
func (repo *Repo) GitUserVersion() string {
|
||||
v, err := repo.gitVersionByName("jcarr")
|
||||
bname := repo.GetUserBranchName()
|
||||
v, err := repo.gitVersionByName(bname)
|
||||
if err == nil {
|
||||
return v
|
||||
} else {
|
||||
|
@ -129,6 +132,6 @@ func (repo *Repo) IsBranch(findname string) bool {
|
|||
return true
|
||||
}
|
||||
}
|
||||
log.Log(GITPBWARN, "did not find tag:", findname, "in", repo.GoPath)
|
||||
log.Log(GITPB, "did not find tag:", findname, "in", repo.GoPath)
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
func (repo *Repo) UpdateGitTags() error {
|
||||
// delete the old hash
|
||||
// r.DeleteByHash(hash)
|
||||
repo.Tags.GitTags = nil
|
||||
repo.Tags = new(GitTags)
|
||||
|
||||
tags := []string{"%(objectname)", "%(creatordate)", "%(*authordate)", "%(refname)", "%(subject)"}
|
||||
format := strings.Join(tags, "_,,,_")
|
||||
|
|
|
@ -8,35 +8,11 @@ import (
|
|||
)
|
||||
|
||||
func (repo *Repo) DeleteGoDepByHash(hash string) *GoDep {
|
||||
/*
|
||||
refslock.Lock()
|
||||
defer refslock.Unlock()
|
||||
|
||||
for i, _ := range repo.GoDeps {
|
||||
if repo.GoDeps[i].Hash == hash {
|
||||
repo.GoDeps[i] = repo.GoDeps[len(repo.GoDeps)-1]
|
||||
repo.GoDeps = repo.GoDeps[:len(repo.GoDeps)-1]
|
||||
return nil
|
||||
}
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
return repo.GoDeps.DeleteByHash(hash)
|
||||
}
|
||||
|
||||
// enforces no duplicate package names
|
||||
func (repo *Repo) AppendGoDep(newP *GoDep) bool {
|
||||
/*
|
||||
refslock.Lock()
|
||||
defer refslock.Unlock()
|
||||
|
||||
for _, p := range repo.GoDeps {
|
||||
if p.GoPath == newP.GoPath {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
repo.GoDeps = append(repo.GoDeps, newP)
|
||||
*/
|
||||
return repo.GoDeps.AppendUniqueGoPath(newP)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ package gitpb;
|
|||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||
|
||||
message GoDep {
|
||||
string hash = 1; // md5sum/hash value from the go.sum file
|
||||
string hash = 1; // `autogenpb:unique` // md5sum/hash value from the go.sum file
|
||||
google.protobuf.Timestamp ctime = 2; // get the go date from 'go list' ?
|
||||
string version = 3; // v1.2.2
|
||||
string goPath = 4; // "go.wit.com/lib/foo"
|
||||
string goPath = 4; // `autogenpb:unique` // "go.wit.com/lib/foo"
|
||||
string goVersion = 5; // version of golang the developer used to make this package version
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,12 @@ func (repo *Repo) MakeRedomod() (bool, error) {
|
|||
log.Warn("go mod tidy failed", err)
|
||||
return ok, err
|
||||
}
|
||||
// most things should build with golang after 1.20
|
||||
// TODO: move this to autogenpb
|
||||
if ok, err := repo.strictRun([]string{"go", "mod", "edit", "-go=1.20"}); !ok {
|
||||
log.Warn("go mod edit failed", err)
|
||||
return ok, err
|
||||
}
|
||||
log.Info("MakeRedomod() worked", repo.GoPath)
|
||||
|
||||
if repo.Exists("go.sum") {
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package gitpb
|
||||
|
||||
// delete a gopath:
|
||||
// myrepos.DeleteByPath("go.wit.com/apps/go-clone")
|
||||
func (all *Repos) DeleteByPath(gopath string) *Repo {
|
||||
reposMu.Lock()
|
||||
defer reposMu.Unlock()
|
||||
|
||||
for i, _ := range all.Repos {
|
||||
if all.Repos[i].GoPath == gopath {
|
||||
all.Repos[i] = all.Repos[len(all.Repos)-1]
|
||||
all.Repos = all.Repos[:len(all.Repos)-1]
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// enforces no duplicate gopath's
|
||||
func (all *Repos) add(newP *Repo) bool {
|
||||
reposMu.Lock()
|
||||
defer reposMu.Unlock()
|
||||
|
||||
for _, p := range all.Repos {
|
||||
if p.GoPath == newP.GoPath {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
all.Repos = append(all.Repos, newP)
|
||||
return true
|
||||
}
|
14
repo.new.go
14
repo.new.go
|
@ -36,7 +36,7 @@ func (all *Repos) NewGoPath(basepath string, gopath string) (*Repo, error) {
|
|||
// newr.UpdateGit()
|
||||
newr.UpdateGitTags()
|
||||
|
||||
all.add(&newr)
|
||||
all.AppendUniqueGoPath(&newr)
|
||||
return &newr, nil
|
||||
}
|
||||
|
||||
|
@ -73,3 +73,15 @@ func (repo *Repo) isPrimativeGoMod() (bool, error) {
|
|||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (repo *Repo) SetMasterBranchName(bname string) {
|
||||
repo.MasterBranchName = bname
|
||||
}
|
||||
|
||||
func (repo *Repo) SetDevelBranchName(bname string) {
|
||||
repo.DevelBranchName = bname
|
||||
}
|
||||
|
||||
func (repo *Repo) SetUserBranchName(bname string) {
|
||||
repo.UserBranchName = bname
|
||||
}
|
||||
|
|
23
repo.proto
23
repo.proto
|
@ -5,28 +5,27 @@ package gitpb;
|
|||
// stores information about git repos
|
||||
// If the project is in golang, also gets the go language dependacies
|
||||
|
||||
import "goDep.proto";
|
||||
import "gitTag.proto";
|
||||
import "goDep.proto";
|
||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||
|
||||
message Repo {
|
||||
string fullPath = 1; // the actual path to the .git directory: '/home/devel/golang.org/x/tools'
|
||||
message Repo { // `autogenpb:marshal`
|
||||
string fullPath = 1; // the actual path to the .git directory: '/home/devel/golang.org/x/tools'
|
||||
google.protobuf.Timestamp lastPull = 2; // last time a git pull was done
|
||||
|
||||
string masterBranchName = 3; // git 'main' or 'master' branch name
|
||||
string develBranchName = 4; // whatever the git 'devel' branch name is
|
||||
string userBranchName = 5; // whatever your username branch is
|
||||
string masterBranchName = 3; // git 'main' or 'master' branch name
|
||||
string develBranchName = 4; // whatever the git 'devel' branch name is
|
||||
string userBranchName = 5; // whatever your username branch is
|
||||
GitTags tags = 6;
|
||||
|
||||
// things specific to golang projects
|
||||
string goPath = 6; // the logical path as used by golang: 'go.wit.com/apps/helloworld'
|
||||
bool goLibrary = 7; // if this is a golang library
|
||||
bool goPrimitive = 8; // if this is a golang primitive
|
||||
GitTags tags = 9;
|
||||
string goPath = 7; // `autogenpb:unique` // the logical path as used by golang: 'go.wit.com/apps/helloworld'
|
||||
bool goLibrary = 8; // if this is a golang library
|
||||
bool goPrimitive = 9; // if this is a golang primitive
|
||||
GoDeps goDeps = 10;
|
||||
google.protobuf.Timestamp lastGoDep = 11; // last time go.sum was processed
|
||||
}
|
||||
|
||||
message Repos {
|
||||
message Repos { // `autogenpb:marshal`
|
||||
string uuid = 1; // I guess why not just have this on each file
|
||||
string version = 2; // maybe can be used for protobuf schema change violations
|
||||
repeated Repo repos = 3;
|
||||
|
|
Loading…
Reference in New Issue