Skip to content

Commit 0cd5744

Browse files
committed
Un-export HasAPI leaky abstraction
1 parent 83bb1bf commit 0cd5744

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎pkg/cmd/issue/create/create.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ func createRun(opts *CreateOptions) (err error) {
207207

208208
if template != nil {
209209
templateContent = string(template.Body())
210-
if ok, _ := tpl.HasAPI(); ok {
211-
templateNameForSubmit = template.Name()
212-
}
210+
templateNameForSubmit = template.NameForSubmit()
213211
} else {
214212
templateContent = string(tpl.LegacyBody())
215213
}

‎pkg/cmd/pr/shared/templates.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ func (t *issueTemplate) Name() string {
2727
return t.Gname
2828
}
2929

30+
func (t *issueTemplate) NameForSubmit() string {
31+
return t.Gname
32+
}
33+
3034
func (t *issueTemplate) Body() []byte {
3135
return []byte(t.Gbody)
3236
}
@@ -95,6 +99,7 @@ func hasIssueTemplateSupport(httpClient *http.Client, hostname string) (bool, er
9599

96100
type Template interface {
97101
Name() string
102+
NameForSubmit() string
98103
Body() []byte
99104
}
100105

@@ -123,7 +128,7 @@ func NewTemplateManager(httpClient *http.Client, repo ghrepo.Interface, dir stri
123128
}
124129
}
125130

126-
func (m *templateManager) HasAPI() (bool, error) {
131+
func (m *templateManager) hasAPI() (bool, error) {
127132
if m.isPR {
128133
return false, nil
129134
}
@@ -190,7 +195,7 @@ func (m *templateManager) memoizedFetch() error {
190195
}
191196

192197
func (m *templateManager) fetch() error {
193-
hasAPI, err := m.HasAPI()
198+
hasAPI, err := m.hasAPI()
194199
if err != nil {
195200
return err
196201
}
@@ -247,6 +252,10 @@ func (t *filesystemTemplate) Name() string {
247252
return githubtemplate.ExtractName(t.path)
248253
}
249254

255+
func (t *filesystemTemplate) NameForSubmit() string {
256+
return ""
257+
}
258+
250259
func (t *filesystemTemplate) Body() []byte {
251260
return githubtemplate.ExtractContents(t.path)
252261
}

0 commit comments

Comments
 (0)