package repostatus import ( "path/filepath" "go.wit.com/gui" "go.wit.com/lib/gadgets" "go.wit.com/log" ) func (rs *RepoStatus) TagExists(findname string) bool { allTags := rs.Tags.ListAll() for _, t := range allTags { tagname := t.TagString() path, filename := filepath.Split(tagname) if filename == findname { log.Info("found tag:", path, filename, "from", rs.Path()) return true } } return false } func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) { rs.gitBranchesGroup = parent.NewGroup("branches") // `progname:"BRANCHES"` // can the toolkits use these for i18n support? newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 0, 0) rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag") // `progname:"LASTTAG"` newgrid.NextRow() rs.masterBranchVersion = 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"` bname := rs.targetBranch.String() log.Info("Should switch to branch", bname, "here") var all [][]string all = append(all, []string{"git", "checkout", bname}) if rs.DoAll(all) { log.Info("branch switched to", bname) } else { log.Info("branch switched to", bname, "failed") } rs.UpdateCurrent() }) rs.targetBranch = newgrid.NewDropdown() // `progname:"TARGET"` // rs.targetBranch.AddText("master") newgrid.NextRow() // runs "git branch --all" rs.gitBranchAll() rs.showBranchesButton = newgrid.NewButton("find jcarr and devel", func() { if rs.TagExists("jcarr") { log.Log(WARN, "tag jcarr exists") } else { log.Log(WARN, "tag jcarr does not exist") } if rs.TagExists("devel") { log.Log(WARN, "tag devel exists") } else { log.Log(WARN, "tag devel does not exist") } }) newgrid.NextRow() rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() { if rs.CheckBranches() { log.Log(WARN, "Branches are perfect") } else { log.Log(WARN, "Branches are not perfect") } }) newgrid.NextRow() newgrid.NewButton("Revert master to devel", func() { rs.RevertMasterToDevel() }) }