Skip to content

Commit

Permalink
newt: Properly handle rc tags in newt info
Browse files Browse the repository at this point in the history
Now newt info properly prints internal repo versions
with rc tags.
  • Loading branch information
m-gorecki committed Nov 15, 2024
1 parent c6bf556 commit 61b7fcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions newt/newtutil/repo_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type RepoVersion struct {
Revision int64
Stability string
Commit string
Rc bool
}

func (v *RepoVersion) IsNormalized() bool {
Expand Down Expand Up @@ -117,6 +118,10 @@ func (ver *RepoVersion) String() string {
s += fmt.Sprintf("-%s", ver.Stability)
}

if ver.Rc {
s += fmt.Sprintf(" (rc)")
}

return s
}

Expand Down
10 changes: 10 additions & 0 deletions newt/repo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package repo

import (
"mynewt.apache.org/newt/newt/downloader"
"regexp"
"strings"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -196,9 +197,18 @@ func (r *Repo) HashFromVer(ver newtutil.RepoVersion) (string, error) {
// commits exist, they are not considered here.
func (r *Repo) VersFromCommit(commit string) []newtutil.RepoVersion {
var vers []newtutil.RepoVersion
var rc bool

restr := `rc\d+_tag`
re := regexp.MustCompile(restr)
if re.MatchString(commit) {
commit = re.ReplaceAllString(commit, "tag")
rc = true
}

for v, c := range r.vers {
if c == commit {
v.Rc = rc
vers = append(vers, v)
}
}
Expand Down

0 comments on commit 61b7fcd

Please sign in to comment.