GitHub には Pull Request テンプレートの機能があります。
GitLab にも同様の機能がありますが、GitLab では複数のテンプレートを登録することが可能です。Merge Request 作成時にそのなかから選択することができます。
https://docs.gitlab.com/user/project/description_templates/
一方で GitHub では登録できるテンプレートは1つのみです。しかしこれでは作成する PR の内容によって異なるテンプレートを使いたい場合などには不便です。すこし工夫をすれば GitHub でも擬似的に複数のテンプレートの機能を実現できますのでご紹介です。
- Multiple templates for Pull Requests on Github - Stack Overflow
- https://stackoverflow.com/questions/73771068/multiple-templates-for-pull-requests-on-github
.github/pull_request_template.md は Pull Request 作成時に自動的に読み込まれるテンプレートです。このファイルの中でテンプレートのリストを表示しリンクを押してもらうことで、別途用意してあるテンプレートファイルを適用するという仕組みです。
ディレクトリ構成 #
└ .github/
├ pull_request_template.md
└ PULL_REQUEST_TEMPLATE/
├ feature-template.md
├ bugfix-template.md
└ hotfix-template.md
ファイル例 #
.github/pull_request_template.md
Switch to the `Preview` tab, then select the template from the following list:
- [feature template](?template=feature-template.md&expand=1)
- [bugfix template](?template=bugfix-template.md&expand=1)
- [hotfix template](?template=hotfix-template.md&expand=1&labels=HOTFIX)
.github/PULL_REQUEST_TEMPLATE/feature-template.md
# Feature Request
.github/PULL_REQUEST_TEMPLATE/bugfix-template.md
# Bugfix Request
.github/PULL_REQUEST_TEMPLATE/hotfix-template.md
# Hotfix Request