Skip to content

Commit 0230c33

Browse files
feat: add support for issue and pr templates (#9)
1 parent 5aee555 commit 0230c33

File tree

10 files changed

+494
-13
lines changed

10 files changed

+494
-13
lines changed

.gitea/defaults/branch_protections.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rules:
1919
block_on_official_review_requests: false
2020
block_on_outdated_branch: true
2121
dismiss_stale_approvals: true
22-
require_signed_commits: true
22+
require_signed_commits: false
2323
- branch_name: stage
2424
rule_name: stage
2525
enable_push: false

.gitea/defaults/templates.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
issue_templates:
2+
- path: .gitea/issue_template.md
3+
content: |
4+
### Issue Description
5+
[Provide a clear and concise description of the issue]
6+
7+
### Expected Behavior
8+
[Describe what you expected to happen]
9+
10+
### Current Behavior
11+
[Describe what actually happened]
12+
13+
### Steps to Reproduce
14+
1. [First Step]
15+
2. [Second Step]
16+
3. [Third Step]
17+
18+
### Environment
19+
- OS:
20+
- Browser:
21+
- Version:
22+
23+
### Additional Context
24+
[Add any other relevant information or screenshots here]
25+
26+
### Checklist
27+
- [ ] I have searched for similar issues
28+
- [ ] I have provided all necessary information
29+
- [ ] I have added appropriate labels
30+
31+
issue_configs:
32+
- path: .gitea/ISSUE_TEMPLATE/config.yaml
33+
content: |
34+
blank_issues_enabled: false
35+
contact_links:
36+
- name: Gitea Docs
37+
url: https://docs.gitea.com
38+
about: Visit the official Gitea docs site
39+
40+
pr_templates:
41+
- path: .gitea/PULL_REQUEST_TEMPLATE.md
42+
content: |
43+
## PR Type
44+
45+
What kind of change does this PR introduce?
46+
47+
```
48+
[ ] Bugfix
49+
[ ] Feature
50+
[ ] Code style update (formatting, local variables)
51+
[ ] Refactoring (no functional changes, no api changes)
52+
[ ] Build related changes
53+
[ ] CI related changes
54+
[ ] Documentation content changes
55+
[ ] Tests
56+
[ ] Other
57+
```
58+
59+
## What's new?
60+
-

BACKLOG.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Gitea Config Wave provides a simple CLI to pull settings from a "canonical" repo
4545
- 📤 **Push Settings**: Apply settings to multiple repos at once
4646
- 🛡️ **Branch Protection**: Sync branch protection rules across repos
4747
- 🎯 **Repository Settings**: Manage core repo settings and topics
48+
- 📋 **Issue & PR Templates**: Sync issue and pull request templates across Gitea repositories
4849
- 🔍 **Dry Run Mode**: Preview changes before applying them
4950
- 🤖 **Automation Ready**: Perfect for CI/CD pipelines
5051

@@ -163,6 +164,18 @@ branch_protections:
163164
require_signed_commits: true
164165
```
165166
167+
### Issue and PR Templates
168+
169+
Gitea Config Wave supports syncing issue and pull request templates across repositories. Templates can be stored in any of the [officially supported locations](https://docs.gitea.com/usage/issue-pull-request-templates), including:
170+
171+
- `.gitea/ISSUE_TEMPLATE/`
172+
- `.gitea/PULL_REQUEST_TEMPLATE/`
173+
- `.github/ISSUE_TEMPLATE/`
174+
- `.github/PULL_REQUEST_TEMPLATE/`
175+
- etc (check the [Gitea docs](https://docs.gitea.com/usage/issue-pull-request-templates) for more info)
176+
177+
When you run `pull`, it will extract templates from your source repository and store them in YAML format. When you run `push`, it will open a PR to create or update the templates in all target repositories.
178+
166179
### Repository Settings
167180

168181
```yaml

cmd/const.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
package cmd
22

33
const (
4-
DefaultConfigFile = "gitea-config-wave.yaml"
5-
DefaultOutputDir = ".gitea/defaults"
6-
DefaultRepoSettingsFile = "repo_settings.yaml"
7-
DefaultBranchProtectionsFile = "branch_protections.yaml"
8-
DefaultTagProtectionsFile = "tag_protections.yaml"
9-
DefaultWebhooksFile = "webhooks.yaml"
10-
DefaultTopicsFile = "topics.yaml"
4+
DefaultConfigFile = "gitea-config-wave.yaml"
5+
DefaultOutputDir = ".gitea/defaults"
6+
DefaultRepoSettingsFile = "repo_settings.yaml"
7+
DefaultBranchProtectionsFile = "branch_protections.yaml"
8+
DefaultTagProtectionsFile = "tag_protections.yaml"
9+
DefaultWebhooksFile = "webhooks.yaml"
10+
DefaultTopicsFile = "topics.yaml"
11+
DefaultTemplatesFile = "templates.yaml"
12+
DefaultTemplatesUpdateBranchName = "gitea-config-wave/sync-templates"
13+
DefaultTemplatesUpdateCommitMessage = "chore(docs): update PR and issue templates"
14+
DefaultTemplatesUpdatePRDescription = `# Gitea Config Wave - Issue/PR Templates Sync
15+
This PR is automatically created by [Gitea Config Wave](https://github.com/dualstacks/gitea-config-wave) to sync issue and PR templates.
16+
`
1117
DefaultTopicsUpdateStrategy = UpdateStrategyAppend
1218
DefaultBranchProtectionsUpdateStrategy = UpdateStrategyAppend
1319
DefaultTagProtectionsUpdateStrategy = UpdateStrategyAppend
1420
DefaultWebhooksUpdateStrategy = UpdateStrategyAppend
21+
DefaultTemplatesUpdateStrategy = UpdateStrategyReplace
1522
)
1623

1724
type UpdateStrategy string

cmd/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ saves them to YAML files in the output directory (defaults to .gitea/defaults).`
5959
// if cfg.Pull.TagProtections {
6060
// handlers = append(handlers, &TagProtectionsHandler{})
6161
// }
62+
if cfg.Pull.Templates {
63+
handlers = append(handlers, &TemplatesHandler{})
64+
}
6265

6366
if len(handlers) == 0 {
6467
logger.Info("🤷 no items enabled in pull config - nothing to do")

cmd/push.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ in the config file or in the command arguments.`,
6464
if cfg.Push.Webhooks {
6565
handlers = append(handlers, &WebhooksHandler{})
6666
}
67+
6768
// TODO: Not supported yet
6869
// if cfg.Push.TagProtections {
6970
// handlers = append(handlers, &TagProtectionsHandler{})
7071
// }
7172

73+
if cfg.Push.Templates {
74+
handlers = append(handlers, &TemplatesHandler{})
75+
}
76+
7277
if len(handlers) == 0 {
7378
logger.Info("🤷 no items enabled in push config - nothing to do")
7479
return nil

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@ type Config struct {
166166
BranchProtections bool `yaml:"branch_protections"`
167167
TagProtections bool `yaml:"tag_protections"`
168168
Webhooks bool `yaml:"webhooks"`
169+
Templates bool `yaml:"templates"`
169170
} `yaml:"pull"`
170171
Push struct {
171172
RepoSettings bool `yaml:"repo_settings"`
172173
Topics bool `yaml:"topics"`
173174
BranchProtections bool `yaml:"branch_protections"`
174175
TagProtections bool `yaml:"tag_protections"`
175176
Webhooks bool `yaml:"webhooks"`
177+
Templates bool `yaml:"templates"`
176178
} `yaml:"push"`
177179
Targets struct {
178180
Autodiscover bool `yaml:"autodiscover"`

0 commit comments

Comments
 (0)