Skip to content

Commit

Permalink
stop using string pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
vilmibm authored and vilmibm committed Nov 12, 2020
1 parent 6671106 commit 1c280d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
10 changes: 1 addition & 9 deletions pkg/cmd/pr/shared/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,5 @@ func FindTemplates(dir, path string) ([]string, string) {
templateFiles := githubtemplate.FindNonLegacy(dir, path)
legacyTemplate := githubtemplate.FindLegacy(dir, path)

// TODO stop using string pointer

lt := ""

if legacyTemplate != nil {
lt = *legacyTemplate
}

return templateFiles, lt
return templateFiles, legacyTemplate
}
8 changes: 3 additions & 5 deletions pkg/githubtemplate/github_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ mainLoop:
}

// FindLegacy returns the file path of the default(legacy) template
func FindLegacy(rootDir string, name string) *string {
// TODO why does this return a pointer to string??
func FindLegacy(rootDir string, name string) string {
namePattern := regexp.MustCompile(fmt.Sprintf(`(?i)^%s(\.|$)`, strings.ReplaceAll(name, "_", "[_-]")))

// https://help.github.com/en/github/building-a-strong-community/creating-a-pull-request-template-for-your-repository
Expand All @@ -72,12 +71,11 @@ func FindLegacy(rootDir string, name string) *string {
// detect a single template file
for _, file := range files {
if namePattern.MatchString(file.Name()) && !file.IsDir() {
result := path.Join(dir, file.Name())
return &result
return path.Join(dir, file.Name())
}
}
}
return nil
return ""
}

// ExtractName returns the name of the template from YAML front-matter
Expand Down

0 comments on commit 1c280d4

Please sign in to comment.