start developing this for real

This commit is contained in:
Jeff Carr 2024-12-02 06:59:56 -06:00
parent 8afc4c7135
commit 3895519f25
8 changed files with 164 additions and 119 deletions

View File

@ -1,8 +1,12 @@
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
all: build
./forge
all: vet build
./forge -h
vet:
@GO111MODULE=off go vet
@echo this go binary package builds okay
build:
GO111MODULE=off go build \
@ -16,22 +20,13 @@ install:
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
only-me: build
reset
./forge --only-me
stderr: build
echo "writing to /tmp/forge.log"
./forge >/tmp/forge.log 2>&1
goimports:
goimports -w *.go
@# // to globally reset paths:
@# // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go
gocui: build
reset
./forge --gui gocui >/tmp/forge.log 2>&1
./forge --gui gocui
check-git-clean:
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
@ -41,3 +36,11 @@ redomod:
GO111MODULE= go mod init
GO111MODULE= go mod tidy
list: build
./forge --list
list-config: build
./forge --list-conf
mine: build
./forge --mine

39
argv.go Normal file
View File

@ -0,0 +1,39 @@
package main
/*
this parses the command line arguements
*/
var argv args
type args struct {
List bool `arg:"--list" help:"list found repos"`
ListConf bool `arg:"--list-conf" help:"list your .config/forge/ configuration"`
GetMine bool `arg:"--mine" help:"download private and writeable repos"`
GetFav bool `arg:"--favorites" help:"download repos marked as favorites"`
Pull bool `arg:"--git-pull" help:"run 'git pull' on all your repos"`
Build bool `arg:"--build" default:"true" help:"also try to build it"`
Install bool `arg:"--install" help:"try to install every binary package"`
RedoGoMod bool `arg:"--go-reset" help:"remake all the go.sum and go.mod files"`
DryRun bool `arg:"--dry-run" help:"show what would be run"`
}
func (args) Version() string {
return "forge " + VERSION + " Built on " + BUILDTIME
}
func (a args) Description() string {
return `
forge -- in the spirit of things like sourceforge
Repository configuration is stored in .config/forge/forge.text
Examples:
forge --list # list found repos
forge --mine # download your private and writable repos
forge --favorites # clone repos you marked as favorites
forge --git-pull # run 'git pull' in every repo
forge --build # build every binary package
forge --install # install every binary package
`
}

View File

