Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export CreateAlternativeVersionForms function #270

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions build/utils/dotnet/dependencies/packagesconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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-- {
Expand Down
2 changes: 1 addition & 1 deletion build/utils/dotnet/dependencies/packagesconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading