Compare commits

...

10 Commits

Author SHA1 Message Date
Jeff Carr cfc91c8ba6 rm GOSRC 2025-09-11 23:10:38 -05:00
Jeff Carr 1c8f502c1b rm old code 2025-09-11 06:31:38 -05:00
Jeff Carr a72e9ce5f4 NEVER LEAVE JUNK IN GO REPOS EVER 2025-02-22 19:11:51 -06:00
Jeff Carr 3ab156a9c4 gitpb code is changing 2025-02-21 09:33:58 -06:00
Jeff Carr fa5c6572ff should help race conditions 2025-01-30 18:00:03 -06:00
Jeff Carr d568d5dbe4 make the buttons work 2025-01-30 13:44:22 -06:00
Jeff Carr 4484b0b84d new window for merge on a single repo 2025-01-30 13:35:22 -06:00
Jeff Carr c079039ffe func name change 2025-01-30 11:50:23 -06:00
Jeff Carr ff91deee63 func name change 2025-01-30 11:27:37 -06:00
Jeff Carr 2395a4466e delete old code. start refactor to protobuf 2025-01-29 16:18:32 -06:00
13 changed files with 447 additions and 384 deletions

View File

@ -10,3 +10,6 @@ redomod:
GO111MODULE= go mod init
GO111MODULE= go mod tidy
clean:
rm -f go.*
go-mod-clean --purge

View File

