From 8b9e7df705a22fa05e7b14ab7bb7a2a3a67a0620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 7 May 2020 15:50:01 +0200 Subject: [PATCH] Fix parsing some issue template names YAML parsing sometimes gets sabotaged by asterisks that follow the end of frontmatter (`---`). We now scope YAML parsing to only frontmatter and we don't pass any contents that follow. --- pkg/githubtemplate/github_template.go | 5 +++-- pkg/githubtemplate/github_template_test.go | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/githubtemplate/github_template.go b/pkg/githubtemplate/github_template.go index 3aac35554..89cceda4c 100644 --- a/pkg/githubtemplate/github_template.go +++ b/pkg/githubtemplate/github_template.go @@ -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 } } diff --git a/pkg/githubtemplate/github_template_test.go b/pkg/githubtemplate/github_template_test.go index fa757873c..839e215b3 100644 --- a/pkg/githubtemplate/github_template_test.go +++ b/pkg/githubtemplate/github_template_test.go @@ -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(),