2024-01-16 04:46:17 -06:00
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-30 17:22:46 -06:00
|
|
|
"path/filepath"
|
2024-02-21 11:18:16 -06:00
|
|
|
"strconv"
|
2024-02-20 21:03:50 -06:00
|
|
|
"strings"
|
2024-01-30 17:22:46 -06:00
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-18 00:58:14 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-16 04:46:17 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func globalResetOptions(box *gui.Node) {
|
2024-01-16 11:56:55 -06:00
|
|
|
group2 := box.NewGroup("Global Destructive Options")
|
2024-02-07 13:04:25 -06:00
|
|
|
|
2024-02-24 11:54:47 -06:00
|
|
|
grid := group2.RawGrid()
|
|
|
|
|
2024-11-13 12:08:58 -06:00
|
|
|
grid.NewButton("remake 'go.work' file", func() {
|
2024-12-03 17:59:30 -06:00
|
|
|
me.repos.View.MakeGoWork()
|
2024-11-13 12:08:58 -06:00
|
|
|
})
|
|
|
|
grid.NextRow()
|
|
|
|
|
2024-11-14 21:46:45 -06:00
|
|
|
// this dumps everything
|
|
|
|
grid.NewLabel("clean start over")
|
|
|
|
me.deleteGoSrcPkgB = grid.NewButton("rm ~/go/src & ~/go/pkg & ~/.cache/go-build", func() {
|
2024-02-20 21:03:50 -06:00
|
|
|
var state string = me.deleteGoSrcPkgB.String()
|
2025-01-08 00:22:39 -06:00
|
|
|
/*
|
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
|
|
|
if repo.GetGoPath() == "go.wit.com/apps/autotypist" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.Status.CheckDirty() {
|
|
|
|
log.Warn("repo is dirty. commit your changes first", repo.Status.Path())
|
|
|
|
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (can't. dirty repos)")
|
|
|
|
return
|
|
|
|
}
|
2024-02-20 21:03:50 -06:00
|
|
|
}
|
2025-01-08 00:22:39 -06:00
|
|
|
*/
|
2024-01-25 11:38:12 -06:00
|
|
|
|
|
|
|
log.Warn("no repos have uncommited changes")
|
|
|
|
log.Warn("TODO: check things are pushed and check every dir in go/src/")
|
2024-02-20 21:03:50 -06:00
|
|
|
if strings.HasPrefix(state, "rm ~/go/src") {
|
|
|
|
me.deleteGoSrcPkgB.SetLabel("ARE YOU SURE?")
|
|
|
|
return
|
|
|
|
}
|
2024-02-17 15:47:46 -06:00
|
|
|
if me.deleteGoSrcPkgB.String() == "ARE YOU SURE?" {
|
2024-02-20 20:51:07 -06:00
|
|
|
me.deleteGoSrcPkgB.SetLabel("WE ARE NOT KIDDING")
|
2024-02-17 15:47:46 -06:00
|
|
|
return
|
|
|
|
}
|
2024-12-03 17:59:30 -06:00
|
|
|
var totals string = "All " + strconv.Itoa(me.forge.Repos.Len()) + " Repos?"
|
2024-02-20 21:03:50 -06:00
|
|
|
log.Info("totals =", totals)
|
2024-02-17 15:47:46 -06:00
|
|
|
if me.deleteGoSrcPkgB.String() == "WE ARE NOT KIDDING" {
|
2024-02-20 20:51:07 -06:00
|
|
|
me.deleteGoSrcPkgB.SetLabel(totals)
|
2024-02-17 15:47:46 -06:00
|
|
|
return
|
|
|
|
}
|
2024-02-20 20:51:07 -06:00
|
|
|
if me.deleteGoSrcPkgB.String() == totals {
|
2024-01-30 17:22:46 -06:00
|
|
|
homeDir := me.userHomePwd.String()
|
|
|
|
fullpath := filepath.Join(homeDir, "go")
|
|
|
|
gosrc := filepath.Join(fullpath, "src")
|
|
|
|
gopkg := filepath.Join(fullpath, "pkg")
|
|
|
|
quickCmd(fullpath, []string{"rm", "-rf", gosrc})
|
|
|
|
quickCmd(fullpath, []string{"chmod", "700", "-R", gopkg})
|
|
|
|
quickCmd(fullpath, []string{"rm", "-rf", gopkg})
|
2024-11-14 21:46:45 -06:00
|
|
|
quickCmd(homeDir, []string{"rm", "-rf", ".cache/go-build/"})
|
2024-02-20 21:03:50 -06:00
|
|
|
if me.autoDryRun.Checked() {
|
|
|
|
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (uncheck dry-run)")
|
|
|
|
return
|
|
|
|
}
|
2024-01-25 11:38:12 -06:00
|
|
|
}
|
2024-01-16 04:46:17 -06:00
|
|
|
})
|
|
|
|
}
|