From 0cd57443983042a43689763aba143708021c6843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 17 Feb 2021 17:08:50 +0100 Subject: [PATCH] Un-export `HasAPI` leaky abstraction --- pkg/cmd/issue/create/create.go | 4 +--- pkg/cmd/pr/shared/templates.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/issue/create/create.go b/pkg/cmd/issue/create/create.go index d2cbd5306..0b2a93cd4 100644 --- a/pkg/cmd/issue/create/create.go +++ b/pkg/cmd/issue/create/create.go @@ -207,9 +207,7 @@ func createRun(opts *CreateOptions) (err error) { if template != nil { templateContent = string(template.Body()) - if ok, _ := tpl.HasAPI(); ok { - templateNameForSubmit = template.Name() - } + templateNameForSubmit = template.NameForSubmit() } else { templateContent = string(tpl.LegacyBody()) } diff --git a/pkg/cmd/pr/shared/templates.go b/pkg/cmd/pr/shared/templates.go index 7c5871431..be2d08db2 100644 --- a/pkg/cmd/pr/shared/templates.go +++ b/pkg/cmd/pr/shared/templates.go @@ -27,6 +27,10 @@ func (t *issueTemplate) Name() string { return t.Gname } +func (t *issueTemplate) NameForSubmit() string { + return t.Gname +} + func (t *issueTemplate) Body() []byte { return []byte(t.Gbody) } @@ -95,6 +99,7 @@ func hasIssueTemplateSupport(httpClient *http.Client, hostname string) (bool, er type Template interface { Name() string + NameForSubmit() string Body() []byte } @@ -123,7 +128,7 @@ func NewTemplateManager(httpClient *http.Client, repo ghrepo.Interface, dir stri } } -func (m *templateManager) HasAPI() (bool, error) { +func (m *templateManager) hasAPI() (bool, error) { if m.isPR { return false, nil } @@ -190,7 +195,7 @@ func (m *templateManager) memoizedFetch() error { } func (m *templateManager) fetch() error { - hasAPI, err := m.HasAPI() + hasAPI, err := m.hasAPI() if err != nil { return err } @@ -247,6 +252,10 @@ func (t *filesystemTemplate) Name() string { return githubtemplate.ExtractName(t.path) } +func (t *filesystemTemplate) NameForSubmit() string { + return "" +} + func (t *filesystemTemplate) Body() []byte { return githubtemplate.ExtractContents(t.path) }