KEMBAR78
Add non-local PR template support by samcoe · Pull Request #5097 · cli/cli · GitHub
Skip to content

Conversation

@samcoe
Copy link
Contributor

@samcoe samcoe commented Jan 25, 2022

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 samcoe self-assigned this Jan 25, 2022
@samcoe samcoe marked this pull request as ready for review January 25, 2022 07:10
@samcoe samcoe requested a review from a team as a code owner January 25, 2022 07:10
@samcoe samcoe requested review from vilmibm and removed request for a team January 25, 2022 07:10
Comment on lines -208 to -211
m.templates = make([]Template, len(issueTemplates))
for i := range issueTemplates {
m.templates[i] = &issueTemplates[i]
}
Copy link
Contributor Author

@samcoe samcoe Jan 25, 2022

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.

Copy link
Contributor

@mislav mislav left a comment

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@samcoe samcoe requested a review from mislav January 26, 2022 07:59
Copy link
Contributor

@mislav mislav left a comment

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)

@samcoe samcoe enabled auto-merge (squash) January 29, 2022 07:31
@samcoe samcoe merged commit f0b60e3 into trunk Jan 29, 2022
@samcoe samcoe deleted the pr-templates branch January 29, 2022 07:41
@localheinz
Copy link

Thank you, @samcoe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pull request template is not used when creating a pull request in an organization with health files

3 participants