Categorize Templates as Legacy and NonLegacy

This commit is contained in:
AliabbasMerchant 2020-05-23 00:03:38 +05:30
parent 01f272dead
commit 864d74d0b1
5 changed files with 173 additions and 52 deletions

View file

@ -356,7 +356,7 @@ func issueCreate(cmd *cobra.Command, args []string) error {
if baseOverride == "" {
if rootDir, err := git.ToplevelDir(); err == nil {
// TODO: figure out how to stub this in tests
templateFiles = githubtemplate.Find(rootDir, "ISSUE_TEMPLATE")
templateFiles = githubtemplate.FindNonLegacy(rootDir, "ISSUE_TEMPLATE")
}
}

View file

@ -217,7 +217,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
var templateFiles []string
if rootDir, err := git.ToplevelDir(); err == nil {
// TODO: figure out how to stub this in tests
templateFiles = githubtemplate.Find(rootDir, "PULL_REQUEST_TEMPLATE")
templateFiles = githubtemplate.FindNonLegacy(rootDir, "PULL_REQUEST_TEMPLATE")
}
err := titleBodySurvey(cmd, &tb, client, baseRepo, title, body, defs, templateFiles, true, baseRepo.ViewerCanTriage())

View file

@ -16,8 +16,8 @@ type Action int
type metadataStateType int
const (
issueMetadata metadataStateType = 0
prMetadata metadataStateType = 1
issueMetadata metadataStateType = iota
prMetadata
)
type issueMetadataState struct {
@ -118,7 +118,7 @@ func selectTemplate(templatePaths []string, metadataType metadataStateType) (str
if metadataType == issueMetadata {
templateNames = append(templateNames, "Open a blank issue")
} else if metadataType == prMetadata {
templateNames = append(templateNames, "Open a blank PR")
templateNames = append(templateNames, "Open a blank pull request")
}
selectQs := []*survey.Question{