From 623fbfbf4a1e92d04779ddf0b0c340784904cd7f Mon Sep 17 00:00:00 2001 From: leovct Date: Fri, 29 Nov 2024 12:18:38 +0100 Subject: [PATCH] test: import package with same prefix name --- .../git_package_content_provider_test.go | 5 +++++ .../git_package_content_provider/locators.go | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go b/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go index a5ac4cceca..43e450d672 100644 --- a/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go @@ -610,6 +610,11 @@ func Test_isSamePackageLocalAbsoluteLocator_TestDetectionInDifferentSubdirectori require.True(t, result) } +func Test_isNotSamePackageLocalAbsoluteLocator_TestRepositoriesWithSamePrefixNames(t *testing.T) { + result := shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package2/main.star", "github.com/author/package/main.star", "github.com/author/package/") + require.False(t, result) +} + func Test_getPathToPackageRoot(t *testing.T) { githubUrlWithKurtosisPackageInSubfolder := "github.com/sample/sample-package/folder/subpackage" parsedGitUrl, err := shared_utils.ParseGitURL(githubUrlWithKurtosisPackageInSubfolder) diff --git a/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/locators.go b/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/locators.go index c5472eb361..bed6d7baa3 100644 --- a/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/locators.go +++ b/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/locators.go @@ -20,10 +20,8 @@ func isLocalLocator(locator string) bool { } func shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage(relativeOrAbsoluteLocator string, sourceModuleLocator string, rootPackageId string) bool { - isSourceModuleInRootPackage := strings.HasPrefix(sourceModuleLocator, rootPackageId) isAbsoluteLocatorInRootPackage := strings.HasPrefix(relativeOrAbsoluteLocator, rootPackageId) - return isSourceModuleInRootPackage && isAbsoluteLocatorInRootPackage }