Un-export HasAPI leaky abstraction

This commit is contained in:
Mislav Marohnić 2021-02-17 17:08:50 +01:00
parent 83bb1bfd9d
commit 0cd5744398
2 changed files with 12 additions and 5 deletions

View file

@ -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())
}

View file

@ -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)
}