lots of changes in gitpb
This commit is contained in:
parent
b2e51ccb9e
commit
ee7e8d5b2b
12
build.go
12
build.go
|
@ -66,8 +66,8 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
all := repo.GoDeps.SortByGoPath()
|
||||
for all.Scan() {
|
||||
t := all.Next()
|
||||
found := f.Repos.FindByGoPath(t.GetGoPath())
|
||||
if found.RepoType() == "protobuf" {
|
||||
found := f.FindByGoPath(t.GetGoPath())
|
||||
if found.GetRepoType() == "protobuf" {
|
||||
if err := f.runAutogenpb(found); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
version = version + "-dirty"
|
||||
}
|
||||
cmd := []string{"go"}
|
||||
if repo.RepoType() == "plugin" {
|
||||
if repo.GetRepoType() == "plugin" {
|
||||
if goWhat == "install" {
|
||||
log.Info("Can not go install plugins yet. just building to ~/go/lib/")
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
linkname := fname + ".so"
|
||||
sopath := filepath.Join(homeDir, "go/lib/go-gui")
|
||||
// if this is a plugin, use buildmode=plugin
|
||||
if repo.RepoType() == "plugin" {
|
||||
if repo.GetRepoType() == "plugin" {
|
||||
if goWhat == "install" {
|
||||
fullname := filepath.Join(sopath, soname)
|
||||
cmd = append(cmd, "-buildmode=plugin", "-o", fullname)
|
||||
|
@ -155,7 +155,7 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
return errors.New("go " + goWhat + " failed: " + fmt.Sprint(result.Error))
|
||||
}
|
||||
// make symlinks
|
||||
if repo.RepoType() == "plugin" {
|
||||
if repo.GetRepoType() == "plugin" {
|
||||
cmd := []string{"ln", "-sf", soname, linkname}
|
||||
if goWhat == "install" {
|
||||
shell.PathRun(sopath, cmd)
|
||||
|
@ -204,5 +204,5 @@ func (f *Forge) FindWorkingDirRepo() *gitpb.Repo {
|
|||
pwd, _ := os.Getwd()
|
||||
basedir := strings.TrimPrefix(pwd, f.GetGoSrc())
|
||||
basedir = strings.Trim(basedir, "/")
|
||||
return f.Repos.FindByGoPath(basedir)
|
||||
return f.FindByGoPath(basedir)
|
||||
}
|
||||
|
|
6
clone.go
6
clone.go
|
@ -120,7 +120,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
|
|||
// actually does something smart
|
||||
func (f *Forge) finishClone(gopath string, giturl string) (*gitpb.Repo, error) {
|
||||
var err error
|
||||
newr := f.Repos.FindByGoPath(gopath)
|
||||
newr := f.FindByGoPath(gopath)
|
||||
if newr == nil {
|
||||
newr, err = f.NewGoRepo(gopath, giturl)
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func (f *Forge) finishClone(gopath string, giturl string) (*gitpb.Repo, error) {
|
|||
newr.URL = giturl
|
||||
}
|
||||
if err := newr.RepoIgnoresGoMod(); err != nil {
|
||||
log.Info("never modify go.mod or go.sum for this repo", newr.GoPath)
|
||||
log.Info("never modify go.mod or go.sum for this repo", newr.GetGoPath())
|
||||
log.Info("We recommend you add 'go.*' to your .gitignore file and store those files as git tag metadata")
|
||||
newr.ParseGoSum()
|
||||
return newr, nil
|
||||
|
@ -145,7 +145,7 @@ func (f *Forge) finishClone(gopath string, giturl string) (*gitpb.Repo, error) {
|
|||
|
||||
log.Info("todo: something went wrong probably. didn't finish. run go-mod-clean? (can't here. loop of circles)")
|
||||
log.Info("todo: do go mod init here directly")
|
||||
log.Info("todo: try to run go mod init here", newr.GoPath)
|
||||
log.Info("todo: try to run go mod init here", newr.GetGoPath())
|
||||
return newr, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool {
|
|||
return false
|
||||
}
|
||||
if !check.Exists("go.mod") {
|
||||
log.Info("go.mod is missing in", check.GoPath)
|
||||
log.Info("go.mod is missing in", check.GetGoPath())
|
||||
return false
|
||||
}
|
||||
|
||||
// IsPrimitive() is expected to set GoPrimitive = true in the protobuf
|
||||
if err := check.SetPrimitive(); err == nil {
|
||||
log.Info("gitpb.SetPrimitive() returned true for", check.GoPath)
|
||||
log.Info("gitpb.SetPrimitive() returned true for", check.GetGoPath())
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool {
|
|||
|
||||
if check.GoDepsLen() == 0 {
|
||||
// this is a primitive
|
||||
check.GoPrimitive = true
|
||||
check.GoInfo.GoPrimitive = true
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool {
|
|||
deps := check.GoDeps.SortByGoPath()
|
||||
for deps.Scan() {
|
||||
depRepo := deps.Next()
|
||||
found := f.Repos.FindByGoPath(depRepo.GetGoPath())
|
||||
found := f.FindByGoPath(depRepo.GetGoPath())
|
||||
if found == nil {
|
||||
if f.CheckOverride(depRepo.GetGoPath()) {
|
||||
// skip this gopath because it's probably broken forever
|
||||
|
@ -62,8 +62,8 @@ func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool {
|
|||
}
|
||||
// log.Info("found dep", depRepo.GetGoPath())
|
||||
if depRepo.GetVersion() != found.GetTargetVersion() {
|
||||
check := f.Repos.FindByGoPath(depRepo.GoPath)
|
||||
if f.Config.IsReadOnly(check.GoPath) {
|
||||
check := f.FindByGoPath(depRepo.GetGoPath())
|
||||
if f.Config.IsReadOnly(check.GetGoPath()) {
|
||||
log.Printf("%-48s ok error .%s. vs .%s. (ignoring read-only repo)", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
|
||||
} else {
|
||||
if f.CheckOverride(depRepo.GetGoPath()) {
|
||||
|
|
|
@ -44,7 +44,7 @@ func (f *Forge) CheckoutDevel() bool {
|
|||
log.Log(FORGEPBWARN, "running git checkout devel everwhere")
|
||||
var failed int = 0
|
||||
var count int = 0
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
count += 1
|
||||
|
@ -53,7 +53,7 @@ func (f *Forge) CheckoutDevel() bool {
|
|||
} else {
|
||||
dname := repo.GetDevelBranchName()
|
||||
if err := f.makeBranch(repo, dname); err != nil {
|
||||
log.Info(repo.GoPath, "can not make devel branch", dname)
|
||||
log.Info(repo.GetGoPath(), "can not make devel branch", dname)
|
||||
failed += 1
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func (f *Forge) CheckoutMaster() bool {
|
|||
log.Log(FORGEPBWARN, "running git checkout master everwhere")
|
||||
var failed int = 0
|
||||
var count int = 0
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
count += 1
|
||||
|
@ -136,7 +136,7 @@ func (f *Forge) CheckoutUser() bool {
|
|||
log.Log(FORGEPBWARN, "running git checkout user everwhere")
|
||||
var failed int = 0
|
||||
var count int = 0
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
count += 1
|
||||
|
|
18
goSrcScan.go
18
goSrcScan.go
|
@ -24,7 +24,7 @@ func (f *Forge) ScanGoSrc() (bool, error) {
|
|||
if strings.HasPrefix(dir, f.goSrc) {
|
||||
gopath := strings.TrimPrefix(dir, f.goSrc)
|
||||
gopath = strings.Trim(gopath, "/")
|
||||
if r := f.Repos.FindByGoPath(gopath); r != nil {
|
||||
if r := f.FindByGoPath(gopath); r != nil {
|
||||
// log.Info("already have", gopath)
|
||||
continue
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func (f *Forge) rillScanDirs(gopaths []string) (int, error) {
|
|||
// Read users from the API.
|
||||
// Concurrency = 20
|
||||
dirs := rill.Map(ids, 20, func(id string) (*gitpb.Repo, error) {
|
||||
return f.NewGoRepo(id, "")
|
||||
return f.checkpath(id, "")
|
||||
})
|
||||
|
||||
var counter int
|
||||
|
@ -158,13 +158,23 @@ func (f *Forge) rillScanDirs(gopaths []string) (int, error) {
|
|||
return counter, err
|
||||
}
|
||||
|
||||
func (f *Forge) checkpath(gopath string, url string) (*gitpb.Repo, error) {
|
||||
fullpath := filepath.Join(f.GetGoSrc(), gopath)
|
||||
log.Info("checkpath()", gopath, fullpath)
|
||||
repo, err := f.NewGoRepo(gopath, "")
|
||||
if err != nil {
|
||||
log.Info("checkpath()", gopath, err)
|
||||
}
|
||||
return repo, err
|
||||
}
|
||||
|
||||
func (f *Forge) RillRedoGoMod() int {
|
||||
var all []*gitpb.Repo
|
||||
tmp := f.Repos.SortByGoPath()
|
||||
tmp := f.Repos.SortByFullPath()
|
||||
for tmp.Scan() {
|
||||
repo := tmp.Next()
|
||||
if !repo.IsValidDir() {
|
||||
log.Printf("%10s %-50s", "old?", repo.GetGoPath())
|
||||
log.Printf("%10s %-50s", "why am I in RillRedoGoMod? old?", repo.GetGoPath())
|
||||
continue
|
||||
}
|
||||
all = append(all, repo)
|
||||
|
|
15
goWork.go
15
goWork.go
|
@ -27,24 +27,27 @@ func (f *Forge) MakeGoWork() error {
|
|||
fmt.Fprintln(workf, "")
|
||||
fmt.Fprintln(workf, "use (")
|
||||
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
/*
|
||||
if !repo.IsGoLang() == "" {
|
||||
// skip repos that aren't go
|
||||
// todo: handle non-flat repos?
|
||||
log.Info("skip non-go", repo.GoPath)
|
||||
log.Info("skip non-go", repo.GetGoPath)
|
||||
continue
|
||||
}
|
||||
*/
|
||||
fmt.Fprintln(workf, "\t"+repo.GoPath)
|
||||
if repo.GetGoPath() == "" {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintln(workf, "\t"+repo.GetGoPath())
|
||||
/*
|
||||
if repo.pb.Exists("go.mod") {
|
||||
// log.Info("ADDING REPO", goSrcDir, repo.GoPath)
|
||||
// log.Info("ADDING REPO", goSrcDir, repo.GetGoPath())
|
||||
} else {
|
||||
fmt.Fprintln(workf, "\t"+repo.GoPath)
|
||||
log.Log(REPO, "missing go.mod for", repo.GoPath)
|
||||
fmt.Fprintln(workf, "\t"+repo.GetGoPath)
|
||||
log.Log(REPO, "missing go.mod for", repo.GetGoPath())
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
30
init.go
30
init.go
|
@ -29,9 +29,9 @@ func Init() *Forge {
|
|||
f.ScanGoSrc()
|
||||
end := f.Repos.Len()
|
||||
if (end - start) == 0 {
|
||||
log.Info("forgepb.Scan() Scan did not find new git repositories.")
|
||||
log.Info("forgepb.Scan() Scan did not find new git repositories. Total =", end)
|
||||
} else {
|
||||
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
||||
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories. Total =", end)
|
||||
}
|
||||
|
||||
f.updateAll()
|
||||
|
@ -50,8 +50,8 @@ func (f *Forge) updateAll() {
|
|||
repo := all.Next()
|
||||
|
||||
if !repo.IsValidDir() {
|
||||
log.Printf("%10s %-50s", "old?\n", repo.GoPath)
|
||||
f.Repos.DeleteByGoPath(repo.GoPath)
|
||||
log.Printf("%10s %-50s", "bad git dir\n", repo.FullPath)
|
||||
f.Repos.DeleteByFullPath(repo.FullPath)
|
||||
f.configSave = true
|
||||
continue
|
||||
}
|
||||
|
@ -61,6 +61,14 @@ func (f *Forge) updateAll() {
|
|||
log.Info("repo changed", repo.StateChange, repo.FullPath)
|
||||
repo.Reload()
|
||||
}
|
||||
if f.Config.IsReadOnly(repo.GetGoPath()) {
|
||||
if repo.ReadOnly {
|
||||
} else {
|
||||
log.Info("readonly flag on repo is wrong", repo.GetGoPath())
|
||||
repo.ReadOnly = true
|
||||
f.configSave = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,3 +117,17 @@ func InitPB() *Forge {
|
|||
f.Repos.ConfigLoad()
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *Forge) SetConfigSave(b bool) {
|
||||
f.configSave = b
|
||||
}
|
||||
|
||||
// saves the config if there have been changes
|
||||
func (f *Forge) Exit() {
|
||||
log.Info("forge.configSave =", f.configSave)
|
||||
if f.configSave {
|
||||
f.ConfigSave()
|
||||
}
|
||||
log.Info("forge.Exit() ok")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func (f *Forge) MakeDevelPatchSet() (*Patchs, error) {
|
|||
defer os.RemoveAll(dir) // clean up
|
||||
pset.TmpDir = dir
|
||||
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
userb := repo.GetUserBranchName()
|
||||
|
@ -50,7 +50,7 @@ func (f *Forge) MakeMasterPatchSet() (*Patchs, error) {
|
|||
defer os.RemoveAll(dir) // clean up
|
||||
pset.TmpDir = dir
|
||||
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
startb := repo.GetMasterBranchName()
|
||||
|
@ -62,7 +62,7 @@ func (f *Forge) MakeMasterPatchSet() (*Patchs, error) {
|
|||
if endb == "" {
|
||||
continue
|
||||
}
|
||||
// log.Info("repo", repo.GoPath, startb, "..", endb)
|
||||
// log.Info("repo", repo.GetGoPath(), startb, "..", endb)
|
||||
pset.StartBranchName = startb
|
||||
pset.EndBranchName = endb
|
||||
err := pset.makePatchSetNew(repo)
|
||||
|
@ -76,7 +76,7 @@ func (f *Forge) MakeMasterPatchSet() (*Patchs, error) {
|
|||
func (pset *Patchs) makePatchSetNew(repo *gitpb.Repo) error {
|
||||
startBranch := pset.StartBranchName
|
||||
endBranch := pset.EndBranchName
|
||||
repoDir := filepath.Join(pset.TmpDir, repo.GoPath)
|
||||
repoDir := filepath.Join(pset.TmpDir, repo.GetGoPath())
|
||||
err := os.MkdirAll(repoDir, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -115,7 +115,7 @@ func (f *Forge) MakePatchSet() (*Patchs, error) {
|
|||
}
|
||||
defer os.RemoveAll(dir) // clean up
|
||||
|
||||
all := f.Repos.SortByGoPath()
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
userb := repo.GetUserBranchName()
|
||||
|
@ -128,7 +128,7 @@ func (f *Forge) MakePatchSet() (*Patchs, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
repoDir := filepath.Join(dir, repo.GoPath)
|
||||
repoDir := filepath.Join(dir, repo.GetGoPath())
|
||||
err := os.MkdirAll(repoDir, 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
26
repoNew.go
26
repoNew.go
|
@ -14,11 +14,15 @@ func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
|
|||
fullpath := filepath.Join(f.GetGoSrc(), gopath)
|
||||
repo, err := f.Repos.NewGoRepo(fullpath, gopath)
|
||||
if err != nil {
|
||||
log.Info("WARNING. NEW FAILED", fullpath)
|
||||
return nil, err
|
||||
}
|
||||
repo.URL = url
|
||||
f.VerifyBranchNames(repo)
|
||||
repo.Reload()
|
||||
if f.Config.IsReadOnly(repo.GetGoPath()) {
|
||||
repo.ReadOnly = true
|
||||
}
|
||||
repo.InitVersions()
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
|
@ -43,15 +47,20 @@ func (f *Forge) ValidGoVersion(ver string) (bool, error) {
|
|||
func (f *Forge) VerifyBranchNames(newr *gitpb.Repo) {
|
||||
// log.Info("init worked for", newr.GoPath)
|
||||
|
||||
var mname string
|
||||
if newr.GetMasterBranchName() == "" {
|
||||
// try to guess what the 'master' branch is
|
||||
if newr.IsBranch("guimaster") {
|
||||
mname = "guimaster"
|
||||
newr.SetMasterBranchName("guimaster")
|
||||
} else if newr.IsBranch("master") {
|
||||
mname = "master"
|
||||
newr.SetMasterBranchName("master")
|
||||
} else if newr.IsBranch("main") {
|
||||
mname = "main"
|
||||
newr.SetMasterBranchName("main")
|
||||
} else {
|
||||
mname = "master"
|
||||
// todo, figure out the name from git
|
||||
newr.SetMasterBranchName("master")
|
||||
if newr.CheckoutMaster() {
|
||||
|
@ -61,10 +70,7 @@ func (f *Forge) VerifyBranchNames(newr *gitpb.Repo) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if f.Config.IsReadOnly(newr.GoPath) {
|
||||
return
|
||||
}
|
||||
log.Info("forge.NewRepo() SET MASTER TO", mname)
|
||||
|
||||
if newr.GetDevelBranchName() == "" {
|
||||
if newr.IsBranch("guidevel") {
|
||||
|
@ -131,3 +137,13 @@ func (f *Forge) AddFullPath(fulldir string) *gitpb.Repo {
|
|||
log.Info("don't know how to add full paths yet", fulldir)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Forge) FindByGoPath(gopath string) *gitpb.Repo {
|
||||
fullpath := filepath.Join(f.GetGoSrc(), gopath)
|
||||
return f.Repos.FindByFullPath(fullpath)
|
||||
}
|
||||
|
||||
func (f *Forge) DeleteByGoPath(gopath string) bool {
|
||||
fullpath := filepath.Join(f.GetGoSrc(), gopath)
|
||||
return f.Repos.DeleteByFullPath(fullpath)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue