Skip to content

Commit

Permalink
no need to check dir name
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Ranson committed Aug 14, 2024
1 parent 877b5f0 commit 3187bcc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/create_prs/create_prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func run(c *cobra.Command, _ []string) {
}

func prDescriptionUnchanged(dir *campaign.Campaign) bool {
originalPrTitleTodo := fmt.Sprintf("TODO: Title of Pull Request (%s)", dir.Name)
originalPrTitleTodo := "TODO: Title of Pull Request"
originalPrBodyTodo := "TODO: This file will serve as both a README and the description of the PR."
return dir.PrTitle == originalPrTitleTodo || strings.Contains(dir.PrBody, originalPrBodyTodo) || dir.PrTitle == ""
return strings.Contains(dir.PrTitle, originalPrTitleTodo) || strings.Contains(dir.PrBody, originalPrBodyTodo) || dir.PrTitle == ""
}
9 changes: 4 additions & 5 deletions cmd/create_prs/create_prs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/skyscanner/turbolift/internal/prompt"
"github.com/skyscanner/turbolift/internal/testsupport"
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"
)

Expand All @@ -34,8 +33,8 @@ func TestItWarnsIfDescriptionFileTemplateIsUnchanged(t *testing.T) {
fakePrompt := prompt.NewFakePromptNo()
p = fakePrompt

dirName := testsupport.PrepareTempCampaign(true, "org/repo1", "org/repo2")
testsupport.UseDefaultPrDescription(dirName)
testsupport.PrepareTempCampaign(true, "org/repo1", "org/repo2")
testsupport.UseDefaultPrDescription()

out, err := runCommand()
assert.NoError(t, err)
Expand All @@ -55,8 +54,8 @@ func TestItWarnsIfOnlyPrTitleIsUnchanged(t *testing.T) {
fakePrompt := prompt.NewFakePromptNo()
p = fakePrompt

dirName := testsupport.PrepareTempCampaign(true, "org/repo1", "org/repo2")
testsupport.UsePrTitleTodoOnly(filepath.Base(dirName))
testsupport.PrepareTempCampaign(true, "org/repo1", "org/repo2")
testsupport.UsePrTitleTodoOnly()

out, err := runCommand()
assert.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions internal/testsupport/testsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ func CreateOrUpdatePrDescriptionFile(filename string, prTitle string, prBody str
}
}

func UseDefaultPrDescription(dirName string) {
originalPrTitleTodo := fmt.Sprintf("TODO: Title of Pull Request (%s)", dirName)
func UseDefaultPrDescription() {
originalPrTitleTodo := "TODO: Title of Pull Request"
originalPrBodyTodo := "TODO: This file will serve as both a README and the description of the PR."
CreateOrUpdatePrDescriptionFile("README.md", originalPrTitleTodo, originalPrBodyTodo)
}

func UsePrTitleTodoOnly(dirName string) {
CreateOrUpdatePrDescriptionFile("README.md", fmt.Sprintf("TODO: Title of Pull Request (%s)", dirName), "updated PR body")
func UsePrTitleTodoOnly() {
CreateOrUpdatePrDescriptionFile("README.md", "TODO: Title of Pull Request", "updated PR body")
}

func UsePrBodyTodoOnly() {
Expand Down

0 comments on commit 3187bcc

Please sign in to comment.