change to use gitpb

This commit is contained in:
Jeff Carr 2024-12-01 00:48:07 -06:00
parent b1cdb841bc
commit afe21d3c62
5 changed files with 29 additions and 40 deletions

View File

@ -1,12 +1,10 @@
package main
import (
"os"
"strings"
"time"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
@ -55,39 +53,23 @@ func (c *controlBox) addRepo(path string) {
c.tagDate = gadgets.NewBasicEntry(c.grid, "git tag Date")
c.grid.NextRow()
err, repo := repostatus.NewRepoStatusWindow(path)
if err != nil {
log.Info("path did not work", path, err)
return
}
if repo == nil {
log.Info("repo == nil", path, err)
os.Exit(-1)
return
}
c.status = repo
// c.status.SetMainWorkingName("master")
// c.status.SetDevelWorkingName("devel")
// c.status.SetUserWorkingName("jcarr")
c.status.Update()
cbname := repo.GetCurrentBranchName()
cbversion := repo.GetCurrentBranchVersion()
debversion := repo.DebianCurrentVersion()
cbname := c.status.GetCurrentBranchName()
cbversion := c.status.GetCurrentBranchVersion()
debversion := c.status.DebianCurrentVersion()
if c.status.CheckDirty() {
if repo.CheckDirty() {
c.dirtyL.SetText("true")
} else {
c.dirtyL.SetText("false")
}
if c.GoPath.String() == "" {
c.GoPath.SetText(c.status.GoPath())
c.GoPath.SetText(repo.GoPath)
}
lasttag := c.status.GetLastTagVersion()
lasttag := repo.GetLastTagVersion()
if argv.Release {
debversion = c.status.DebianReleaseVersion()
debversion = repo.DebianReleaseVersion()
c.dirtyL.SetText("false")
}
@ -99,9 +81,5 @@ func (c *controlBox) addRepo(path string) {
tagDate := c.getDateStamp(lasttag)
c.tagDate.SetText(tagDate)
if s, ok := c.status.Changed(); ok {
log.Warn("should scan here", s)
}
return
}

View File

@ -289,7 +289,7 @@ func (c *controlBox) computeControlValues() bool {
// stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC")
func (c *controlBox) getDateStamp(tag string) string {
r := c.status.Run([]string{"git", "log", "-1", "--format=%at", tag})
r := repo.Run([]string{"git", "log", "-1", "--format=%at", tag})
out := strings.Join(r.Stdout, "\n")
out = strings.TrimSpace(out)

View File

@ -3,7 +3,6 @@ package main
import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repostatus"
)
type controlBox struct {
@ -33,7 +32,7 @@ type controlBox struct {
currentL *gadgets.OneLiner
buildDate *gadgets.OneLiner
tagDate *gadgets.BasicEntry
status *repostatus.RepoStatus
// status *repostatus.RepoStatus
}
// This initializes the control box

23
main.go
View File

@ -9,6 +9,8 @@ import (
"go.wit.com/lib/debugger"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
@ -19,6 +21,10 @@ var DATE string
// This is the beginning of the binary tree of GUI widgets
var myGui *gui.Node
// this scans in the repos
var forge *forgepb.Forge
var repo *gitpb.Repo
var cBox *controlBox
// this is a basic window. the user can open and close it
@ -34,6 +40,17 @@ func main() {
println("go-deb --repo go.wit.com/apps/helloworld")
os.Exit(0)
}
forge = forgepb.Init()
os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())
repo = forge.Repos.FindByGoPath(argv.Repo)
if repo == nil {
log.Info("repo not found. you need to clone", argv.Repo)
os.Exit(-1)
}
log.Info("found repo", argv.Repo)
// build()
myGui = gui.New()
if !argv.Auto {
myGui.InitEmbed(resources)
@ -65,7 +82,7 @@ func main() {
cBox.computeControlValues()
// verify the values for the package
if cBox.status == nil {
if repo == nil {
if argv.Repo == "." {
// this means try the local directory for a custom 'control' file
} else {
@ -79,8 +96,8 @@ func main() {
}
// set the working directory to argv.Repo
log.Info("cd", cBox.status.Path())
os.Chdir(cBox.status.Path())
log.Info("cd", repo.FullPath)
os.Chdir(repo.FullPath)
if argv.Auto {
shell.TestTerminalColor()

View File

@ -43,10 +43,5 @@ func makebasicWindow() *gadgets.BasicWindow {
basicWindow.Enable()
})
group1.NewButton("open repo", func() {
cBox.status.Update()
cBox.status.Toggle()
})
return basicWindow
}