use Scan()

This commit is contained in:
Jeff Carr 2024-11-14 21:46:45 -06:00
parent fe5045eb05
commit 90f2a202d5
3 changed files with 19 additions and 9 deletions

View File

@ -8,7 +8,6 @@ import (
"strings" "strings"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log" "go.wit.com/log"
) )
@ -31,7 +30,9 @@ func globalResetOptions(box *gui.Node) {
fmt.Fprintln(f, "go 1.21.4") fmt.Fprintln(f, "go 1.21.4")
fmt.Fprintln(f, "") fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (") fmt.Fprintln(f, "use (")
for _, repo := range repolist.AllRepos() { loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.Status.Exists("go.mod") { if repo.Status.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.Status.GoPath()) fmt.Fprintln(f, "\t"+repo.Status.GoPath())
} else { } else {
@ -108,8 +109,9 @@ func globalResetOptions(box *gui.Node) {
}) })
grid.NextRow() grid.NextRow()
grid.NewLabel("start over") // this dumps everything
me.deleteGoSrcPkgB = grid.NewButton("rm ~/go/src & ~/go/pkg", func() { grid.NewLabel("clean start over")
me.deleteGoSrcPkgB = grid.NewButton("rm ~/go/src & ~/go/pkg & ~/.cache/go-build", func() {
var state string = me.deleteGoSrcPkgB.String() var state string = me.deleteGoSrcPkgB.String()
loop := me.repos.View.ReposSortByName() loop := me.repos.View.ReposSortByName()
for loop.Scan() { for loop.Scan() {
@ -148,6 +150,7 @@ func globalResetOptions(box *gui.Node) {
quickCmd(fullpath, []string{"rm", "-rf", gosrc}) quickCmd(fullpath, []string{"rm", "-rf", gosrc})
quickCmd(fullpath, []string{"chmod", "700", "-R", gopkg}) quickCmd(fullpath, []string{"chmod", "700", "-R", gopkg})
quickCmd(fullpath, []string{"rm", "-rf", gopkg}) quickCmd(fullpath, []string{"rm", "-rf", gopkg})
quickCmd(homeDir, []string{"rm", "-rf", ".cache/go-build/"})
if me.autoDryRun.Checked() { if me.autoDryRun.Checked() {
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (uncheck dry-run)") me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (uncheck dry-run)")
return return

View File

@ -132,7 +132,9 @@ func (r *repoWindow) repoMenu() *gui.Node {
func (r *repoWindow) mergeAllDevelToMain() bool { func (r *repoWindow) mergeAllDevelToMain() bool {
log.Info("merge all here") log.Info("merge all here")
for _, repo := range r.View.AllRepos() { loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.ReadOnly() { if repo.ReadOnly() {
log.Info("skipping readonly", repo.Name(), repo.State()) log.Info("skipping readonly", repo.Name(), repo.State())
continue continue
@ -162,7 +164,9 @@ func (r *repoWindow) mergeAllDevelToMain() bool {
func (r *repoWindow) mergeAllUserToDevel() bool { func (r *repoWindow) mergeAllUserToDevel() bool {
log.Info("merge all here") log.Info("merge all here")
for _, repo := range r.View.AllRepos() { loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.ReadOnly() { if repo.ReadOnly() {
log.Info("skipping readonly", repo.Name(), repo.State()) log.Info("skipping readonly", repo.Name(), repo.State())
continue continue

View File

@ -5,7 +5,6 @@ import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/repostatus"
) )
@ -47,7 +46,9 @@ func makeTagWindow() *tagWindow {
topGrid.NewButton("list all tags", func() { topGrid.NewButton("list all tags", func() {
me.autotypistWindow.Disable() me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable() defer me.autotypistWindow.Enable()
for _, repo := range repolist.AllRepos() { loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
allTags := repo.AllTags() allTags := repo.AllTags()
for _, t := range allTags { for _, t := range allTags {
log.Info("found tag:", t.TagString(), "from", repo.Name()) log.Info("found tag:", t.TagString(), "from", repo.Name())
@ -58,7 +59,9 @@ func makeTagWindow() *tagWindow {
topGrid.NewButton("delete all dup tags", func() { topGrid.NewButton("delete all dup tags", func() {
me.autotypistWindow.Disable() me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable() defer me.autotypistWindow.Enable()
for _, repo := range repolist.AllRepos() { loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.GoPath() == "go.wit.com/lib/gadgets" { if repo.GoPath() == "go.wit.com/lib/gadgets" {
// only do log for now // only do log for now
} else { } else {