Skip to content

Commit

Permalink
fix: correctly consume pr title
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jul 22, 2024
1 parent 5859bae commit f9955b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/identify_imagebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func TestImageBuildConfigurationIdentification(t *testing.T) {
EnvironmentName: "pr-123",
BuildType: "pullrequest",
PRNumber: "123",
PRTitle: "My PullRequest",
PRHeadBranch: "pr-head",
PRBaseBranch: "pr-base",
PRHeadSHA: "123456",
Expand All @@ -400,7 +401,7 @@ func TestImageBuildConfigurationIdentification(t *testing.T) {
"LAGOON_PR_HEAD_BRANCH": "pr-head",
"LAGOON_PR_HEAD_SHA": "123456",
"LAGOON_PR_NUMBER": "123",
"LAGOON_PR_TITLE": "123",
"LAGOON_PR_TITLE": "My PullRequest",
"LAGOON_GIT_SHA": "abcdefg123456",
"LAGOON_GIT_SOURCE_REPOSITORY": "ssh://git@example.com/lagoon-demo.git",
"LAGOON_KUBERNETES": "remote-cluster1",
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewGenerator(
environmentName := helpers.GetEnv("ENVIRONMENT", generator.EnvironmentName, generator.Debug)
branch := helpers.GetEnv("BRANCH", generator.Branch, generator.Debug)
prNumber := helpers.GetEnv("PR_NUMBER", generator.PRNumber, generator.Debug)
prTitle := helpers.GetEnv("PR_NUMBER", generator.PRTitle, generator.Debug)
prTitle := helpers.GetEnv("PR_TITLE", generator.PRTitle, generator.Debug)
prHeadBranch := helpers.GetEnv("PR_HEAD_BRANCH", generator.PRHeadBranch, generator.Debug)
prBaseBranch := helpers.GetEnv("PR_BASE_BRANCH", generator.PRBaseBranch, generator.Debug)
environmentType := helpers.GetEnv("ENVIRONMENT_TYPE", generator.EnvironmentType, generator.Debug)
Expand Down
8 changes: 8 additions & 0 deletions internal/testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type TestData struct {
Branch string
GitSHA string
PRNumber string
PRTitle string
PRHeadBranch string
PRBaseBranch string
PRHeadSHA string
Expand Down Expand Up @@ -84,6 +85,10 @@ func SetupEnvironment(rootCmd cobra.Command, templatePath string, t TestData) (g
if err != nil {
return generator.GeneratorInput{}, err
}
err = os.Setenv("PR_TITLE", t.PRTitle)
if err != nil {
return generator.GeneratorInput{}, err
}
err = os.Setenv("PR_HEAD_BRANCH", t.PRHeadBranch)
if err != nil {
return generator.GeneratorInput{}, err
Expand Down Expand Up @@ -250,6 +255,9 @@ func GetSeedData(t TestData, defaultProjectVariables bool) TestData {
if t.PRNumber != "" {
rt.PRNumber = t.PRNumber
}
if t.PRTitle != "" {
rt.PRTitle = t.PRTitle
}
if t.PRHeadBranch != "" {
rt.PRHeadBranch = t.PRHeadBranch
}
Expand Down

0 comments on commit f9955b0

Please sign in to comment.