generate valid DebianVersions()
This commit is contained in:
parent
b2d3d13ed9
commit
412c84fcd9
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
all:
|
||||
GO111MODULE=off go build
|
||||
GO111MODULE=off go vet
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
|
37
common.go
37
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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
3
unix.go
3
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)
|
||||
|
|
Loading…
Reference in New Issue