refactor: GetDiffShortStat and fix panic caused by inconsistent "changed file number" (#39248)

This commit is contained in:
wxiaoguang
2026-09-06 05:20:42 +00:00
committed by GitHub
parent e5e7b2e76e
commit 3bd7ea4c9f
13 changed files with 143 additions and 146 deletions
+2 -3
View File
@@ -4,7 +4,6 @@
package pull
import (
"path/filepath"
"testing"
"gitea.dev/modules/git"
@@ -97,7 +96,7 @@ func TestAddCommitMessageTailer(t *testing.T) {
func TestResolveMergeMessageTemplate(t *testing.T) {
t.Run("NoDefault", func(t *testing.T) {
repo, err := git.ForceFastImportWithInit(t.Context(), filepath.Join(t.TempDir(), "test-repo"), []git.FastImportCommit{
repo, err := git.ForceFastImportWithInit(t.Context(), t.TempDir(), []git.FastImportCommit{
{Ref: "refs/heads/master", Files: []git.FastImportFile{
{Path: ".gitea/default_merge_message/REBASE_TEMPLATE.md", Content: "rebase template"},
}},
@@ -117,7 +116,7 @@ func TestResolveMergeMessageTemplate(t *testing.T) {
assert.Equal(t, "rebase template", tmpl)
})
t.Run("WithDefault", func(t *testing.T) {
repo, err := git.ForceFastImportWithInit(t.Context(), filepath.Join(t.TempDir(), "test-repo"), []git.FastImportCommit{
repo, err := git.ForceFastImportWithInit(t.Context(), t.TempDir(), []git.FastImportCommit{
{Ref: "refs/heads/master", Files: []git.FastImportFile{
{Path: ".gitea/default_merge_message/DEFAULT_TEMPLATE.md", Content: "default template"},
{Path: ".gitea/default_merge_message/REBASE_TEMPLATE.md", Content: "rebase template"},