Add non-local PR template support by samcoe · Pull Request #5097 · cli/cli
This PR adds the ability to use non-local templates when opening a PR. It is mostly a copy of the work done for issue create templates.
Closes #838
samcoe
marked this pull request as ready for review
Comment on lines -208 to -211
| m.templates = make([]Template, len(issueTemplates)) | ||
| for i := range issueTemplates { | ||
| m.templates[i] = &issueTemplates[i] | ||
| } |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this work into the list functions so that they would both have the same function signatures.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on!
| return hasQuerySupport && hasMutationSupport, nil | ||
| } | ||
|
|
||
| func hasPullRequestTemplateSupport(httpClient *http.Client, hostname string) (bool, error) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function does the exact same query as hasIssueTemplateSupport, except that it scans for a different field on a Repository object. Could this lookup instead piggyback on hasIssueTemplateSupport so that fewer API calls are done?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup good call. I consolidated hasIssueTemplateSupport and hasPullRequestTemplateSupport into a single hasTemplateSupport function which uses one query and supports both issues and pull requests.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! One minor note about keeping the GraphQL query unchanged (for cache key purposes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters