2018-05-11 06:12:22 +05:30
---
date: "2018-05-10T16:00:00+02:00"
title: "Usage: Issue and Pull Request templates"
slug: "issue-pull-request-templates"
weight: 15
2020-12-09 12:17:06 +05:30
toc: false
2018-05-11 06:12:22 +05:30
draft: false
menu:
sidebar:
parent: "usage"
name: "Issue and Pull Request templates"
weight: 15
identifier: "issue-pull-request-templates"
---
# Issue and Pull Request Templates
2020-12-09 12:17:06 +05:30
**Table of Contents**
{{< toc > }}
2019-03-10 02:45:45 +05:30
Some projects have a standard list of questions that users need to answer
when creating an issue or pull request. Gitea supports adding templates to the
2020-11-28 11:42:22 +05:30
main branch of the repository so that they can autopopulate the form when users are
2019-03-10 02:45:45 +05:30
creating issues and pull requests. This will cut down on the initial back and forth
2019-01-28 20:53:59 +05:30
of getting some clarifying details.
2018-05-11 06:12:22 +05:30
Possible file names for issue templates:
2020-12-09 12:17:06 +05:30
- `ISSUE_TEMPLATE.md`
- `issue_template.md`
- `.gitea/ISSUE_TEMPLATE.md`
- `.gitea/issue_template.md`
- `.github/ISSUE_TEMPLATE.md`
- `.github/issue_template.md`
2018-05-11 06:12:22 +05:30
Possible file names for PR templates:
2020-12-09 12:17:06 +05:30
- `PULL_REQUEST_TEMPLATE.md`
- `pull_request_template.md`
- `.gitea/PULL_REQUEST_TEMPLATE.md`
- `.gitea/pull_request_template.md`
- `.github/PULL_REQUEST_TEMPLATE.md`
- `.github/pull_request_template.md`
2019-01-28 20:53:59 +05:30
2022-05-08 18:02:45 +05:30
Possible file names for PR default merge message templates:
- `.gitea/default_merge_message/MERGE_TEMPLATE.md`
- `.gitea/default_merge_message/REBASE_TEMPLATE.md`
- `.gitea/default_merge_message/REBASE-MERGE_TEMPLATE.md`
- `.gitea/default_merge_message/SQUASH_TEMPLATE.md`
- `.gitea/default_merge_message/MANUALLY-MERGED_TEMPLATE.md`
- `.gitea/default_merge_message/REBASE-UPDATE-ONLY_TEMPLATE.md`
You can use the following variables enclosed in `${}` inside these templates which follow [os.Expand ](https://pkg.go.dev/os#Expand ) syntax:
- BaseRepoOwnerName: Base repository owner name of this pull request
- BaseRepoName: Base repository name of this pull request
- BaseBranch: Base repository target branch name of this pull request
- HeadRepoOwnerName: Head repository owner name of this pull request
- HeadRepoName: Head repository name of this pull request
- HeadBranch: Head repository branch name of this pull request
- PullRequestTitle: Pull request's title
- PullRequestDescription: Pull request's description
- PullRequestPosterName: Pull request's poster name
- PullRequestIndex: Pull request's index number
- PullRequestReference: Pull request's reference char with index number. i.e. #1 , !2
- ClosingIssues: return a string contains all issues which will be closed by this pull request i.e. `close #1, close #2`
2020-09-11 20:18:39 +05:30
Additionally, the New Issue page URL can be suffixed with `?title=Issue+Title&body=Issue+Text` and the form will be populated with those strings. Those strings will be used instead of the template if there is one.
2020-12-09 12:17:06 +05:30
## Issue Template Directory
2020-09-11 20:18:39 +05:30
2020-11-28 11:42:22 +05:30
Alternatively, users can create multiple issue templates inside a special directory and allow users to choose one that more specifically
2020-09-11 20:18:39 +05:30
addresses their problem.
Possible directory names for issue templates:
2020-12-09 12:17:06 +05:30
- `ISSUE_TEMPLATE`
- `issue_template`
- `.gitea/ISSUE_TEMPLATE`
- `.gitea/issue_template`
- `.github/ISSUE_TEMPLATE`
- `.github/issue_template`
- `.gitlab/ISSUE_TEMPLATE`
- `.gitlab/issue_template`
2020-09-11 20:18:39 +05:30
2022-06-21 19:38:31 +05:30
Inside the directory can be multiple markdown (`.md`) issue templates of the form
2020-09-11 20:18:39 +05:30
2020-12-09 12:17:06 +05:30
```md
---
2020-09-11 20:18:39 +05:30
name: "Template Name"
about: "This template is for testing!"
title: "[TEST] "
2021-12-18 02:59:09 +05:30
ref: "main"
2020-09-11 20:18:39 +05:30
labels:
2020-12-09 12:17:06 +05:30
- bug
- "help needed"
---
2020-09-11 20:18:39 +05:30
This is the template!
```
In the above example, when a user is presented with the list of issues they can submit, this would show as `Template Name` with the description
2020-11-28 11:42:22 +05:30
`This template is for testing!` . When submitting an issue with the above example, the issue title would be pre-populated with
2020-09-11 20:18:39 +05:30
`[TEST] ` while the issue body would be pre-populated with `This is the template!` . The issue would also be assigned two labels,
2021-12-18 02:59:09 +05:30
`bug` and `help needed` , and the issue will have a reference to `main` .