Merge pull request #879 from cli/issue-template-name-fix

Fix parsing some issue template names
This commit is contained in:
Mislav Marohnić 2020-05-07 16:30:46 +02:00 committed by GitHub
commit 51e46c75b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -66,11 +66,12 @@ mainLoop:
// ExtractName returns the name of the template from YAML front-matter
func ExtractName(filePath string) string {
contents, err := ioutil.ReadFile(filePath)
if err == nil && detectFrontmatter(contents)[0] == 0 {
frontmatterBoundaries := detectFrontmatter(contents)
if err == nil && frontmatterBoundaries[0] == 0 {
templateData := struct {
Name string
}{}
if err := yaml.Unmarshal(contents, &templateData); err == nil && templateData.Name != "" {
if err := yaml.Unmarshal(contents[0:frontmatterBoundaries[1]], &templateData); err == nil && templateData.Name != "" {
return templateData.Name
}
}

View file

@ -148,9 +148,7 @@ name: Bug Report
about: This is how you report bugs
---
Template contents
---
More of template
**Template contents**
`,
args: args{
filePath: tmpfile.Name(),