From 985682a6e584f5e901b45edf8c910bf80e530482 Mon Sep 17 00:00:00 2001 From: Igor Zhalkin Date: Tue, 27 Aug 2024 14:00:47 +0300 Subject: [PATCH] XRAY-43991 - Export CreateAlternativeVersionForms function, which is needed for Curation Audit support for NuGet --- .../utils/dotnet/dependencies/packagesconfig.go | 16 +++++++++------- .../dotnet/dependencies/packagesconfig_test.go | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build/utils/dotnet/dependencies/packagesconfig.go b/build/utils/dotnet/dependencies/packagesconfig.go index 3baaff3d..9445877e 100644 --- a/build/utils/dotnet/dependencies/packagesconfig.go +++ b/build/utils/dotnet/dependencies/packagesconfig.go @@ -4,15 +4,17 @@ import ( "encoding/binary" "encoding/xml" "fmt" - "github.com/jfrog/build-info-go/build/utils/dotnet" - buildinfo "github.com/jfrog/build-info-go/entities" - "github.com/jfrog/build-info-go/utils" - "github.com/jfrog/gofrog/crypto" - gofrogcmd "github.com/jfrog/gofrog/io" "os" "path/filepath" "strings" "unicode/utf16" + + "github.com/jfrog/gofrog/crypto" + gofrogcmd "github.com/jfrog/gofrog/io" + + "github.com/jfrog/build-info-go/build/utils/dotnet" + buildinfo "github.com/jfrog/build-info-go/entities" + "github.com/jfrog/build-info-go/utils" ) const ( @@ -79,7 +81,7 @@ func (extractor *packagesExtractor) extract(packagesConfig *packagesConfig, glob } if pack == nil { // If it doesn't exist lets build the array of alternative versions. - alternativeVersions := createAlternativeVersionForms(nuget.Version) + alternativeVersions := CreateAlternativeVersionForms(nuget.Version) // Now let's do a loop to run over the alternative possibilities for i := 0; i < len(alternativeVersions); i++ { nPackage.version = alternativeVersions[i] @@ -110,7 +112,7 @@ func (extractor *packagesExtractor) extract(packagesConfig *packagesConfig, glob // "1.22.33" --> []string{"1.22.33.0"} // "1.22.33.44" --> []string{} // "1.0.2" --> []string{"1.0.2.0"} -func createAlternativeVersionForms(originalVersion string) []string { +func CreateAlternativeVersionForms(originalVersion string) []string { versionSlice := strings.Split(originalVersion, ".") versionSliceSize := len(versionSlice) for i := 4; i > versionSliceSize; i-- { diff --git a/build/utils/dotnet/dependencies/packagesconfig_test.go b/build/utils/dotnet/dependencies/packagesconfig_test.go index 5b849972..9a656890 100644 --- a/build/utils/dotnet/dependencies/packagesconfig_test.go +++ b/build/utils/dotnet/dependencies/packagesconfig_test.go @@ -61,7 +61,7 @@ func TestAlternativeVersionsForms(t *testing.T) { } for _, test := range tests { t.Run(test.version, func(t *testing.T) { - actual := createAlternativeVersionForms(test.version) + actual := CreateAlternativeVersionForms(test.version) sort.Strings(actual) sort.Strings(test.expected) if len(actual) != len(test.expected) {