summaryrefslogtreecommitdiff
path: root/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'common.go')
-rw-r--r--common.go160
1 files changed, 0 insertions, 160 deletions
diff --git a/common.go b/common.go
index 6480e56..08a7625 100644
--- a/common.go
+++ b/common.go
@@ -1,11 +1,6 @@
package repostatus
import (
- "os"
- "strings"
- "unicode"
-
- "go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@@ -26,30 +21,10 @@ func (rs *RepoStatus) getChanges() string {
}
func (rs *RepoStatus) NoteChange(s string) {
- log.Log(REPOWARN, "NoteChange() got", rs.String(), s)
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 filesystem path to the repo
-func (rs *RepoStatus) Path() string {
- if rs == nil {
- log.Warn("rs == nil")
- return ""
- }
- if rs.realPath == nil {
- log.Warn("rs.realPath == nil")
- return ""
- }
- return rs.realPath.String()
-}
-
func (rs *RepoStatus) Show() {
if !rs.Ready() {
return
@@ -87,138 +62,3 @@ func (rs *RepoStatus) Ready() bool {
}
return rs.ready
}
-
-func (rs *RepoStatus) IsGoLang() bool {
- if !rs.Ready() {
- return false
- }
- if rs.isGoLang.String() == "true" {
- return true
- }
- return false
-}
-
-// experiment to determine the golang package type
-func (rs *RepoStatus) RepoType() string {
- if !rs.IsGoLang() {
- return ""
- }
- if !rs.Exists("go.mod") {
- return ""
- }
- os.Setenv("GO111MODULE", "off")
- cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}
- r := shell.PathRunLog(rs.Path(), cmd, INFO)
- output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
- if r.Error != nil {
- log.Info("go package error:", r.Error)
- }
- return output
-}
-
-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.Run([]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
-}
-
-func (rs *RepoStatus) GetTargetVersion() string {
- return rs.targetReleaseVersion.String()
-}
-
-func (rs *RepoStatus) GetCurrentVersion() string {
- return rs.currentVersion.String()
-}
-
-func (rs *RepoStatus) LastTag() string {
- return rs.lasttag.String()
-}
-
-func (rs *RepoStatus) IncrementVersion() bool {
- rs.incrementRevision()
- rs.EnableSelectTag()
- rs.setTag()
- newtag := "v" + rs.newversion.String()
- rs.targetReleaseVersion.SetText(newtag)
- return true
-}
-
-// 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)
-}
-
-func (rs *RepoStatus) IsPrivate() bool {
- if rs.private.String() == "true" {
- return true
- }
- return false
-}
-
-func (rs *RepoStatus) SetPrivate(b bool) {
- if b {
- rs.private.SetText("true")
- } else {
- rs.private.SetText("false")
- }
-}
-
-func trimNonNumericFromStart(s string) string {
- for i, r := range s {
- if unicode.IsDigit(r) {
- return s[i:]
- }
- }
- return ""
-}
-
-func (rs *RepoStatus) DebianReleaseVersion() string {
- lasttag := rs.GetLastTagVersion()
- newv := trimNonNumericFromStart(lasttag)
- if newv == "" {
- newv = "0.0"
- if lasttag != "" {
- newv += "-" + lasttag
- }
- }
- return newv
-}
-
-func (rs *RepoStatus) DebianCurrentVersion() string {
- cbversion := rs.GetCurrentBranchVersion()
-
- newv := trimNonNumericFromStart(cbversion)
- if newv == "" {
- newv = "0.0"
- }
- if rs.CheckDirty() {
- newv += "-dirty"
- }
- return newv
-}