deprecate the "forge mode" concept
unfortunately, this was a bad idea. boo I wasted lots of time on this. live and learn
This commit is contained in:
parent
08b7f2406c
commit
d3938adf63
|
@ -10,7 +10,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -120,6 +119,14 @@ func rillCheckoutUser(repo *gitpb.Repo) error {
|
||||||
// trys to figure out if there is still something to update
|
// trys to figure out if there is still something to update
|
||||||
func doAllCheckoutUser() error {
|
func doAllCheckoutUser() error {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
|
if argv.Force {
|
||||||
|
log.Info("going to force create user branches")
|
||||||
|
if err := makeUserBranches(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
me.forge.RillFuncError(rillCheckoutUser)
|
me.forge.RillFuncError(rillCheckoutUser)
|
||||||
count := me.forge.RillReload()
|
count := me.forge.RillReload()
|
||||||
if count != 0 {
|
if count != 0 {
|
||||||
|
@ -161,6 +168,10 @@ func rillCheckoutDevel(repo *gitpb.Repo) error {
|
||||||
// is every repo on the devel branch?
|
// is every repo on the devel branch?
|
||||||
func doAllCheckoutDevel() error {
|
func doAllCheckoutDevel() error {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
if argv.Force {
|
||||||
|
log.Info("going to force create devel branches")
|
||||||
|
makeDevelBranches()
|
||||||
|
}
|
||||||
log.Info("going to rill:")
|
log.Info("going to rill:")
|
||||||
me.forge.RillFuncError(rillCheckoutDevel)
|
me.forge.RillFuncError(rillCheckoutDevel)
|
||||||
count := me.forge.RillReload()
|
count := me.forge.RillReload()
|
||||||
|
@ -254,66 +265,28 @@ func doAllCheckoutMaster() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared this with the GUI and the command line?
|
|
||||||
func doCheckoutShared() error {
|
|
||||||
if me.argvCheckoutUser {
|
|
||||||
// log.Info("Starting git checkout user")
|
|
||||||
if argv.Force {
|
|
||||||
log.Info("going to force create user branches")
|
|
||||||
if err := makeUserBranches(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// this uses rill and is super fast
|
|
||||||
doAllCheckoutUser()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if me.argvCheckoutDevel {
|
|
||||||
// log.Info("Starting git checkout devel")
|
|
||||||
if argv.Force {
|
|
||||||
log.Info("going to force create devel branches")
|
|
||||||
makeDevelBranches()
|
|
||||||
}
|
|
||||||
// this uses rill and is super fast
|
|
||||||
doAllCheckoutDevel()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if me.argvCheckoutMaster {
|
|
||||||
log.Info("Starting git checkout master")
|
|
||||||
doAllCheckoutMaster()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
log.Info("Forge didn't know what branches to checkout")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// trys to figure out if there is still something to update
|
// trys to figure out if there is still something to update
|
||||||
// todo: redo this logic as it is terrible
|
// todo: redo this logic as it is terrible
|
||||||
|
|
||||||
func doCheckout() error {
|
func doCheckout() error {
|
||||||
if argv.Checkout.User != nil {
|
if argv.Checkout.User != nil {
|
||||||
me.argvCheckoutUser = true
|
if err := doAllCheckoutUser(); err != nil {
|
||||||
me.forge.Config.Mode = forgepb.ForgeMode_USER
|
badExit(err)
|
||||||
me.forge.Config.ConfigSave()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Checkout.Devel != nil {
|
if argv.Checkout.Devel != nil {
|
||||||
me.argvCheckoutDevel = true
|
if err := doAllCheckoutDevel(); err != nil {
|
||||||
me.forge.Config.Mode = forgepb.ForgeMode_DEVEL
|
badExit(err)
|
||||||
me.forge.Config.ConfigSave()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Checkout.Master != nil {
|
if argv.Checkout.Master != nil {
|
||||||
me.argvCheckoutMaster = true
|
if err := doAllCheckoutMaster(); err != nil {
|
||||||
me.forge.Config.Mode = forgepb.ForgeMode_MASTER
|
badExit(err)
|
||||||
me.forge.Config.ConfigSave()
|
}
|
||||||
}
|
}
|
||||||
if err := doCheckoutShared(); err != nil {
|
badExit(fmt.Errorf("did not specify what branch to checkout"))
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
okExit("")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
104
doGui.go
104
doGui.go
|
@ -209,109 +209,6 @@ func drawWindow(win *gadgets.GenericWindow) {
|
||||||
|
|
||||||
gridM.NextRow()
|
gridM.NextRow()
|
||||||
gridM.NewLabel("")
|
gridM.NewLabel("")
|
||||||
|
|
||||||
group1 := win.Stack.NewGroup("Forge Mode (deprecated)")
|
|
||||||
grid = group1.RawGrid()
|
|
||||||
me.forgeMode = grid.NewLabel("")
|
|
||||||
me.forgeMode.SetText(me.forge.GetMode())
|
|
||||||
|
|
||||||
me.newBranch = grid.NewDropdown()
|
|
||||||
me.newBranch.AddText("master")
|
|
||||||
me.newBranch.AddText("devel")
|
|
||||||
me.newBranch.AddText(me.forge.Config.GetUsername())
|
|
||||||
me.newBranch.Custom = func() {
|
|
||||||
me.setBranchB.Disable()
|
|
||||||
// toggle global values shared by the command line and the gui for doCheckout()
|
|
||||||
switch me.newBranch.String() {
|
|
||||||
case "master":
|
|
||||||
if me.forge.Config.Mode != forgepb.ForgeMode_MASTER {
|
|
||||||
me.setBranchB.Enable()
|
|
||||||
}
|
|
||||||
case "devel":
|
|
||||||
if me.forge.Config.Mode != forgepb.ForgeMode_DEVEL {
|
|
||||||
me.setBranchB.Enable()
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
if me.forge.Config.Mode != forgepb.ForgeMode_USER {
|
|
||||||
me.setBranchB.Enable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// select the branch you want to test, build and develop against
|
|
||||||
// this lets you select your user branch, but, when you are happy
|
|
||||||
// you can merge everything into the devel branch and make sure it actually
|
|
||||||
// works. Then, when that is good, merge and version everything in master
|
|
||||||
me.setBranchB = grid.NewButton("Switch mode", func() {
|
|
||||||
win.Disable()
|
|
||||||
defer win.Enable()
|
|
||||||
|
|
||||||
switch me.newBranch.String() {
|
|
||||||
case "master":
|
|
||||||
forgeSwitchMode(forgepb.ForgeMode_MASTER)
|
|
||||||
case "devel":
|
|
||||||
forgeSwitchMode(forgepb.ForgeMode_DEVEL)
|
|
||||||
default:
|
|
||||||
forgeSwitchMode(forgepb.ForgeMode_USER)
|
|
||||||
}
|
|
||||||
|
|
||||||
me.setBranchB.Disable()
|
|
||||||
})
|
|
||||||
me.setBranchB.Disable()
|
|
||||||
|
|
||||||
// set the initial button state based on the last
|
|
||||||
// forge mode the user saved in the config file
|
|
||||||
switch me.forge.Config.Mode {
|
|
||||||
case forgepb.ForgeMode_MASTER:
|
|
||||||
me.newBranch.SetText("master")
|
|
||||||
case forgepb.ForgeMode_DEVEL:
|
|
||||||
me.newBranch.SetText("devel")
|
|
||||||
case forgepb.ForgeMode_USER:
|
|
||||||
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
||||||
default:
|
|
||||||
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
||||||
}
|
|
||||||
|
|
||||||
forgeSwitchMode(me.forge.Config.Mode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify the GUI button disable/enable settings
|
|
||||||
func forgeVerifyGuiState() {
|
|
||||||
me.forgeMode.SetText(me.forge.GetMode())
|
|
||||||
|
|
||||||
me.argvCheckoutUser = false
|
|
||||||
me.argvCheckoutDevel = false
|
|
||||||
me.argvCheckoutMaster = false
|
|
||||||
|
|
||||||
switch me.forge.Config.Mode {
|
|
||||||
case forgepb.ForgeMode_MASTER:
|
|
||||||
me.argvCheckoutMaster = true
|
|
||||||
me.newBranch.SetText("master")
|
|
||||||
case forgepb.ForgeMode_DEVEL:
|
|
||||||
me.argvCheckoutDevel = true
|
|
||||||
me.newBranch.SetText("devel")
|
|
||||||
case forgepb.ForgeMode_USER:
|
|
||||||
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
||||||
me.argvCheckoutUser = true
|
|
||||||
default:
|
|
||||||
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
||||||
me.argvCheckoutUser = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sets the text in the labels in the window
|
|
||||||
// and hides and shows the buttons
|
|
||||||
func forgeSwitchMode(newMode forgepb.ForgeMode) {
|
|
||||||
if newMode == me.forge.Config.Mode {
|
|
||||||
log.Info("you are already on", newMode.String())
|
|
||||||
forgeVerifyGuiState() // doing this here initializes the button state
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
me.forge.Config.Mode = newMode
|
|
||||||
forgeVerifyGuiState() // update the button states
|
|
||||||
|
|
||||||
me.forge.Config.ConfigSave()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the magic that generates a window directly from the protocol buffer
|
// this is the magic that generates a window directly from the protocol buffer
|
||||||
|
@ -359,7 +256,6 @@ func findMergeToDevel() *gitpb.Repos {
|
||||||
found := gitpb.NewRepos()
|
found := gitpb.NewRepos()
|
||||||
|
|
||||||
for repo := range me.forge.Repos.IterByFullPath() {
|
for repo := range me.forge.Repos.IterByFullPath() {
|
||||||
|
|
||||||
// this sees if user has patches for devel. If it does, add it to found
|
// this sees if user has patches for devel. If it does, add it to found
|
||||||
if repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName()) > 0 {
|
if repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName()) > 0 {
|
||||||
found.AppendByGoPath(repo)
|
found.AppendByGoPath(repo)
|
||||||
|
|
37
doPull.go
37
doPull.go
|
@ -131,3 +131,40 @@ func doGitFetch() {
|
||||||
me.forge.ConfigSave()
|
me.forge.ConfigSave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doMergeDevel() (*gitpb.Repos, error) {
|
||||||
|
var err error
|
||||||
|
done := gitpb.NewRepos()
|
||||||
|
found := findMergeToDevel()
|
||||||
|
for repo := range found.IterAll() {
|
||||||
|
if repo.CheckDirty() {
|
||||||
|
log.Info("repo is dirty", repo.GetGoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Info("Starting merge on", repo.GetGoPath())
|
||||||
|
if repo.CheckoutDevel() {
|
||||||
|
log.Info("checkout devel failed", repo.GetGoPath())
|
||||||
|
err = fmt.Errorf("checkout devel failed")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if _, err := repo.MergeToDevel(); err != nil {
|
||||||
|
log.Info("merge from user failed", repo.GetGoPath(), err)
|
||||||
|
err = fmt.Errorf("merge from user failed")
|
||||||
|
// log.Info(strings.Join(r.Stdout, "\n"))
|
||||||
|
// log.Info(strings.Join(r.Stderr, "\n"))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done.Append(repo)
|
||||||
|
/*
|
||||||
|
if repo.CheckoutMaster() {
|
||||||
|
log.Info("checkout master failed", repo.GetGoPath())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, err := repo.MergeToMaster(); err != nil {
|
||||||
|
log.Info("merge from devel failed", repo.GetGoPath(), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return done, err
|
||||||
|
}
|
||||||
|
|
13
doSync.go
13
doSync.go
|
@ -9,7 +9,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -28,11 +27,7 @@ func doSync() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doSyncClean() error {
|
func doSyncClean() error {
|
||||||
me.argvCheckoutMaster = true
|
if err := doAllCheckoutMaster(); err != nil {
|
||||||
me.forge.Config.Mode = forgepb.ForgeMode_MASTER
|
|
||||||
me.forge.Config.ConfigSave()
|
|
||||||
|
|
||||||
if err := doCheckoutShared(); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +68,8 @@ func doSyncUser() error {
|
||||||
log.Info("Rill syncDevelBranch() ok count =", count)
|
log.Info("Rill syncDevelBranch() ok count =", count)
|
||||||
}
|
}
|
||||||
|
|
||||||
me.argvCheckoutUser = true
|
|
||||||
me.forge.Config.Mode = forgepb.ForgeMode_USER
|
|
||||||
me.forge.Config.ConfigSave()
|
|
||||||
|
|
||||||
argv.Force = true
|
argv.Force = true
|
||||||
if err := doCheckoutShared(); err != nil {
|
if err := doAllCheckoutUser(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,9 @@ type mainType struct {
|
||||||
gitAuthor *gadgets.OneLiner // ENV GIT_AUTHOR NAME and EMAIL
|
gitAuthor *gadgets.OneLiner // ENV GIT_AUTHOR NAME and EMAIL
|
||||||
|
|
||||||
// these hold the branches that the user can switch all the repositories to them
|
// these hold the branches that the user can switch all the repositories to them
|
||||||
newBranch *gui.Node // deprecate?
|
|
||||||
setBranchB *gui.Node // deprecate?
|
|
||||||
reposWinB *gui.Node // button that opens the repos window
|
reposWinB *gui.Node // button that opens the repos window
|
||||||
repoAllB *gui.Node // "all" repos button
|
repoAllB *gui.Node // "all" repos button
|
||||||
repoDirtyB *gui.Node // "dirty" repos button
|
repoDirtyB *gui.Node // "dirty" repos button
|
||||||
repoDevelMergeB *gui.Node // "merge to devel" repos button
|
repoDevelMergeB *gui.Node // "merge to devel" repos button
|
||||||
repoWritableB *gui.Node // "what repos are writable" repos button
|
repoWritableB *gui.Node // "what repos are writable" repos button
|
||||||
|
|
||||||
// deprecate these
|
|
||||||
forgeMode *gui.Node // is the user in 'master', 'devel' or 'user' branches
|
|
||||||
argvCheckoutUser bool // shared between the GUI and the command line tools
|
|
||||||
argvCheckoutDevel bool // shared between the GUI and the command line tools
|
|
||||||
argvCheckoutMaster bool // shared between the GUI and the command line tools
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,10 +236,7 @@ func makeHackModeWindow(stdwin *stdReposTableWin) {
|
||||||
stdwin.win.Disable()
|
stdwin.win.Disable()
|
||||||
defer stdwin.win.Enable()
|
defer stdwin.win.Enable()
|
||||||
|
|
||||||
me.argvCheckoutUser = false
|
if err := doAllCheckoutDevel(); err != nil {
|
||||||
me.argvCheckoutDevel = true
|
|
||||||
me.argvCheckoutMaster = false
|
|
||||||
if err := doCheckoutShared(); err != nil {
|
|
||||||
log.Info("checkout error:", err)
|
log.Info("checkout error:", err)
|
||||||
} else {
|
} else {
|
||||||
log.Info("checkout was ok")
|
log.Info("checkout was ok")
|
||||||
|
@ -247,10 +244,7 @@ func makeHackModeWindow(stdwin *stdReposTableWin) {
|
||||||
|
|
||||||
mergeUserToDevel(true)
|
mergeUserToDevel(true)
|
||||||
|
|
||||||
me.argvCheckoutUser = false
|
if err := doAllCheckoutMaster(); err != nil {
|
||||||
me.argvCheckoutDevel = false
|
|
||||||
me.argvCheckoutMaster = true
|
|
||||||
if err := doCheckoutShared(); err != nil {
|
|
||||||
log.Info("checkout error:", err)
|
log.Info("checkout error:", err)
|
||||||
} else {
|
} else {
|
||||||
log.Info("checkout was ok")
|
log.Info("checkout was ok")
|
||||||
|
|
Loading…
Reference in New Issue