generate valid DebianVersions()
This commit is contained in:
parent
b2d3d13ed9
commit
412c84fcd9
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
all:
|
all:
|
||||||
GO111MODULE=off go build
|
GO111MODULE=off go vet
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
|
37
common.go
37
common.go
|
@ -2,6 +2,7 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
// "go.wit.com/gui/gui"
|
// "go.wit.com/gui/gui"
|
||||||
|
@ -206,3 +207,39 @@ func (rs *RepoStatus) Name() string {
|
||||||
}
|
}
|
||||||
return rs.Path()
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -84,8 +85,7 @@ func (rs *RepoStatus) readGitConfig() error {
|
||||||
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
|
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
|
||||||
file, err = os.Open(filename)
|
file, err = os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("couldn't open .git/config")
|
return errors.New("couldn't open .git/config")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
3
unix.go
3
unix.go
|
@ -11,7 +11,6 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
|
@ -183,6 +182,7 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) {
|
||||||
// panic("fucknuts")
|
// panic("fucknuts")
|
||||||
return err, false, string(output)
|
return err, false, string(output)
|
||||||
|
|
||||||
|
/* todo: see if there is a way to get the exit value
|
||||||
// The command failed (non-zero exit status)
|
// The command failed (non-zero exit status)
|
||||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
// Assert that it is an exec.ExitError and get the exit code
|
// 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 {
|
} else {
|
||||||
log.Warn("cmd.Run() failed with %s\n", err)
|
log.Warn("cmd.Run() failed with %s\n", err)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp := string(output)
|
tmp := string(output)
|
||||||
|
|
Loading…
Reference in New Issue