go back to global mutex again. hmmm.
This commit is contained in:
parent
434f62a7e6
commit
46d61345af
|
@ -76,7 +76,6 @@ func (repo *Repo) DeleteLocalDevelBranch() error {
|
||||||
b1 := repo.CountDiffObjects(branch, remote) // should be zero
|
b1 := repo.CountDiffObjects(branch, remote) // should be zero
|
||||||
if b1 == 0 {
|
if b1 == 0 {
|
||||||
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
||||||
// log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
|
|
||||||
_, err := repo.RunVerboseOnError(cmd)
|
_, err := repo.RunVerboseOnError(cmd)
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|
21
config.go
21
config.go
|
@ -47,8 +47,27 @@ func (all *Repos) ConfigSave() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (all *Repos) tryValidate() error {
|
// todo: move this to Marshal() functions automatically in autogenpb?
|
||||||
|
func (repo *Repo) ValidateUTF8() error {
|
||||||
|
if _, err := repo.Marshal(); err == nil {
|
||||||
|
// exit if Marshal() works
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
log.Printf("%s repo.Marshal() failed: %v\n", repo.GetFullPath(), err)
|
||||||
|
}
|
||||||
|
// you only need to do this if Marshal() fails
|
||||||
|
err := bugpb.ValidateProtoUTF8(repo)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Protobuf UTF-8 validation failed: %v\n", err)
|
||||||
|
}
|
||||||
|
if err := bugpb.SanitizeProtoUTF8(repo); err != nil {
|
||||||
|
log.Warn("Sanitation failed:", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (all *Repos) tryValidate() error {
|
||||||
err := bugpb.ValidateProtoUTF8(all)
|
err := bugpb.ValidateProtoUTF8(all)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Protobuf UTF-8 validation failed: %v\n", err)
|
log.Printf("Protobuf UTF-8 validation failed: %v\n", err)
|
||||||
|
|
|
@ -56,6 +56,7 @@ func (repo *Repo) Reload() error {
|
||||||
|
|
||||||
// LastUpdate should always be the newest time
|
// LastUpdate should always be the newest time
|
||||||
repo.Times.LastUpdate = timestamppb.New(time.Now())
|
repo.Times.LastUpdate = timestamppb.New(time.Now())
|
||||||
|
repo.ValidateUTF8()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (repo *Repo) CheckBranches() bool {
|
||||||
if hash == hashCheck {
|
if hash == hashCheck {
|
||||||
// log.Info("notsure why this git show is here", hash)
|
// log.Info("notsure why this git show is here", hash)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("UNKNOWN BRANCH %-50s %s %s %s\n", repo.GetFullPath(), r.Stdout, cmd, b)
|
// log.Printf("UNKNOWN BRANCH %-50s %s %s %s\n", repo.GetFullPath(), r.Stdout, cmd, b)
|
||||||
perfect = false
|
perfect = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ func (repo *Repo) ExamineBranches() *GitTag {
|
||||||
if hash == hashCheck {
|
if hash == hashCheck {
|
||||||
// log.Info("notsure why this git show is here", hash)
|
// log.Info("notsure why this git show is here", hash)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("UNKNOWN BRANCH %-50s %s %s %s\n", repo.GetFullPath(), r.Stdout, cmd, b)
|
// log.Printf("UNKNOWN BRANCH %-50s %s %s %s\n", repo.GetFullPath(), r.Stdout, cmd, b)
|
||||||
tag := new(GitTag)
|
tag := new(GitTag)
|
||||||
tag.Refname = b
|
tag.Refname = b
|
||||||
tag.Hash = hash
|
tag.Hash = hash
|
||||||
|
|
|
@ -33,9 +33,9 @@ func (repo *Repo) setRepoState() {
|
||||||
repo.State = "merge to main"
|
repo.State = "merge to main"
|
||||||
// log.Info("master vs devel count is normal b1 == 0", b1)
|
// log.Info("master vs devel count is normal b1 == 0", b1)
|
||||||
} else {
|
} else {
|
||||||
repo.State = "DEVEL < MASTER"
|
repo.State = "DEVEL behind MASTER"
|
||||||
// log.Info("master vs devel count b1 != 0", b1)
|
// log.Info("master vs devel count b1 != 0", b1)
|
||||||
log.Info("SERIOUS ERROR. DEVEL BRANCH NEEDS MERGE FROM MASTER b1 ==", b1, repo.GetGoPath())
|
log.Infof("%s devel branch is behind master branch (missing %d commits)\n", repo.GetGoPath(), b1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ func (all *Repos) NewGoRepo(fullpath string, gopath string) (*Repo, error) {
|
||||||
// everything happens in here
|
// everything happens in here
|
||||||
newr.Reload()
|
newr.Reload()
|
||||||
|
|
||||||
|
newr.ValidateUTF8()
|
||||||
if all.AppendByFullPath(&newr) {
|
if all.AppendByFullPath(&newr) {
|
||||||
// worked
|
// worked
|
||||||
return &newr, nil
|
return &newr, nil
|
||||||
|
@ -52,6 +53,7 @@ func (all *Repos) NewGoRepo(fullpath string, gopath string) (*Repo, error) {
|
||||||
// enforces GoPath is unique
|
// enforces GoPath is unique
|
||||||
// TODO: deprecate this (?)
|
// TODO: deprecate this (?)
|
||||||
// mutex's should finally work in the autogenpb protobuf code
|
// mutex's should finally work in the autogenpb protobuf code
|
||||||
|
/*
|
||||||
func (all *Repos) AppendByGoPathOld(newr *Repo) bool {
|
func (all *Repos) AppendByGoPathOld(newr *Repo) bool {
|
||||||
// all.RLock()
|
// all.RLock()
|
||||||
repoMu.RLock()
|
repoMu.RLock()
|
||||||
|
@ -69,6 +71,7 @@ func (all *Repos) AppendByGoPathOld(newr *Repo) bool {
|
||||||
all.Append(newr)
|
all.Append(newr)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (all *Repos) NewRepo(fullpath string, namespace string) (*Repo, error) {
|
func (all *Repos) NewRepo(fullpath string, namespace string) (*Repo, error) {
|
||||||
if r := all.FindByFullPath(fullpath); r != nil {
|
if r := all.FindByFullPath(fullpath); r != nil {
|
||||||
|
@ -88,6 +91,7 @@ func (all *Repos) NewRepo(fullpath string, namespace string) (*Repo, error) {
|
||||||
// everything happens in here
|
// everything happens in here
|
||||||
newr.Reload()
|
newr.Reload()
|
||||||
|
|
||||||
|
newr.ValidateUTF8()
|
||||||
if all.AppendByFullPath(&newr) {
|
if all.AppendByFullPath(&newr) {
|
||||||
// worked
|
// worked
|
||||||
return &newr, nil
|
return &newr, nil
|
||||||
|
|
|
@ -42,7 +42,7 @@ message GoInfo { // `autogenpb
|
||||||
bool gitIgnoresGoSum = 12; // does .gitignore ignore go.mod & go.sum?
|
bool gitIgnoresGoSum = 12; // does .gitignore ignore go.mod & go.sum?
|
||||||
}
|
}
|
||||||
|
|
||||||
message Repo { // `autogenpb:marshal`
|
message Repo { // `autogenpb:marshal` `autogenpb:nomutex`
|
||||||
string namespace = 1; // `autogenpb:unique` `autogenpb:sort` // this repo is 'go.wit.com/lib/protobuf/gitpb'
|
string namespace = 1; // `autogenpb:unique` `autogenpb:sort` // this repo is 'go.wit.com/lib/protobuf/gitpb'
|
||||||
string fullPath = 2; // `autogenpb:unique` `autogenpb:sort` // the OS path to the .git directory: '/home/devel/golang.org/x/tools'
|
string fullPath = 2; // `autogenpb:unique` `autogenpb:sort` // the OS path to the .git directory: '/home/devel/golang.org/x/tools'
|
||||||
string masterBranchName = 3; // git 'main' or 'master' branch name
|
string masterBranchName = 3; // git 'main' or 'master' branch name
|
||||||
|
@ -70,7 +70,7 @@ message Repo { // `autogenpb
|
||||||
GitConfig gitConfig = 25; // protobuf of the current .git/config
|
GitConfig gitConfig = 25; // protobuf of the current .git/config
|
||||||
}
|
}
|
||||||
|
|
||||||
message Repos { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:gui`
|
message Repos { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:gui` `autogenpb:nomutex`
|
||||||
string uuid = 1; // `autogenpb:uuid:8daaeba1-fb1f-4762-ae6e-95a55d352673`
|
string uuid = 1; // `autogenpb:uuid:8daaeba1-fb1f-4762-ae6e-95a55d352673`
|
||||||
string version = 2; // `autogenpb:version:v4`
|
string version = 2; // `autogenpb:version:v4`
|
||||||
repeated Repo repos = 3; // `autogenpb:append` // generate AppendUnique() function for this
|
repeated Repo repos = 3; // `autogenpb:append` // generate AppendUnique() function for this
|
||||||
|
|
Loading…
Reference in New Issue