package repostatus import ( "strings" "go.wit.com/log" // "go.wit.com/gui/gui" ) // reports externally if something has changed // since the last time it was asked about it func (rs *RepoStatus) Changed() (string, bool) { if !rs.Ready() { return "", false } return rs.getChanges(), rs.changed } // keeps a human readable list of things that have // changed. todo: timestampe these? func (rs *RepoStatus) getChanges() string { return rs.changes } func (rs *RepoStatus) NoteChange(s string) { rs.changed = true rs.changes += s + "\n" } // deprecate this. returns the gopath right now func (rs *RepoStatus) String() string { // log.Warn("RepoStatus.String() is to be deprecated") return rs.path.String() } // returns the go path for the repo. "go.wit.com/apps/autotypist" func (rs *RepoStatus) GoName() string { return rs.GoPath() } // not sure which name is easier to remember. probably this one func (rs *RepoStatus) GoPath() string { return rs.goSrcPath.String() } // returns the filesystem path to the repo func (rs *RepoStatus) Path() string { return rs.realPath.String() } /* func (rs *RepoStatus) GetPath() string { return rs.path.String() } */ /* func (rs *RepoStatus) Draw() { if !rs.Ready() { return } log.Log(CHANGE, "Draw() window ready =", rs.ready) rs.window.TestDraw() } */ func (rs *RepoStatus) Show() { if !rs.Ready() { return } log.Log(CHANGE, "Show() window ready =", rs.ready) rs.window.Show() } func (rs *RepoStatus) Hide() { if !rs.Ready() { return } log.Log(CHANGE, "Hide() window ready =", rs.ready) rs.window.Hide() } func (rs *RepoStatus) Toggle() { if !rs.Ready() { return } log.Log(CHANGE, "Toggle() window ready =", rs.ready) if rs.window.Hidden() { rs.Show() } else { rs.Hide() } } func (rs *RepoStatus) Ready() bool { if rs == nil { return false } if rs.window == nil { return false } return rs.ready } func (rs *RepoStatus) IsGoLang() bool { if !rs.Ready() { return false } if rs.isGoLang.String() == "true" { return true } return false } /* func (rs *RepoStatus) Initialized() bool { log.Log(CHANGE, "checking Initialized()") if rs == nil {return false} if rs.parent == nil {return false} return true } */ func (rs *RepoStatus) RepoType() string { if !rs.IsGoLang() { return "" } err, output := rs.RunCmd([]string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}) if err == nil { output = strings.Trim(output, "'") // log.Info("go package is:", output) return output } // log.Info("package is: unknown", err) return "" } func (rs *RepoStatus) BinaryName() string { // get the package name from the repo name path := rs.String() parts := strings.Split(path, "/") name := parts[len(parts)-1] return name } func (rs *RepoStatus) Build() bool { if !rs.IsGoLang() { return false } name := rs.BinaryName() // removes the binary if it already exists rs.RunCmd([]string{"rm", "-f", name}) if rs.Exists(name) { log.Warn("file could not be removed filename =", name) return false } log.Info("need to build here", rs.String()) // rs.RunCmd([]string{"go", "build", "-v", "-x"}) rs.XtermBash([]string{"go", "build", "-v", "-x"}) if rs.Exists(name) { log.Warn("build worked", name) return true } log.Warn("build failed", name) return false } // moved to repolist func (rs *RepoStatus) GetGoSumStatusOld() string { return rs.goSumStatus.String() } // moved to repolist func (rs *RepoStatus) SetGoSumStatusOld(s string) { rs.goSumStatus.SetText(s) } func (rs *RepoStatus) GetTargetVersion() string { return rs.targetReleaseVersion.String() } func (rs *RepoStatus) IncrementVersion() bool { return rs.setTag() } // TODO: run this through the sanity check! func (rs *RepoStatus) SetTargetVersion(s string) { // todo: redo setTag to do increment logic // func (rs *RepoStatus) setTag() bool { rs.targetReleaseVersion.SetText(s) }