Select PR template by <source> and <target> branch included in template's filename #165834
Replies: 1 comment
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Product Feedback
Body
Even though multiple PR templates are supported, their selection seems possible only via URL manipulation (prompting to create a separate UI on top of GH in order to get a template chooser experience).
Since the "big" overhaul of the Pull Request Template experience seems heavy and not done for years1, I propose a simpler move in this direction:
🌟 Heuristically match PR template file by
<source>and<target>branch name embedded in the template name💡 Core idea
Aside the catch-all default template
.github/PULL_REQUEST_TEMPLATE.mdhave a file naming convention2 of the.github\PULL_REQUEST_TEMPLATE\*.mdfiles, following:{baseRefName}^{compareRefName}.md(or similar3)with the refnames matched as substrings (or using globbing patterns, prefixes, etc.).
For example, given a PR template:
.github\PULL_REQUEST_TEMPLATE\main^feature.md, every PR targetingmain(if the source matches*feature*) would get this PR template, but a PRmain <- personal-experimentwould not (and fall back to the default).Similarly:
.github\PULL_REQUEST_TEMPLATE\main^.mdintercepts anything targeting*main*, and.github\PULL_REQUEST_TEMPLATE\^private.mdintercepts anything sourced from*private*Rationale
It's not a full-blown solution to all the templating needs, but caters to one of the more typical problems: i.e. certain branches (source, target or both) requiring different rules4. Such naive template choosing should have the benefit of being relatively cheap to implement (hopefully by merely adding a stage to the template lookup strategy) and not collide with existing naming schemes in use (who uses
^in their filenames? 😃 ).Scaled-down version
Only focus on the target branch name and use its full name verbatim. I.e. assuming we have
Any PR targeting
mainwill getTemplate1and everything else will fall back toTemplate2Footnotes
There are already a few great ideas on how to improve the overall UX with not much progress since a few years already 😞 . Just to name a few:
- Pull Request Templates improvements: support `.github-private` and UI for picking template #42499
- Add Pull request Template chooser similar to Issue Template chooser #4620
- Pull Request Templates Scoped to Directory #8229 ↩
Better yet, metadata inside the
.mdfiles. ↩I.e.
BASE[{baseRefName}]___COMPARE[{compareRefName}]. Ideally separators could be chosen in such a way so that they're valid cross-OS file names, but (not valid for a refname)[https://git-scm.com/docs/git-check-ref-format].^seems a good candidate ❔ ↩For example: private/feature branches being OK with a short description but a stable/hotfix branch requiring to add additional external IDs etc. ↩
Beta Was this translation helpful? Give feedback.
All reactions