summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-03-02 17:52:45 -0600
committerJeff Carr <[email protected]>2024-03-02 17:52:45 -0600
commit412c84fcd9f40350eeec767b7367d6d1fed0fabb (patch)
treec698fa27508b1bcca498e75330f503eec50b0bc3
parentb2d3d13ed9992aab812184009303e1a1be305194 (diff)
generate valid DebianVersions()v0.21.4
-rw-r--r--Makefile2
-rw-r--r--common.go37
-rw-r--r--gitConfig.go4
-rw-r--r--unix.go3
4 files changed, 42 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 2a5b530..350c71e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
all:
- GO111MODULE=off go build
+ GO111MODULE=off go vet
goimports:
goimports -w *.go
diff --git a/common.go b/common.go
index 7daa87a..eab7925 100644
--- a/common.go
+++ b/common.go
@@ -2,6 +2,7 @@ package repostatus
import (
"strings"
+ "unicode"
"go.wit.com/log"
// "go.wit.com/gui/gui"
@@ -206,3 +207,39 @@ func (rs *RepoStatus) Name() string {
}
return rs.Path()
}
+
+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
+ }
+ }
+ log.Info("ValidDebianPackageVersion:", newv)
+ return newv
+}
+
+func (rs *RepoStatus) DebianCurrentVersion() string {
+ cbversion := rs.GetCurrentBranchVersion()
+
+ newv := trimNonNumericFromStart(cbversion)
+ if newv == "" {
+ newv = "0.0"
+ }
+ if rs.CheckDirty() {
+ newv += "-dirty"
+ }
+ log.Info("ValidDebianPackageVersion:", newv)
+ return newv
+}
diff --git a/gitConfig.go b/gitConfig.go
index ce8834c..595345f 100644
--- a/gitConfig.go
+++ b/gitConfig.go
@@ -2,6 +2,7 @@ package repostatus
import (
"bufio"
+ "errors"
"os"
"path/filepath"
"strings"
@@ -84,8 +85,7 @@ func (rs *RepoStatus) readGitConfig() error {
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
file, err = os.Open(filename)
if err != nil {
- panic("couldn't open .git/config")
- return nil
+ return errors.New("couldn't open .git/config")
}
}
defer file.Close()
diff --git a/unix.go b/unix.go
index 12ed300..6c7faef 100644
--- a/unix.go
+++ b/unix.go
@@ -11,7 +11,6 @@ import (
"regexp"
"strconv"
"strings"
- "syscall"
"time"
"go.wit.com/lib/gui/shell"
@@ -183,6 +182,7 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) {
// panic("fucknuts")
return err, false, string(output)
+ /* todo: see if there is a way to get the exit value
// The command failed (non-zero exit status)
if exitErr, ok := err.(*exec.ExitError); ok {
// Assert that it is an exec.ExitError and get the exit code
@@ -192,6 +192,7 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) {
} else {
log.Warn("cmd.Run() failed with %s\n", err)
}
+ */
}
tmp := string(output)