[FEAT] support .forgejo
dir for issue and PR templates
This commit is contained in:
parent
599264717f
commit
271db6ff22
5 changed files with 28 additions and 2 deletions
|
@ -77,6 +77,12 @@ var IssueTemplateCandidates = []string{
|
||||||
"issue_template.md",
|
"issue_template.md",
|
||||||
"issue_template.yaml",
|
"issue_template.yaml",
|
||||||
"issue_template.yml",
|
"issue_template.yml",
|
||||||
|
".forgejo/ISSUE_TEMPLATE.md",
|
||||||
|
".forgejo/ISSUE_TEMPLATE.yaml",
|
||||||
|
".forgejo/ISSUE_TEMPLATE.yml",
|
||||||
|
".forgejo/issue_template.md",
|
||||||
|
".forgejo/issue_template.yaml",
|
||||||
|
".forgejo/issue_template.yml",
|
||||||
".gitea/ISSUE_TEMPLATE.md",
|
".gitea/ISSUE_TEMPLATE.md",
|
||||||
".gitea/ISSUE_TEMPLATE.yaml",
|
".gitea/ISSUE_TEMPLATE.yaml",
|
||||||
".gitea/ISSUE_TEMPLATE.yml",
|
".gitea/ISSUE_TEMPLATE.yml",
|
||||||
|
|
|
@ -65,6 +65,12 @@ var pullRequestTemplateCandidates = []string{
|
||||||
"pull_request_template.md",
|
"pull_request_template.md",
|
||||||
"pull_request_template.yaml",
|
"pull_request_template.yaml",
|
||||||
"pull_request_template.yml",
|
"pull_request_template.yml",
|
||||||
|
".forgejo/PULL_REQUEST_TEMPLATE.md",
|
||||||
|
".forgejo/PULL_REQUEST_TEMPLATE.yaml",
|
||||||
|
".forgejo/PULL_REQUEST_TEMPLATE.yml",
|
||||||
|
".forgejo/pull_request_template.md",
|
||||||
|
".forgejo/pull_request_template.yaml",
|
||||||
|
".forgejo/pull_request_template.yml",
|
||||||
".gitea/PULL_REQUEST_TEMPLATE.md",
|
".gitea/PULL_REQUEST_TEMPLATE.md",
|
||||||
".gitea/PULL_REQUEST_TEMPLATE.yaml",
|
".gitea/PULL_REQUEST_TEMPLATE.yaml",
|
||||||
".gitea/PULL_REQUEST_TEMPLATE.yml",
|
".gitea/PULL_REQUEST_TEMPLATE.yml",
|
||||||
|
|
|
@ -94,6 +94,10 @@ func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry, try
|
||||||
if entry.Name() == "docs" || docsEntries[0] == nil {
|
if entry.Name() == "docs" || docsEntries[0] == nil {
|
||||||
docsEntries[0] = entry
|
docsEntries[0] = entry
|
||||||
}
|
}
|
||||||
|
case ".forgejo":
|
||||||
|
if entry.Name() == ".forgejo" || docsEntries[1] == nil {
|
||||||
|
docsEntries[1] = entry
|
||||||
|
}
|
||||||
case ".gitea":
|
case ".gitea":
|
||||||
if entry.Name() == ".gitea" || docsEntries[1] == nil {
|
if entry.Name() == ".gitea" || docsEntries[1] == nil {
|
||||||
docsEntries[1] = entry
|
docsEntries[1] = entry
|
||||||
|
|
|
@ -23,6 +23,8 @@ import (
|
||||||
var templateDirCandidates = []string{
|
var templateDirCandidates = []string{
|
||||||
"ISSUE_TEMPLATE",
|
"ISSUE_TEMPLATE",
|
||||||
"issue_template",
|
"issue_template",
|
||||||
|
".forgejo/ISSUE_TEMPLATE",
|
||||||
|
".forgejo/issue_template",
|
||||||
".gitea/ISSUE_TEMPLATE",
|
".gitea/ISSUE_TEMPLATE",
|
||||||
".gitea/issue_template",
|
".gitea/issue_template",
|
||||||
".github/ISSUE_TEMPLATE",
|
".github/ISSUE_TEMPLATE",
|
||||||
|
@ -32,6 +34,8 @@ var templateDirCandidates = []string{
|
||||||
}
|
}
|
||||||
|
|
||||||
var templateConfigCandidates = []string{
|
var templateConfigCandidates = []string{
|
||||||
|
".forgejo/ISSUE_TEMPLATE/config",
|
||||||
|
".forgejo/issue_template/config",
|
||||||
".gitea/ISSUE_TEMPLATE/config",
|
".gitea/ISSUE_TEMPLATE/config",
|
||||||
".gitea/issue_template/config",
|
".gitea/issue_template/config",
|
||||||
".github/ISSUE_TEMPLATE/config",
|
".github/ISSUE_TEMPLATE/config",
|
||||||
|
|
|
@ -55,12 +55,18 @@ func getMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr *issue
|
||||||
}
|
}
|
||||||
|
|
||||||
if mergeStyle != "" {
|
if mergeStyle != "" {
|
||||||
templateFilepath := fmt.Sprintf(".gitea/default_merge_message/%s_TEMPLATE.md", strings.ToUpper(string(mergeStyle)))
|
|
||||||
commit, err := baseGitRepo.GetBranchCommit(pr.BaseRepo.DefaultBranch)
|
commit, err := baseGitRepo.GetBranchCommit(pr.BaseRepo.DefaultBranch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
templateContent, err := commit.GetFileContent(templateFilepath, setting.Repository.PullRequest.DefaultMergeMessageSize)
|
|
||||||
|
templateFilepathForgejo := fmt.Sprintf(".forgejo/default_merge_message/%s_TEMPLATE.md", strings.ToUpper(string(mergeStyle)))
|
||||||
|
templateFilepathGitea := fmt.Sprintf(".gitea/default_merge_message/%s_TEMPLATE.md", strings.ToUpper(string(mergeStyle)))
|
||||||
|
|
||||||
|
templateContent, err := commit.GetFileContent(templateFilepathForgejo, setting.Repository.PullRequest.DefaultMergeMessageSize)
|
||||||
|
if _, ok := err.(git.ErrNotExist); ok {
|
||||||
|
templateContent, err = commit.GetFileContent(templateFilepathGitea, setting.Repository.PullRequest.DefaultMergeMessageSize)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !git.IsErrNotExist(err) {
|
if !git.IsErrNotExist(err) {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
|
|
Loading…
Reference in a new issue