@ -7,19 +7,12 @@ package main
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
)
var args struct {
OnlyMe bool `arg:"--only-me" help:"only scan repos from ~/.config/submitpatchsets`
}
func init() {
arg.MustParse(&args)
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {

View File

@ -1,27 +0,0 @@
package main
// this initializes the repos
import (
"strings"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
func (r *repoWindow) initRepoList() {
r.View.InitRepoList(".config/autotypist")
if args.OnlyMe {
log.Info("not scanning everything")
} else {
log.Info("scanning everything in ~/go/src")
for i, path := range repostatus.ListGitDirectories() {
// log.Info("addRepo()", i, path)
path = strings.TrimPrefix(path, me.goSrcPwd.String())
path = strings.Trim(path, "/")
log.Info("addRepo()", i, path)
r.View.NewRepo(path)
}
}
}

37
list.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"os"
"go.wit.com/log"
)
func list() {
if argv.ListConf {
me.forge.ConfigPrintTable()
os.Exit(0)
}
if argv.List {
repos := me.forge.Repos.SortByGoPath()
for repos.Scan() {
repo := repos.Next()
if !repo.IsValid() {
log.Printf("%10s %-50s", "old?", repo.GetGoPath())
continue
}
log.Printf("%10s %-50s", repo.RepoType(), repo.GetGoPath())
}
os.Exit(0)
}
if argv.GetMine {
log.Printf("get mine %s", me.forge.GetGoSrc())
os.Exit(0)
}
if argv.GetFav {
log.Printf("get favorites")
os.Exit(0)
}
}

30
main.go
View File

@ -3,25 +3,40 @@ package main
// An app to submit patches for the 30 GO GUI repos
import (
"os"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
"go.wit.com/gui"
)
// sent via -ldflags
var VERSION string
var BUILDTIME string
func main() {
me = new(mainType)
me.pp = arg.MustParse(&argv)
me.myGui = gui.New().Default()
// load the ~/.config/forge/ config
me.forge = forgepb.Init()
os.Setenv("REPO_WORK_PATH", me.forge.GetGoSrc())
// processes any --list like options
// may exit
list()
me.myGui = gui.New()
me.myGui.Default()
me.mainWindow = gadgets.RawBasicWindow("submit & test patchsets")
me.mainWindow.Make()
me.mainWindow.Show()
me.mainbox = me.mainWindow.Box()
vbox1 := me.mainbox.NewVerticalBox("BOX1")
globalDisplayOptions(vbox1)
// disable the interface while everything is scanned
me.Disable()
@ -31,13 +46,6 @@ func main() {
me.repos = makeRepoView()
// parse config file and scan for .git repos
me.repos.initRepoList()
// reads in the State of all the repos
// TODO: should not really be necessary directly after init()
me.repos.View.ScanRepositories()
// processing is done. update the repo summary box
me.summary.Update()

View File

@ -54,39 +54,25 @@ func makeRepoView() *repoWindow {
log.Warn("Should I do something special here?")
}
r.topbox = r.repoAllButtons()
r.topbox = r.repoMenu()
r.View = repolist.AutotypistView(r.box)
r.View = repolist.InitBox(me.forge, r.box)
r.View.Enable()
showncount := r.View.MirrorShownCount()
r.topbox.Append(showncount)
duration := r.View.MirrorScanDuration()
r.topbox.Append(duration)
r.View.ScanRepositories()
r.View.RegisterHideFunction(hideFunction)
/*
r.View = repolist.AutotypistView(r.box)
showncount := r.View.MirrorShownCount()
r.topbox.Append(showncount)
duration := r.View.MirrorScanDuration()
r.topbox.Append(duration)
*/
return r
}
func (r *repoWindow) showApps() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
switch repo.Status.RepoType() {
case "binary":
//log.Info("compile here. Show()")
repo.Show()
case "library":
//log.Info("library here. Hide()")
repo.Hide()
default:
log.Info("showApps() unknown. Show()")
repo.Hide()
}
}
}
func (r *repoWindow) repoAllButtons() *gui.Node {
func (r *repoWindow) repoMenu() *gui.Node {
// reposbox.SetExpand(false)
group1 := r.box.NewGroup("Run on all repos:")
@ -95,21 +81,23 @@ func (r *repoWindow) repoAllButtons() *gui.Node {
hbox.Vertical()
box2 := hbox.Box().Vertical()
box2.NewButton("merge all user to devel", func() {
r.Disable()
if !r.mergeAllUserToDevel() {
return
}
r.Enable()
})
/*
box2.NewButton("merge all user to devel", func() {
r.Disable()
if !r.mergeAllUserToDevel() {
return
}
r.Enable()
})
box2.NewButton("merge all devel to main", func() {
r.Disable()
if !r.mergeAllDevelToMain() {
return
}
r.Enable()
})
box2.NewButton("merge all devel to main", func() {
r.Disable()
if !r.mergeAllDevelToMain() {
return
}
r.Enable()
})
*/
box2.NewButton("merge it all", func() {
r.Disable()
@ -122,30 +110,30 @@ func (r *repoWindow) repoAllButtons() *gui.Node {
r.Enable()
})
box2.NewButton("test all builds", func() {
r.Disable()
defer r.Enable()
r.showApps()
box2.NewButton("show apps", func() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.Hidden() {
// log.Info("skip hidden", repo.String())
} else {
log.Info("try to build", repo.Name())
if repo.Status.Build() {
log.Info("build worked", repo.Name())
} else {
log.Info("build failed", repo.Name())
go repo.Status.Xterm("bash")
return
}
rtype := repo.Status.RepoType()
switch rtype {
case "'binary'":
// log.Info(repo.Status.Path(), "compile here. Show()")
repo.Show()
case "'library'":
// log.Info(repo.Status.Path(), "library here. Hide()")
repo.Hide()
default:
log.Info(repo.Status.Path(), "unknown type", rtype)
// repo.Hide()
}
}
log.Info("")
log.Info("every build worked !!!")
log.Info("")
})
box2.NewButton("scan now", func() {
log.Info("re-scanning now")
i, s := me.repos.View.ScanRepositories()
log.Info("re-scanning done", i, "repos in", s)
})
return box2
}

View File

@ -1,8 +1,10 @@
package main
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
)
var me *mainType
@ -17,8 +19,13 @@ func (b *mainType) Enable() {
// this app's variables
type mainType struct {
pp *arg.Parser
forge *forgepb.Forge
myGui *gui.Node
// our view of the repositories
repos *repoWindow
mainWindow *gadgets.BasicWindow
// the main box. enable/disable this
@ -27,9 +34,6 @@ type mainType struct {
// the window from the /lib/gui/gowit package
lw *gadgets.BasicWindow
// our view of the repositories
repos *repoWindow
// #### Sorting options for the repolist
autoHidePerfect *gui.Node
autoHideReadOnly *gui.Node