Skip to content

Commit 61b7fcd

Browse files
committed
newt: Properly handle rc tags in newt info
Now newt info properly prints internal repo versions with rc tags.
1 parent c6bf556 commit 61b7fcd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

newt/newtutil/repo_version.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type RepoVersion struct {
5151
Revision int64
5252
Stability string
5353
Commit string
54+
Rc bool
5455
}
5556

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

121+
if ver.Rc {
122+
s += fmt.Sprintf(" (rc)")
123+
}
124+
120125
return s
121126
}
122127

newt/repo/version.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package repo
2323

2424
import (
2525
"mynewt.apache.org/newt/newt/downloader"
26+
"regexp"
2627
"strings"
2728

2829
log "github.com/sirupsen/logrus"
@@ -196,9 +197,18 @@ func (r *Repo) HashFromVer(ver newtutil.RepoVersion) (string, error) {
196197
// commits exist, they are not considered here.
197198
func (r *Repo) VersFromCommit(commit string) []newtutil.RepoVersion {
198199
var vers []newtutil.RepoVersion
200+
var rc bool
201+
202+
restr := `rc\d+_tag`
203+
re := regexp.MustCompile(restr)
204+
if re.MatchString(commit) {
205+
commit = re.ReplaceAllString(commit, "tag")
206+
rc = true
207+
}
199208

200209
for v, c := range r.vers {
201210
if c == commit {
211+
v.Rc = rc
202212
vers = append(vers, v)
203213
}
204214
}

0 commit comments

Comments
 (0)