enhance: fall back to DEFAULT_TEMPLATE.md when style-specific template is missing (#38803)

Closes #38801

Introduce `DEFAULT_TEMPLATE.md` as the default message for all merge
styles.

https://gitea.com/gitea/docs/pulls/491

By the way, fix incorrect os.Expand usage for merge message & repo
template

---------

Co-authored-by: waterWang <waterWang@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
water
2026-08-07 14:11:03 +00:00
committed by GitHub
co-authored by waterWang wxiaoguang
parent a34cc4cac4
commit 2657756cac
9 changed files with 152 additions and 28 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir
"CloneURL.HTTPS": cloneLink.HTTPS,
"OwnerName": repo.OwnerName,
}
res, err := vars.Expand(string(data), match)
res, err := vars.ExpandCurlyBrace(string(data), match)
if err != nil {
// here we could just log the error and continue the rendering
log.Error("unable to expand template vars for repo README: %s, err: %v", opts.Readme, err)
+2 -6
View File
@@ -24,6 +24,7 @@ import (
"gitea.dev/modules/log"
repo_module "gitea.dev/modules/repository"
"gitea.dev/modules/setting"
"gitea.dev/modules/templates/vars"
"gitea.dev/modules/util"
"github.com/huandu/xstrings"
@@ -86,12 +87,7 @@ func generateExpansion(ctx context.Context, src string, templateRepo, generateRe
}
}
return os.Expand(src, func(key string) string {
if val, ok := expansionMap[key]; ok {
return val
}
return key
})
return vars.ExpandShellLike(src, expansionMap)
}
type giteaTemplateFileMatcher struct {