@ -2,46 +2,36 @@ package repostatus
import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
repo := rs.pb
rs.gitBranchesGroup = parent.NewGroup("branches") // `progname:"BRANCHES"` // can the toolkits use these for i18n support?
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 0, 0)
grid := rs.gitBranchesGroup.RawGrid()
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag") // `progname:"LASTTAG"`
newgrid.NextRow()
rs.mainBranchVersion = gadgets.NewOneLiner(newgrid, "master") // `progname:"MASTERBRANCH"`
newgrid.NextRow()
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel") // `progname:"DEVELBRANCH"`
newgrid.NextRow()
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user") // `progname:"USERBRANCH"`
newgrid.NextRow()
rs.currentBranch = gadgets.NewOneLiner(newgrid, "current branch") // `progname:"CURRENTBRANCH"`
newgrid.NextRow()
rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version") // `progname:"CURRENTVERSION"`
newgrid.NextRow()
rs.switchBranchB = newgrid.NewButton("Switch Branch", func() { // `progname:"SWITCH"`
})
rs.targetBranch = newgrid.NewDropdown() // `progname:"TARGET"`
newgrid.NextRow()
rs.showBranchesButton = newgrid.NewButton("find user and devel", func() {
var win *repoBranchesWindow
grid.NewButton("Branches Window", func() {
if win != nil {
win.Toggle()
return
}
log.Info("redo this")
win = MakeRepoBranchesWindow(repo)
win.Show()
})
newgrid.NextRow()
grid.NextRow()
rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
var mergeWin *repoMergeWindow
grid.NewButton("Merge Window", func() {
if mergeWin != nil {
mergeWin.Toggle()
return
}
log.Info("redo this")
mergeWin = rs.MakeRepoMergeWindow(repo)
mergeWin.Show()
})
newgrid.NextRow()
grid.NextRow()
newgrid.NewButton("Revert master to devel", func() {
log.Info("redo this")
})
}

62
git.go
View File

@ -1,13 +1,15 @@
package repostatus
// remove this everything
// most everything here needs to be deprecated now
func (rs *RepoStatus) Path() string {
return rs.realPath.String()
}
/*
func (rs *RepoStatus) GitState() string {
return rs.gitState.String()
}
*/
func (rs *RepoStatus) GetStatus() string {
return rs.gitState.String()
@ -38,61 +40,3 @@ func (rs *RepoStatus) checkCurrentBranchName() string {
rs.NoteChange("current branch has changed from " + currentname + " to " + out)
return out
}
/*
func (rs *RepoStatus) oldgitDescribeByHash(hash string) (string, error) {
if hash == "" {
return "", errors.New("hash was blank")
}
r := shell.PathRunLog(rs.realPath.String(), []string{"git", "describe", "--tags", "--always", hash}, INFO)
out := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Warn("not in a git repo or bad hash?", r.Error, rs.Path())
return out, r.Error
}
return out, r.Error
}
func (rs *RepoStatus) oldgitDescribeByName(name string) (string, error) {
name = strings.TrimSpace(name)
if name == "" {
// git will return the current tag
r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always"}, INFO)
output := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Warn("gitDescribeByName() not in a git repo?", r.Error, rs.Path())
}
return strings.TrimSpace(output), r.Error
}
if !rs.LocalTagExists(name) {
// tag does not exist
return "", errors.New("gitDescribeByName() git fatal: Not a valid object name")
}
cmd := []string{"git", "describe", "--tags", "--always", name}
r := shell.PathRunLog(rs.Path(), cmd, INFO)
output := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Warn("cmd =", cmd)
log.Warn("err =", r.Error)
log.Warn("not in a git repo or bad tag?", rs.Path())
}
return strings.TrimSpace(output), r.Error
}
*/
/*
func (rs *RepoStatus) populateTags() {
tmp := rs.realPath.String() + "/.git/refs/tags"
log.Log(REPO, "populateTags() path =", tmp)
for _, tag := range gitpb.ListFiles(tmp) {
if rs.tags[tag] == "" {
log.Log(REPO, "populateTags() Adding new tag", tag)
// rs.tagsDrop.AddText(tag)
rs.tags[tag] = "origin"
}
}
// rs.tagsDrop.SetText(rs.lasttagrev)
}
*/

View File

@ -1,95 +0,0 @@
package repolist
// attempt to make a golang 'interface' for a 'view' of git repos
import (
"context"
"errors"
"fmt"
"go.wit.com/lib/protobuf/virtbuf"
)
// ViewRepoManager is a concrete implementation of the RepoManager interface.
type ViewRepoManager struct {
// client represents a hypothetical API client for interacting with the cloud.
client ViewAPIClient
}
// ViewAPIClient defines the methods required from the API client.
// This is useful if you want to mock this client for testing.
type ViewAPIClient interface {
GetRepoByName(ctx context.Context, name string) (*virtbuf.Cluster, error)
StartRepo(ctx context.Context, clusterID string) error
StopRepo(ctx context.Context, clusterID string) error
ListRepos(ctx context.Context) ([]*virtbuf.Cluster, error)
GetRepoStatus(ctx context.Context, clusterID string) (string, error)
}
// NewViewRepoManager creates a new ViewRepoManager with the provided API client.
func NewViewRepoManager(client ViewAPIClient) *ViewRepoManager {
return &ViewRepoManager{client: client}
}
// FindByName retrieves a cluster by name.
func (m *ViewRepoManager) FindByName(ctx context.Context, name string) (*virtbuf.Cluster, error) {
cluster, err := m.client.GetRepoByName(ctx, name)
if err != nil {
return nil, fmt.Errorf("error finding cluster by name %q: %w", name, err)
}
return cluster, nil
}
// Start initiates the startup process for the specified cluster.
func (m *ViewRepoManager) Start(ctx context.Context, cluster *virtbuf.Cluster) error {
if cluster == nil {
return errors.New("cluster cannot be nil")
}
/*
err := m.client.StartRepo(ctx, cluster.Id)
if err != nil {
return fmt.Errorf("error starting cluster %q: %w", cluster.Id, err)
}
*/
return nil
}
// Stop halts the specified cluster.
func (m *ViewRepoManager) Stop(ctx context.Context, cluster *virtbuf.Cluster) error {
if cluster == nil {
return errors.New("cluster cannot be nil")
}
/*
err := m.client.StopRepo(ctx, cluster.Id)
if err != nil {
return fmt.Errorf("error stopping cluster %q: %w", cluster.Id, err)
}
*/
return nil
}
// List retrieves all available clusters.
func (m *ViewRepoManager) List(ctx context.Context) ([]*virtbuf.Cluster, error) {
/*
clusters, err := m.client.ListRepos(ctx)
if err != nil {
return nil, fmt.Errorf("error listing clusters: %w", err)
}
return clusters, nil
*/
return nil, errors.New("List not done yet")
}
// Status checks the current status of a specified cluster.
func (m *ViewRepoManager) Status(ctx context.Context, cluster *virtbuf.Cluster) (string, error) {
if cluster == nil {
return "", errors.New("cluster cannot be nil")
}
/*
status, err := m.client.GetRepoStatus(ctx, cluster.Id)
if err != nil {
return "", fmt.Errorf("error getting status of cluster %q: %w", cluster.Id, err)
}
*/
return "", nil
}

View File

@ -1,32 +0,0 @@
package repostatus
import (
"strings"
"go.wit.com/log"
)
func (rs *RepoStatus) setGitCommands() {
var line1, line2, line3 []string
var all [][]string
newTag := rs.newversion.String()
line1 = append(line1, "git", "tag", "v"+newTag, "-m", rs.versionMessage.String())
all = append(all, line1)
line2 = append(line2, "git", "push", "--tags")
all = append(all, line2)
line3 = append(line3, "git", "push", "--prune", "--tags")
all = append(all, line3)
rs.versionCmds = all
var tmp []string
// convert to displayable to the user text
for _, line := range all {
s := strings.Join(line, " ")
log.Log(INFO, "s =", s)
tmp = append(tmp, s)
}
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
}

View File

@ -1,41 +0,0 @@
package repostatus
// reverts master to devel
// used in the unwind process of making GUI releases
/*
func (rs *RepoStatus) RevertMasterToDevel() bool {
if rs.CheckDirty() {
log.Info("sorry, it's still dirty")
return false
}
curName := rs.GetCurrentBranchName()
dName := rs.GetDevelBranchName()
mName := rs.GetMasterBranchName()
if curName != mName {
log.Info("repo is not working from main branch", curName, "!=", mName)
return false
}
log.Info("reset master to devel", curName, rs.String())
var all [][]string
all = append(all, []string{"git", "checkout", dName}) // switch to the devel branch
all = append(all, []string{"git", "branch", "-D", mName})
all = append(all, []string{"git", "branch", mName}) // make a master branch based on devel
all = append(all, []string{"git", "checkout", mName})
all = append(all, []string{"git", "push", "--set-upstream", "--force", "origin", mName})
// don't do anything with tags here
// all = append(all, []string{"git", "tag", "--delete", release.version.String()})
// all = append(all, []string{"git", "push", "--delete", "origin", release.version.String()})
if rs.DoAll(all) {
log.Info("EVERYTHING OK. RERELEASED", rs.String())
return true
}
log.Info("SOMETHING FAILED")
return false
}
*/

View File

@ -1,36 +0,0 @@
package repostatus
import (
"time"
)
// timeFunction takes a function as an argument and returns the execution time.
func timeFunction(f func()) time.Duration {
startTime := time.Now() // Record the start time
f() // Execute the function
return time.Since(startTime) // Calculate the elapsed time
}
func (ls *RepoStatus) SetSpeedActual(s string) {
if !ls.Ready() {
return
}
ls.speedActual.SetValue(s)
}
func (rs *RepoStatus) setSpeed(duration time.Duration) {
s := fmt.Sprint(duration)
if rs.speedActual == nil {
log.Log(WARN, "rs.speedActual == nil")
return
}
rs.speedActual.SetValue(s)
if duration > 200*time.Millisecond {
rs.speed.SetValue("SLOW")
} else if duration > 50*time.Millisecond {
rs.speed.SetValue("OK")
} else {
rs.speed.SetValue("FAST")
}
}

View File

@ -47,38 +47,3 @@ func (rs *RepoStatus) CheckGitState() string {
rs.gitState.SetText(state)
return state
}
/*
func (rs *RepoStatus) setState() {
pb := rs.pb
rs.changed = false
if pb.CheckDirty() {
log.Log(REPO, "CheckDirty() true")
rs.gitState.SetText("dirty")
return
}
if pb.GetUserVersion() != pb.GetDevelVersion() {
rs.gitState.SetText("merge to devel")
return
}
if pb.GetDevelVersion() != pb.GetMasterVersion() {
rs.gitState.SetText("merge to main")
return
}
if pb.GetLastTag() != pb.GetMasterVersion() {
rs.gitState.SetText("unchanged")
return
}
if pb.CheckBranches() {
log.Log(REPO, "Branches are Perfect")
rs.gitState.SetText("PERFECT")
return
}
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
rs.gitState.SetText("unknown branches")
}
*/

127
windowBranches.go Normal file
View File

@ -0,0 +1,127 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
"go.wit.com/gui"
)
type repoBranchesWindow struct {
repo *gitpb.Repo // the repo protobuf
win *gadgets.BasicWindow // the patches window
stack *gui.Node // the top box set as vertical
//shelf *gui.Node // the first box in the stack, set as horizontal
//grid *gui.Node // the list of available patches
//setgrid *gui.Node // the list of each patchset
}
// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow
// is the window hidden right now?
func (w *repoBranchesWindow) Hidden() bool {
return w.win.Hidden()
}
// switches between the window being visable or hidden on the desktop
func (w *repoBranchesWindow) Toggle() {
if w.Hidden() {
w.Show()
} else {
w.Hide()
}
}
// hides the window completely
func (w *repoBranchesWindow) Show() {
w.win.Show()
}
func (w *repoBranchesWindow) Hide() {
w.win.Hide()
}
// should be the first box/widget in the window
// greys out the window to the user
func (w *repoBranchesWindow) Disable() {
w.stack.Disable()
}
func (w *repoBranchesWindow) Enable() {
w.stack.Enable()
}
// you can only have one of these
func MakeRepoBranchesWindow(repo *gitpb.Repo) *repoBranchesWindow {
pw := new(repoBranchesWindow)
// sync.Once()
pw.win = gadgets.RawBasicWindow("Branches for " + repo.GetGoPath())
pw.win.Make()
pw.stack = pw.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
pw.win.Custom = func() {
log.Info("Got close. setting win.Hide()")
// sets the hidden flag to false so Toggle() works
pw.win.Hide()
}
grid := pw.stack.NewGrid("", 0, 0)
grid.NewGroup("Branches")
grid.NextRow()
grid.NewGroup("Name")
grid.NewGroup("Forge use")
grid.NewGroup("Ref Version")
grid.NewGroup("Type")
grid.NewGroup("Hash")
grid.NextRow()
/*
for _, b := range repo.GetLocalBranches() {
hash := repo.GetBranchHash(b)
grid.NewLabel(b)
grid.NewLabel(repo.GetBranchVersion(b))
if s, err := repo.GetHashName(hash); err == nil {
grid.NewLabel(s)
} else {
grid.NewLabel("err")
}
grid.NewLabel("local")
grid.NewLabel(hash)
grid.NewButton("Delete", func() {
repo.RunVerbose([]string{"git", "branch", "-D", b})
})
grid.NextRow()
}
for _, b := range repo.GetRemoteBranches() {
hash := repo.GetBranchHash(b)
grid.NewLabel(b)
forgeuse := repo.GetBranchVersion(b)
grid.NewLabel(forgeuse)
if s, err := repo.GetHashName(hash); err == nil {
grid.NewLabel(s)
} else {
grid.NewLabel("")
}
grid.NewLabel("remote")
grid.NewLabel(hash)
if b == "origin/HEAD" || forgeuse == "remote master" {
// can't delete these
} else {
grid.NewButton("Delete Remote", func() {
})
}
grid.NextRow()
}
*/
return pw
}

View File

@ -1,8 +1,6 @@
package repostatus
import (
"os"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
@ -14,26 +12,6 @@ func init() {
windowMap = make(map[string]*RepoStatus)
}
/*
// deprecate this
func ListAllOld() {
}
// returns the object for the path
// deprecate this
func FindPathOld(path string) *RepoStatus {
if windowMap[path] == nil {
log.Log(INFO, "FindPath() not initialized yet", path)
return nil
}
return windowMap[path]
}
func SetWorkPath(path string) {
os.Setenv("REPO_WORK_PATH", path)
}
*/
// makes a window of the status of the repo
// don't worry, you can think of it like Sierpinski carpet
// it's doesn't need to be displayed so it'll work fine even in an embedded space
@ -62,7 +40,7 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
group := basebox.NewGroup("stuff")
primarybox := group.Box()
primarybox.Horizontal()
box2 := group.Box()
// box2 := group.Box()
rs.ready = true
rs.window.Custom = func() {
rs.Hide()
@ -75,39 +53,10 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
// display the git branches and options
rs.makeBranchesBox(primarybox)
// var win *gadgets.BasicWindow
// show standard git commit and merge controls
rs.drawGitCommands(primarybox)
// save ~/go/src & the whole path strings
rs.path.SetValue(path)
rs.goSrcPath.SetValue(os.Getenv("FORGE_GOSRC"))
rs.realPath.SetValue(rs.pb.GetFullPath())
// add all the tags
rs.makeTagBox(box2)
// rs.readGitConfig()
if rs.pb.GetReadOnly() {
rs.readOnly.SetValue("true")
} else {
rs.readOnly.SetValue("false")
}
rs.mainWorkingName.SetText(rs.pb.GetMasterBranchName())
rs.mainBranchVersion.SetLabel(rs.pb.GetMasterBranchName())
rs.develWorkingName.SetText(rs.pb.GetDevelBranchName())
rs.develBranchVersion.SetLabel(rs.pb.GetDevelBranchName())
rs.userWorkingName.SetText(rs.pb.GetUserBranchName())
rs.userBranchVersion.SetLabel(rs.pb.GetUserBranchName())
if rs.pb.GetGoPath() == "" {
// not golang repo
} else {
rs.isGoLang.SetText("true")
rs.goPath.SetText(rs.pb.GetGoPath())
}
windowMap[path] = rs
return rs, nil
}

216
windowMerge.go Normal file
View File

@ -0,0 +1,216 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
"go.wit.com/gui"
)
type repoMergeWindow struct {
repo *gitpb.Repo // the repo protobuf
win *gadgets.BasicWindow // the patches window
stack *gui.Node // the top box set as vertical
lasttag *gadgets.OneLiner // the last tag version
mainBranchVersion *gadgets.OneLiner // the primary branch version
develBranchVersion *gadgets.OneLiner // the devel branch version
userBranchVersion *gadgets.OneLiner // the user branch version
currentVersion *gadgets.OneLiner // the devel branch version
currentBranch *gadgets.OneLiner // the user branch version
mergeD *gui.Node // the merge button
mergeM *gui.Node // the merge button
}
// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow
// is the window hidden right now?
func (w *repoMergeWindow) Hidden() bool {
return w.win.Hidden()
}
// switches between the window being visable or hidden on the desktop
func (w *repoMergeWindow) Toggle() {
if w.Hidden() {
w.Show()
} else {
w.Hide()
}
}
// hides the window completely
func (w *repoMergeWindow) Show() {
w.win.Show()
w.Update()
}
func (w *repoMergeWindow) Hide() {
w.win.Hide()
}
// should be the first box/widget in the window
// greys out the window to the user
func (w *repoMergeWindow) Disable() {
w.stack.Disable()
}
func (w *repoMergeWindow) Enable() {
w.stack.Enable()
}
func (w *repoMergeWindow) Update() {
w.lasttag.SetText(w.repo.GetLastTag())
w.mainBranchVersion.SetText(w.repo.GetMasterVersion())
w.develBranchVersion.SetText(w.repo.GetDevelVersion())
w.userBranchVersion.SetText(w.repo.GetUserVersion())
w.currentBranch.SetText(w.repo.GetCurrentBranchName())
w.currentVersion.SetText(w.repo.GetCurrentVersion())
if w.repo.GetCurrentBranchName() == w.repo.GetDevelBranchName() {
w.mergeD.Enable()
} else {
w.mergeD.Disable()
}
if w.repo.GetCurrentBranchName() == w.repo.GetMasterBranchName() {
w.mergeM.Enable()
} else {
w.mergeM.Disable()
}
}
func (rs *RepoStatus) MakeRepoMergeWindow(repo *gitpb.Repo) *repoMergeWindow {
w := new(repoMergeWindow)
w.repo = repo
// sync.Once()
w.win = gadgets.RawBasicWindow("Merge controls for " + repo.GetGoPath())
w.win.Make()
w.stack = w.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
w.win.Custom = func() {
log.Info("Got close. setting win.Hide()")
// sets the hidden flag to false so Toggle() works
w.win.Hide()
}
grid := w.stack.NewGrid("", 0, 0)
grid.NewGroup("Merge Options")
grid.NextRow()
grid.NewButton("checkout user", func() {
w.Disable()
defer w.Enable()
if err := repo.CheckoutUser(); err != nil {
log.Info(repo.GetFullPath(), err)
}
w.repo.Reload()
w.Update()
})
grid.NextRow()
grid.NewButton("checkout devel", func() {
w.Disable()
defer w.Enable()
repo.CheckoutDevel()
w.repo.Reload()
w.Update()
})
w.mergeD = grid.NewButton("merge to devel", func() {
w.Disable()
defer w.Enable()
log.Info("repo:", repo.GetGoPath())
if result, err := repo.MergeToDevel(); err == nil {
log.Warn("THINGS SEEM OK", repo.GetFullPath())
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
} else {
log.Warn("THINGS FAILED ", repo.GetFullPath())
log.Warn("err", err)
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
}
w.repo.Reload()
w.Update()
})
grid.NextRow()
grid.NewButton("checkout master", func() {
w.Disable()
defer w.Enable()
repo.CheckoutMaster()
w.repo.Reload()
w.Update()
})
w.mergeM = grid.NewButton("merge to master", func() {
w.Disable()
defer w.Enable()
log.Info("repo:", repo.GetGoPath())
if result, err := repo.MergeToMaster(); err == nil {
log.Warn("THINGS SEEM OK", repo.GetFullPath())
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
} else {
log.Warn("THINGS FAILED ", repo.GetFullPath())
log.Warn("err", err)
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
}
w.repo.Reload()
w.Update()
})
grid.NextRow()
w.lasttag = gadgets.NewOneLiner(grid, "last tag") // `progname:"LASTTAG"`
grid.NextRow()
w.mainBranchVersion = gadgets.NewOneLiner(grid, "master") // `progname:"MASTERBRANCH"`
grid.NextRow()
w.develBranchVersion = gadgets.NewOneLiner(grid, "devel") // `progname:"DEVELBRANCH"`
grid.NextRow()
w.userBranchVersion = gadgets.NewOneLiner(grid, "user") // `progname:"USERBRANCH"`
grid.NextRow()
w.currentBranch = gadgets.NewOneLiner(grid, "current branch") // `progname:"CURRENTBRANCH"`
grid.NextRow()
w.currentVersion = gadgets.NewOneLiner(grid, "current version") // `progname:"CURRENTVERSION"`
grid.NextRow()
w.Update()
return w
}
/*
rs.showBranchesButton = newgrid.NewButton("find user and devel", func() {
log.Info("redo this")
})
newgrid.NextRow()
rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
log.Info("redo this")
})
newgrid.NextRow()
newgrid.NewButton("Revert master to devel", func() {
log.Info("redo this")
})
*/

View File

@ -47,7 +47,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String()
rs.develMergeB = newgrid.NewButton(label, func() {
rs.Disable()
if result, err := rs.pb.MergeUserToDevel(); err == nil {
if result, err := rs.pb.MergeToDevel(); err == nil {
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else {
log.Warn("THINGS FAILED fullAutomation() returned false", result.Error)
@ -58,7 +58,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String()
rs.mainMergeB = newgrid.NewButton(label, func() {
rs.Disable()
if result, err := rs.pb.MergeDevelToMaster(); err == nil {
if result, err := rs.pb.MergeToMaster(); err == nil {
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else {
log.Warn("THINGS FAILED fullAutomation() returned false", result.Error)
@ -113,7 +113,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
rs.Disable()
rs.pb.MergeDevelToMaster()
rs.pb.MergeToMaster()
})
// rs.releaseVersion.Hide()
newgrid.NextRow()

73
windowRepo.go Normal file
View File

@ -0,0 +1,73 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/gui"
)
type repoWindow struct {
repo *gitpb.Repo // the repo protobuf
win *gadgets.BasicWindow // the patches window
stack *gui.Node // the top box set as vertical
//shelf *gui.Node // the first box in the stack, set as horizontal
//grid *gui.Node // the list of available patches
//setgrid *gui.Node // the list of each patchset
}
// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow
// is the window hidden right now?
func (w *repoWindow) Hidden() bool {
return w.win.Hidden()
}
// switches between the window being visable or hidden on the desktop
func (w *repoWindow) Toggle() {
if w.Hidden() {
w.Show()
} else {
w.Hide()
}
}
// hides the window completely
func (w *repoWindow) Show() {
w.win.Show()
}
func (w *repoWindow) Hide() {
w.win.Hide()
}
// should be the first box/widget in the window
// greys out the window to the user
func (w *repoWindow) Disable() {
w.stack.Disable()
}
func (w *repoWindow) Enable() {
w.stack.Enable()
}
// you can only have one of these
func MakeRepoWindow(repo *gitpb.Repo) *repoWindow {
pw := new(repoWindow)
// sync.Once()
pw.win = gadgets.RawBasicWindow("Patcheset for " + repo.GetGoPath())
pw.win.Make()
pw.stack = pw.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
pw.win.Custom = func() {
// sets the hidden flag to false so Toggle() works
pw.win.Hide()
}
// grid := pw.stack.NewGrid("", 0, 0)
return pw
}