From ee845a7f28e88878ecfcb6623e7d607409310357 Mon Sep 17 00:00:00 2001 From: Philipp Heuer Date: Wed, 21 Aug 2024 19:16:43 +0200 Subject: [PATCH] fix: project path could return a wrong value on gitlab --- pkg/normalizer/githubactions/normalize_test.go | 3 +++ pkg/normalizer/gitlabci/normalize.go | 2 +- pkg/normalizer/gitlabci/normalize_test.go | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/normalizer/githubactions/normalize_test.go b/pkg/normalizer/githubactions/normalize_test.go index 8531d32..fe4e681 100644 --- a/pkg/normalizer/githubactions/normalize_test.go +++ b/pkg/normalizer/githubactions/normalize_test.go @@ -85,6 +85,9 @@ func TestNormalizer_Normalize_Project(t *testing.T) { }) assert.NoError(t, err) + assert.Equal(t, "normalizeci", normalized.Project.Name) + assert.Equal(t, "cidverse/normalizeci", normalized.Project.Path) + assert.Equal(t, "cidverse-normalizeci", normalized.Project.Slug) assert.Equal(t, "https://github.com/cidverse/cienvsamples", normalized.Project.Url) } diff --git a/pkg/normalizer/gitlabci/normalize.go b/pkg/normalizer/gitlabci/normalize.go index c812d19..873404f 100644 --- a/pkg/normalizer/gitlabci/normalize.go +++ b/pkg/normalizer/gitlabci/normalize.go @@ -84,7 +84,7 @@ func (n Normalizer) Normalize(env map[string]string) (v1.Spec, error) { } nci.Project.Id = nciutil.FirstNonEmpty([]string{nciutil.GetValueFromMap(env, "CI_PROJECT_ID"), projectData.Id}) nci.Project.Name = nciutil.FirstNonEmpty([]string{nciutil.GetValueFromMap(env, "CI_PROJECT_TITLE"), projectData.Name}) - nci.Project.Path = nciutil.FirstNonEmpty([]string{nciutil.GetValueFromMap(env, "CI_PROJECT_NAME"), projectData.Path}) + nci.Project.Path = nciutil.FirstNonEmpty([]string{nciutil.GetValueFromMap(env, "CI_PROJECT_PATH"), projectData.Path}) nci.Project.Slug = nciutil.FirstNonEmpty([]string{nciutil.GetValueFromMap(env, "CI_PROJECT_PATH_SLUG"), projectData.Slug}) nci.Project.Description = nciutil.FirstNonEmpty([]string{nciutil.GetValueFromMap(env, "CI_PROJECT_DESCRIPTION"), projectData.Description}) nci.Project.Topics = nciutil.FirstNonEmpty([]string{projectData.Topics}) diff --git a/pkg/normalizer/gitlabci/normalize_test.go b/pkg/normalizer/gitlabci/normalize_test.go index 90473bc..e9c6f9c 100644 --- a/pkg/normalizer/gitlabci/normalize_test.go +++ b/pkg/normalizer/gitlabci/normalize_test.go @@ -91,6 +91,7 @@ func TestNormalizer_Normalize_Project(t *testing.T) { "CI_PROJECT_ID": "35974876", "CI_PROJECT_TITLE": "cienvsamples", "CI_PROJECT_NAME": "cienvsamples", + "CI_PROJECT_PATH": "cidverse/cienvsamples", "CI_PROJECT_PATH_SLUG": "cidverse-cienvsamples", "CI_PROJECT_DESCRIPTION": "A tool to turn the continuous integration / deployment variables into a common format for generally usable scripts without any dependencies.", "CI_DEFAULT_BRANCH": "main", @@ -100,7 +101,7 @@ func TestNormalizer_Normalize_Project(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "35974876", normalized.Project.Id) assert.Equal(t, "cienvsamples", normalized.Project.Name) - assert.Equal(t, "cienvsamples", normalized.Project.Path) + assert.Equal(t, "cidverse/cienvsamples", normalized.Project.Path) assert.Equal(t, "cidverse-cienvsamples", normalized.Project.Slug) assert.Equal(t, "A tool to turn the continuous integration / deployment variables into a common format for generally usable scripts without any dependencies.", normalized.Project.Description) assert.Equal(t, "main", normalized.Project.DefaultBranch)