hub
hub copied to clipboard
hub pull-request should show organization-wide template
Command attempted:
Ran hub pull-request
to create a new PR in a repository belonging to a specific organization.
What happened:
Did not fetch the organization-wide PULL_REQUEST_TEMPLATE.md
from repo named .github
repo and use as pull request description. Instead used a blank description.
More info: Steps to reproduce:
- Create an organization with a repository named
.github
- Add a file PULL_REQUEST_TEMPLATE.md with some content
- In another repository in the same organization as you created the
.github
repo, checkout a new branch, change some stuff, make a commit and push the branch to github. - run
hub pull-request
Thank you for reporting this! We do not yet have support for per-organization issue nor pull request templates. I'm going to re-label this as "feature", but I can also see how you can perceive it as a bug.
Thanks for replying so quickly. I am considering trying to do a PR on this, how would you start?
Here is where the pull-request
command reads repo templates from disk: https://github.com/github/hub/blob/ec93940647a88a6389cf3afbd4d8e6c5601fe9a6/commands/pull_request.go#L302-L305
You would need to add a condition that, in case a template isn't found in this repo, fetches the templates from the ORG/.github
repo. The precise way of doing that would be up to you to figure out. To my knowledge, there isn't a GitHub API to read repo templates.
I have doubts about this functionality. Fetching per-org repo templates will add an additional overhead for every repo that doesn't have its own templates, slowing down the time since pull-request
was run to when a text editor opens for authoring PR title & message. Also it looks like it will add complexity to the code and long-term maintenance overhead, and I'm not sure how useful the feature will be in the first place.
You may take a stab implementing this, but keep in mind all these considerations and that the feature won't necessarily make it into a release considering the trade-offs.
Would be nice if this could be a configuration option or maybe something we can set via an environment variable.