Skip to content

Commit

Permalink
fix: set Commit.RefRelease based on gitlab env value
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippHeuer committed Aug 2, 2024
1 parent 292cc2e commit ee4402b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/normalizer/gitlabci/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (n Normalizer) Normalize(env map[string]string) (v1.Spec, error) {
nci.Commit.RefSlug = slug.Make(env["CI_COMMIT_REF_NAME"])
nci.Commit.RefVCS = "refs/heads/" + env["CI_COMMIT_REF_NAME"]
}
nci.Commit.RefRelease = vcsrepository.ToReleaseName(nci.Commit.RefName)

// project details
projectData, err := projectdetails.GetProjectDetails(nci.Repository.Kind, nci.Repository.Remote, nci.Repository.HostType, nci.Repository.HostServer)
Expand Down
4 changes: 2 additions & 2 deletions pkg/vcsrepository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func GetVCSRepositoryInformation(dir string) (RepositoryInformation, error) {
result.Commit.RefVCS = client.VCSRefToInternalRef(head)

// release name (=name, but without leading v, without slash)
result.Commit.RefRelease = getReleaseName(result.Commit.RefName)
result.Commit.RefRelease = ToReleaseName(result.Commit.RefName)

// repository status (data[ncispec.NCI_REPOSITORY_STATUS])
// TODO: current isClean by go-git detects newlines as change, see https://github.com/go-git/go-git/issues/436
Expand Down Expand Up @@ -103,7 +103,7 @@ func GetVCSRepositoryInformation(dir string) (RepositoryInformation, error) {
return result, nil
}

func getReleaseName(input string) string {
func ToReleaseName(input string) string {
input = slug.Substitute(input, map[string]string{
"/": "-",
})
Expand Down

0 comments on commit ee4402b

Please sign in to comment.