This is an automated email from the ASF dual-hosted git repository.

mgorecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 0cca236c408d81e44ee994c2d2ba49ad56df1603
Author: Michal Gorecki <[email protected]>
AuthorDate: Fri Nov 15 11:36:44 2024 +0100

    newt: Properly handle rc tags in newt info
    
    Now newt info properly prints internal repo versions
    with rc tags.
---
 newt/newtutil/repo_version.go |  5 +++++
 newt/repo/version.go          | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/newt/newtutil/repo_version.go b/newt/newtutil/repo_version.go
index b8516db6..4569dba6 100644
--- a/newt/newtutil/repo_version.go
+++ b/newt/newtutil/repo_version.go
@@ -51,6 +51,7 @@ type RepoVersion struct {
        Revision  int64
        Stability string
        Commit    string
+       Rc        bool
 }
 
 func (v *RepoVersion) IsNormalized() bool {
@@ -117,6 +118,10 @@ func (ver *RepoVersion) String() string {
                s += fmt.Sprintf("-%s", ver.Stability)
        }
 
+       if ver.Rc {
+               s += fmt.Sprintf(" (rc)")
+       }
+
        return s
 }
 
diff --git a/newt/repo/version.go b/newt/repo/version.go
index bc31af2a..8329e9da 100644
--- a/newt/repo/version.go
+++ b/newt/repo/version.go
@@ -23,6 +23,7 @@ package repo
 
 import (
        "mynewt.apache.org/newt/newt/downloader"
+       "regexp"
        "strings"
 
        log "github.com/sirupsen/logrus"
@@ -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)
                }
        }

Reply via email to