Skip to content

Commit

Permalink
check for todos only
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Ranson committed Aug 14, 2024
1 parent 18fd743 commit 1fcc16b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
18 changes: 5 additions & 13 deletions cmd/create_prs/create_prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/skyscanner/turbolift/internal/prompt"
"os"
"path"
"strings"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -72,7 +73,7 @@ func run(c *cobra.Command, _ []string) {
return
}
if prDescriptionUnchanged(dir) {
if !p.AskConfirm(fmt.Sprintf("It looks like the PR title and/or description has not been updated in %s. Are you sure you want to proceed?", prDescriptionFile)) {
if !p.AskConfirm(fmt.Sprintf("It looks like the PR title and/or description may not have been updated in %s. Are you sure you want to proceed?", prDescriptionFile)) {
return
}
}
Expand Down Expand Up @@ -141,16 +142,7 @@ func run(c *cobra.Command, _ []string) {
}

func prDescriptionUnchanged(dir *campaign.Campaign) bool {
originalPrTitle := fmt.Sprintf("TODO: Title of Pull Request (%s)", dir.Name)
originalPrBody := `TODO: This file will serve as both a README and the description of the PR. Describe the pull request using markdown in this file. Make it clear why the change is being made, and make suggestions for anything that the reviewer may need to do.
By approving this PR, you are confirming that you have adequately and effectively reviewed this change.
## How this change was made
TODO: Describe the approach that was used to select repositories for this change
TODO: Describe any shell commands, scripts, manual operations, etc, that were used to make changes
<!-- Please keep the footer below, to support turbolift usage tracking -->
<sub>This PR was generated using [turbolift](https://github.com/Skyscanner/turbolift).</sub>`
return dir.PrTitle == originalPrTitle || dir.PrBody == originalPrBody || dir.PrTitle == ""
originalPrTitleTodo := fmt.Sprintf("TODO: Title of Pull Request (%s)", dir.Name)
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 == ""
}
4 changes: 2 additions & 2 deletions cmd/create_prs/create_prs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestItWarnsIfDescriptionFileTemplateIsUnchanged(t *testing.T) {
assert.NotContains(t, out, "turbolift create-prs completed")
assert.NotContains(t, out, "2 OK, 0 skipped")

fakePrompt.AssertCalledWith(t, "It looks like the PR title and/or description has not been updated in README.md. Are you sure you want to proceed?")
fakePrompt.AssertCalledWith(t, "It looks like the PR title and/or description may not have been updated in README.md. Are you sure you want to proceed?")
}

func TestItWarnsIfDescriptionFileIsEmpty(t *testing.T) {
Expand All @@ -66,7 +66,7 @@ func TestItWarnsIfDescriptionFileIsEmpty(t *testing.T) {
assert.NotContains(t, out, "turbolift create-prs completed")
assert.NotContains(t, out, "2 OK, 0 skipped")

fakePrompt.AssertCalledWith(t, "It looks like the PR title and/or description has not been updated in custom.md. Are you sure you want to proceed?")
fakePrompt.AssertCalledWith(t, "It looks like the PR title and/or description may not have been updated in custom.md. Are you sure you want to proceed?")
}

func TestItLogsCreatePrErrorsButContinuesToTryAll(t *testing.T) {
Expand Down
15 changes: 3 additions & 12 deletions internal/testsupport/testsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,7 @@ func CreateOrUpdatePrDescriptionFile(filename string, prTitle string, prBody str
}

func UseDefaultPrDescription(dirName string) {
originalPrTitle := fmt.Sprintf("TODO: Title of Pull Request (%s)", dirName)
originalPrBody := `TODO: This file will serve as both a README and the description of the PR. Describe the pull request using markdown in this file. Make it clear why the change is being made, and make suggestions for anything that the reviewer may need to do.
By approving this PR, you are confirming that you have adequately and effectively reviewed this change.
## How this change was made
TODO: Describe the approach that was used to select repositories for this change
TODO: Describe any shell commands, scripts, manual operations, etc, that were used to make changes
<!-- Please keep the footer below, to support turbolift usage tracking -->
<sub>This PR was generated using [turbolift](https://github.com/Skyscanner/turbolift).</sub>`
CreateOrUpdatePrDescriptionFile("README.md", originalPrTitle, originalPrBody)
originalPrTitleTodo := fmt.Sprintf("TODO: Title of Pull Request (%s)", dirName)
originalPrBodyTodo := "TODO: This file will serve as both a README and the description of the PR."
CreateOrUpdatePrDescriptionFile("README.md", originalPrTitleTodo, originalPrBodyTodo)
}

0 comments on commit 1fcc16b

Please sign in to comment.