Skip to content

Commit

Permalink
fix(publisher): fix ga oci judgement (#218)
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <[email protected]>

Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo authored Dec 30, 2024
1 parent 63c6b7f commit 069f4f2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions publisher/pkg/impl/funcs_tiup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const nightlyVerSuffix = "-nightly"
var (
pkgNameRegex = regexp.MustCompile(`^(.+)-v\d+\.\d+\.\d+`)
pkgVersionNightlyRegex = regexp.MustCompile(`(-\d+-g[0-9a-f]{7,})$`)
ociGATagRegex = regexp.MustCompile(`^(v\d+\.\d+\.\d+)(-\w+-)?_(linux|darwin)_(amd64|arm64)$`)
ociGATagRegex = regexp.MustCompile(`^(v\d+\.\d+\.\d+)(-\w+)?_(linux|darwin)_(amd64|arm64)$`)
ociNightlyTagRegex = regexp.MustCompile(`^(master|main)_(linux|darwin)_(amd64|arm64)$`)
tiupVersionRegex = regexp.MustCompile(`^v\d+\.\d+\.\d+.*(-nightly)$`)
)
Expand Down Expand Up @@ -162,7 +162,7 @@ func transformTiupVer(version, tag string) string {
case ociGATagRegex.MatchString(tag): // GA case
// ociGATagRegex = regexp.MustCompile(`^(v\d+\.\d+\.\d+)(-\w+)?_(linux|darwin)_(amd64|arm64)$`)
matches := ociGATagRegex.FindStringSubmatch(tag)
return strings.Join(matches[1:2], "")
return strings.Join(matches[1:3], "")
case ociNightlyTagRegex.MatchString(tag): // Nightly case
// we replace the suffix part of version: '-[0-9]+-g[0-9a-f]+$' to "-nightly"
return pkgVersionNightlyRegex.ReplaceAllString(version, "") + nightlyVerSuffix
Expand Down
31 changes: 31 additions & 0 deletions publisher/pkg/impl/funcs_tiup_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package impl

import "testing"

func Test_transformTiupVer(t *testing.T) {
type args struct {
version string
tag string
}
tests := []struct {
name string
args args
want string
}{
{
name: "test1",
args: args{
version: "v8.5.0-pre",
tag: "v8.5.0-centos7_linux_amd64",
},
want: "v8.5.0-centos7",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := transformTiupVer(tt.args.version, tt.args.tag); got != tt.want {
t.Errorf("transformTiupVer() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 069f4f2

Please sign in to comment.