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 22:11:03 +08:00
committed by GitHub
parent a34cc4cac4
commit 2657756cac
9 changed files with 152 additions and 28 deletions
+21
View File
@@ -7,11 +7,18 @@ import (
"bytes"
"context"
"fmt"
"os"
"gitea.dev/modules/git/gitcmd"
"gitea.dev/modules/git/gitrepo"
"gitea.dev/modules/util"
)
type FastImportInit struct {
Bare bool
ObjectFormat string
}
type FastImportFile struct {
Mode EntryMode
Path string
@@ -24,6 +31,20 @@ type FastImportCommit struct {
Files []FastImportFile
}
// ForceFastImportWithInit is for mainly for testing purpose
func ForceFastImportWithInit(ctx context.Context, repoLocalPath string, commits []FastImportCommit, initOpts ...FastImportInit) (RepositoryFacade, error) {
repo := gitrepo.RepositoryUnmanaged(repoLocalPath)
initOpt := util.OptionalArg(initOpts, FastImportInit{Bare: true})
if exist, _ := IsRepositoryExist(ctx, repo); !exist {
_ = os.MkdirAll(repoLocalPath, 0o755)
err := InitRepositoryLocal(ctx, repoLocalPath, initOpt.Bare, util.IfZero(initOpt.ObjectFormat, "sha1"))
if err != nil {
return nil, err
}
}
return repo, ForceFastImport(ctx, repo, commits)
}
// ForceFastImport is for mainly for testing purpose
func ForceFastImport(ctx context.Context, repo RepositoryFacade, commits []FastImportCommit) error {
var buf bytes.Buffer