rename to repolist.RepoRow

This commit is contained in:
Jeff Carr 2024-02-23 09:02:51 -06:00
parent 8f4ae1a639
commit ec7dd061e2
8 changed files with 39 additions and 102 deletions

View File

@ -18,13 +18,13 @@ func (r *RepoList) Hide() {
r.reposbox.Hide()
}
func (r *RepoList) FindRepo(path string) *Repo {
func (r *RepoList) FindRepo(path string) *RepoRow {
repo, _ := me.allrepos[path]
return repo
}
func (r *RepoList) AllRepos() []*Repo {
var all []*Repo
func (r *RepoList) AllRepos() []*RepoRow {
var all []*RepoRow
for _, repo := range me.allrepos {
all = append(all, repo)
}
@ -32,8 +32,8 @@ func (r *RepoList) AllRepos() []*Repo {
}
// deprecate this
func AllRepos() []*Repo {
var all []*Repo
func AllRepos() []*RepoRow {
var all []*RepoRow
for _, repo := range me.allrepos {
all = append(all, repo)
}
@ -41,40 +41,40 @@ func AllRepos() []*Repo {
}
// a human readable state of the current repo
func (r *Repo) State() string {
func (r *RepoRow) State() string {
return r.gitState.String()
}
func (r *Repo) Scan() bool {
func (r *RepoRow) Scan() bool {
return r.NewScan()
}
// returns a name for human consuption only
// todo: implement nicknames
func (rs *Repo) Name() string {
func (rs *RepoRow) Name() string {
if rs.Status.IsGoLang() {
return rs.Status.GoPath()
}
return rs.Status.Path()
}
func (r *Repo) Exists(s string) bool {
func (r *RepoRow) Exists(s string) bool {
return false
}
func (r *Repo) GoPath() string {
func (r *RepoRow) GoPath() string {
return r.Status.GoPath()
}
func (r *Repo) CheckDirty() bool {
func (r *RepoRow) CheckDirty() bool {
return r.Status.CheckDirty()
}
func (r *Repo) IsDirty() bool {
func (r *RepoRow) IsDirty() bool {
return r.Status.IsDirty()
}
func (r *Repo) ReadOnly() bool {
func (r *RepoRow) ReadOnly() bool {
if r == nil {
log.Warn("ReadOnly() repo == nil")
return false
@ -86,7 +86,7 @@ func (r *Repo) ReadOnly() bool {
return r.Status.ReadOnly()
}
func (r *Repo) LastTag() string {
func (r *RepoRow) LastTag() string {
if r == nil {
log.Warn("LastTag() repo == nil")
return ""
@ -101,7 +101,7 @@ func (r *Repo) LastTag() string {
// be sure that anything will run with older versions
// because this are changing too often at this point
// TODO: revisit this in 2025 or 2026
func (r *Repo) GoState() string {
func (r *RepoRow) GoState() string {
if r == nil {
log.Info("GoState() r == nil")
return "goState == nil"
@ -113,7 +113,7 @@ func (r *Repo) GoState() string {
return r.goState.String()
}
func (r *Repo) SetGoState(s string) {
func (r *RepoRow) SetGoState(s string) {
if r == nil {
log.Info("SetGoState() r == nil")
return
@ -125,7 +125,7 @@ func (r *Repo) SetGoState(s string) {
r.goState.SetText(s)
}
func (r *Repo) IsPerfect() bool {
func (r *RepoRow) IsPerfect() bool {
if r.gitState.String() == "PERFECT" {
return true
}
@ -135,20 +135,20 @@ func (r *Repo) IsPerfect() bool {
return false
}
func (r *Repo) RunCmd(cmd []string) (error, string) {
func (r *RepoRow) RunCmd(cmd []string) (error, string) {
return r.Status.RunCmd(cmd)
}
func (r *Repo) AllTags() []*repostatus.Tag {
func (r *RepoRow) AllTags() []*repostatus.Tag {
return r.Status.Tags.ListAll()
}
func (r *Repo) TagsBox() *repostatus.GitTagBox {
func (r *RepoRow) TagsBox() *repostatus.GitTagBox {
return r.Status.Tags
}
// todo, fix bool return for deletetag()
func (r *Repo) DeleteTag(t *repostatus.Tag) bool {
func (r *RepoRow) DeleteTag(t *repostatus.Tag) bool {
r.Status.DeleteTag(t)
return true
}

View File

@ -34,7 +34,7 @@ if dirty == 0 {
// move all this to repolist and gowit repos
func (repo *Repo) GetPatches(oldname string, newname string) (int, []*Patch) {
func (repo *RepoRow) GetPatches(oldname string, newname string) (int, []*Patch) {
var patchcount int
patches := make([]*Patch, 0, 0)
@ -74,7 +74,7 @@ func (repo *Repo) GetPatches(oldname string, newname string) (int, []*Patch) {
return patchcount, patches
}
func (repo *Repo) GetUserPatches() (int, []*Patch) {
func (repo *RepoRow) GetUserPatches() (int, []*Patch) {
usern := repo.Status.GetUserBranchName()
develn := repo.Status.GetDevelBranchName()
userv := repo.Status.GetUserVersion()
@ -89,7 +89,7 @@ func (repo *Repo) GetUserPatches() (int, []*Patch) {
return c, all
}
func (repo *Repo) GetMasterPatches() (int, []*Patch) {
func (repo *RepoRow) GetMasterPatches() (int, []*Patch) {
lasttag := repo.LastTag()
mastern := repo.Status.GetMasterBranchName()
masterv := repo.Status.GetMasterVersion()

View File

@ -11,7 +11,7 @@ import (
// scans through everything in the go.sum file to make
// sure the versions are correct when attempting to do a GUI release
func (rl *RepoList) CheckValidGoSum(r *Repo) (bool, error) {
func (rl *RepoList) CheckValidGoSum(r *RepoRow) (bool, error) {
log.Log(REPOWARN, "CheckValidGoSum() started")
ok, err := r.Status.MakeRedomod()
if !ok {
@ -54,66 +54,3 @@ func (rl *RepoList) CheckValidGoSum(r *Repo) (bool, error) {
log.Log(REPOWARN, "Releasing this should be ok", r.GoPath())
return true, nil
}
/*
// check if it is safe to remake the go.sum & go.mod files
func (rs *RepoStatus) CheckSafeGoSumRemakeOld() (bool, []string) {
// myGoSumS := rs.goSumStatus.String()
if rs.ReadGoMod() {
log.Log(REPO, "parsed go.mod", rs.realPath.String())
} else {
log.Log(REPOWARN, "Something went wrong parsing go.mod", rs.realPath.String())
return false, nil
}
log.Log(REPOWARN, "go.sum:", rs.realPath.String())
var clean []string
for depname, version := range rs.goConfig {
if strings.HasSuffix(depname, "/v2") {
log.Log(REPOWARN, " FOUND /v2 wierd golang stuff. instead, look for:", depname)
depname = strings.TrimSuffix(depname, "/v2")
}
log.Log(REPOWARN, " ", depname, version)
deprs, ok := windowMap[depname]
if ok {
if deprs.CheckDirty() {
log.Log(REPOWARN, " IS DIRTY", deprs.String())
clean = append(clean, deprs.String())
}
if deprs.readOnly.String() == "true" {
log.Log(REPOWARN, " SKIPPING Read Only", deprs.String())
} else {
// goSumS := deprs.goSumStatus.String()
log.Log(REPOWARN, " FOUND", deprs.String())
username := deprs.mainWorkingName.String()
userhash, _ := deprs.gitConfig.hashes[username]
userversion, _ := deprs.gitConfig.versions[userhash]
log.Log(REPOWARN, " username :"+username, userhash)
log.Log(REPOWARN, " username :"+username, userversion)
if version == userversion {
log.Log(REPOWARN, " USER VERSIONS MATCH", version, userversion)
clean = append(clean, deprs.String())
} else {
os.Unsetenv("GO111MODULE")
log.Log(REPOWARN, " USER VERSIONS MISMATCH", version, userversion)
log.Log(REPOWARN, " IGNORE UNCHANGED REPO. RUNNING 'go get'", depname, userversion)
err, output := rs.RunCmd([]string{"go", "get", depname + "@" + userversion})
log.Log(REPOWARN, " go get", depname, err, output)
}
}
} else {
// log.Log(REPOWARN, " NOT FOUND", depname)
// only fail on our stuff
if strings.HasPrefix(depname, "go.wit.com") {
log.Log(REPOWARN, " go get -v", depname)
// rs.RunCmd([]string{"go", "get", "-v", depname})
return false, clean
}
// log.Log(REPOWARN, " NOT FOUND BUT IGNORING FOR NOW")
}
}
if len(clean) == 0 {
return true, nil
}
return false, clean
}
*/

View File

@ -7,11 +7,11 @@ import (
"go.wit.com/log"
)
func (r *Repo) Hidden() bool {
func (r *RepoRow) Hidden() bool {
return r.hidden
}
func (r *Repo) Hide() {
func (r *RepoRow) Hide() {
r.pLabel.Hide()
r.lastTag.Hide()
r.currentName.Hide()
@ -30,7 +30,7 @@ func (r *Repo) Hide() {
r.hidden = true
}
func (r *Repo) Show() {
func (r *RepoRow) Show() {
r.pLabel.Show()
r.lastTag.Show()
r.currentName.Show()
@ -49,12 +49,12 @@ func (r *Repo) Show() {
r.hidden = false
}
func (r *RepoList) NewRepo(path string) (*Repo, error) {
func (r *RepoList) NewRepo(path string) (*RepoRow, error) {
status, err := repostatus.New(path)
if err != nil {
return nil, err
}
newRepo := new(Repo)
newRepo := new(RepoRow)
newRepo.Status = status
newRepo.pLabel = r.reposgrid.NewLabel(path).SetProgName("path")
@ -75,7 +75,7 @@ func (r *RepoList) NewRepo(path string) (*Repo, error) {
return newRepo, nil
}
func (r *RepoList) makeAutotypistView(newRepo *Repo) {
func (r *RepoList) makeAutotypistView(newRepo *RepoRow) {
grid := r.reposgrid
newRepo.lastTag = newRepo.Status.MirrorLastTag()
@ -148,7 +148,7 @@ func (r *RepoList) makeAutotypistView(newRepo *Repo) {
}
}
func (r *RepoList) makeGuireleaserView(newRepo *Repo) {
func (r *RepoList) makeGuireleaserView(newRepo *RepoRow) {
grid := r.reposgrid
newRepo.targetV = newRepo.Status.MirrorTargetVersion()

View File

@ -12,7 +12,7 @@ func (r *RepoList) SetAutoScan(b bool) {
me.autoScan = b
}
func (r *RepoList) RegisterHideFunction(f func(*Repo)) {
func (r *RepoList) RegisterHideFunction(f func(*RepoRow)) {
me.hideFunction = f
}
@ -48,7 +48,7 @@ func (r *RepoList) ScanRepositories() (int, string) {
return i, s
}
func (r *Repo) NewScan() bool {
func (r *RepoRow) NewScan() bool {
if r.Status == nil {
log.Warn("repo.Status = nil. not initialized for some reason")
return false

View File

@ -21,7 +21,7 @@ type RepoList struct {
goSrcPwd string
autoHidePerfect bool
autoScan bool
allrepos map[string]*Repo
allrepos map[string]*RepoRow
viewName string
reposbox *gui.Node
@ -32,11 +32,11 @@ type RepoList struct {
blind *gui.Node
shownCount *gui.Node
hideFunction func(*Repo)
hideFunction func(*RepoRow)
duration *gui.Node
}
type Repo struct {
type RepoRow struct {
hidden bool
lasttagrev string
// lasttag string

View File

@ -9,7 +9,7 @@ func AutotypistView(parent *gui.Node) *RepoList {
return me
}
me = new(RepoList)
me.allrepos = make(map[string]*Repo)
me.allrepos = make(map[string]*RepoRow)
me.viewName = "autotypist"
// me.reposbox = gui.RawBox()

View File

@ -9,7 +9,7 @@ func GuireleaserView(parent *gui.Node) *RepoList {
return me
}
me = new(RepoList)
me.allrepos = make(map[string]*Repo)
me.allrepos = make(map[string]*RepoRow)
me.viewName = "guireleaser"
// me.reposbox = gui.RawBox()