summaryrefslogtreecommitdiff
path: root/repolist.go
diff options
context:
space:
mode:
Diffstat (limited to 'repolist.go')
-rw-r--r--repolist.go114
1 files changed, 114 insertions, 0 deletions
diff --git a/repolist.go b/repolist.go
new file mode 100644
index 0000000..fae362f
--- /dev/null
+++ b/repolist.go
@@ -0,0 +1,114 @@
+// This is a simple example
+package main
+
+import (
+ "io/ioutil"
+ "strings"
+
+ "go.wit.com/log"
+
+ "go.wit.com/gui/gadgets/repostatus"
+ "go.wit.com/apps/control-panel-dns/smartwindow"
+)
+
+func (r *repo) getPath() string {
+ return r.path
+}
+
+func RemoveFirstElement(slice []string) (string, []string) {
+ if len(slice) == 0 {
+ return "", slice // Return the original slice if it's empty
+ }
+ return slice[0], slice[1:] // Return the slice without the first element
+}
+
+// returns path, master branch name, devel branch name, user branch name
+func splitLine(line string) (string, string, string, string) {
+ var path, master, devel, user string
+ parts := strings.Split(line, " ")
+ path, parts = RemoveFirstElement(parts)
+ master, parts = RemoveFirstElement(parts)
+ devel, parts = RemoveFirstElement(parts)
+ user, parts = RemoveFirstElement(parts)
+ // path, master, devel, user := strings.Split(line, " ")
+ return path, master, devel, user
+}
+
+// This creates a window
+func hellosmart() {
+ win := smartwindow.New()
+ win.SetParent(myGui)
+ win.InitWindow()
+ win.Title("hellosmart test")
+ win.Vertical()
+ win.SetDraw(smartDraw)
+ win.Make()
+
+ win.Box().NewButton("test smartwindow", func () {
+ log.Println("smart")
+ })
+}
+
+func smartDraw(sw *smartwindow.SmartWindow) {
+ sw.Box().NewButton("hello", func () {
+ log.Println("smart")
+ })
+}
+
+func myrepolist() []string {
+ content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
+ out := string(content)
+ out = strings.TrimSpace(out)
+ lines := strings.Split(out, "\n")
+ return lines
+}
+
+func (r *repo) newScan() bool {
+ if r.status == nil {
+ log.Warn("repo.status = nil. not initialized for some reason")
+ return false
+ }
+ // r.scan()
+ if repostatus.VerifyLocalGoRepo(r.getPath()) {
+ log.Warn("repo actually exists", r.getPath())
+ } else {
+ log.Warn("repo does not exist", r.getPath())
+ return false
+ }
+ mn := r.status.GetMasterName()
+ mv := r.status.GetMasterVersion()
+ r.masterVersion.Set(mn + " " + mv)
+
+ dn := r.status.GetDevelName()
+ dv := r.status.GetDevelVersion()
+ r.develVersion.Set(dn + " " + dv)
+
+ un := r.status.GetUserName()
+ uv := r.status.GetUserVersion()
+ r.jcarrVersion.Set(un + " " + uv)
+
+ cbname := r.status.GetCurrentBranchName()
+ cbversion := r.status.GetCurrentBranchVersion()
+ ltversion := r.status.GetLastTagVersion()
+ r.lastLabel.Set(cbname + " " + cbversion)
+ r.vLabel.Set(cbname + " " + ltversion)
+
+ if r.status.CheckDirty() {
+ log.Warn("CheckDirty() true")
+ r.dirtyLabel.Set("dirty")
+ return false
+ }
+ log.Warn("CheckDirty() no")
+ r.dirtyLabel.Set("not dirty")
+
+ if r.status.CheckBranches() {
+ log.Warn("Branches are Perfect")
+ r.dirtyLabel.SetText("PEFECT")
+ return true
+ } else {
+ log.Warn("Branches are not Perfect")
+ r.dirtyLabel.SetText("merge")
+ }
+
+ return false
+}