mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-26 03:38:51 +08:00
Decouple diff stats query from actual diffing (#33810)
The diff stats are no longer part of the diff generation. Use `GetDiffShortStat` instead to get the total number of changed files, added lines, and deleted lines. As such, `gitdiff.GetDiff` can be simplified: It should not do more than expected. And do not run "git diff --shortstat" for pull list. Fix #31492
This commit is contained in:
@ -182,16 +182,10 @@ diff --git "\\a/README.md" "\\b/README.md"
|
||||
}
|
||||
|
||||
gotMarshaled, _ := json.MarshalIndent(got, "", " ")
|
||||
if got.NumFiles != 1 {
|
||||
if len(got.Files) != 1 {
|
||||
t.Errorf("ParsePath(%q) did not receive 1 file:\n%s", testcase.name, string(gotMarshaled))
|
||||
return
|
||||
}
|
||||
if got.TotalAddition != testcase.addition {
|
||||
t.Errorf("ParsePath(%q) does not have correct totalAddition %d, wanted %d", testcase.name, got.TotalAddition, testcase.addition)
|
||||
}
|
||||
if got.TotalDeletion != testcase.deletion {
|
||||
t.Errorf("ParsePath(%q) did not have correct totalDeletion %d, wanted %d", testcase.name, got.TotalDeletion, testcase.deletion)
|
||||
}
|
||||
file := got.Files[0]
|
||||
if file.Addition != testcase.addition {
|
||||
t.Errorf("ParsePath(%q) does not have correct file addition %d, wanted %d", testcase.name, file.Addition, testcase.addition)
|
||||
@ -407,16 +401,10 @@ index 6961180..9ba1a00 100644
|
||||
}
|
||||
|
||||
gotMarshaled, _ := json.MarshalIndent(got, "", " ")
|
||||
if got.NumFiles != 1 {
|
||||
if len(got.Files) != 1 {
|
||||
t.Errorf("ParsePath(%q) did not receive 1 file:\n%s", testcase.name, string(gotMarshaled))
|
||||
return
|
||||
}
|
||||
if got.TotalAddition != testcase.addition {
|
||||
t.Errorf("ParsePath(%q) does not have correct totalAddition %d, wanted %d", testcase.name, got.TotalAddition, testcase.addition)
|
||||
}
|
||||
if got.TotalDeletion != testcase.deletion {
|
||||
t.Errorf("ParsePath(%q) did not have correct totalDeletion %d, wanted %d", testcase.name, got.TotalDeletion, testcase.deletion)
|
||||
}
|
||||
file := got.Files[0]
|
||||
if file.Addition != testcase.addition {
|
||||
t.Errorf("ParsePath(%q) does not have correct file addition %d, wanted %d", testcase.name, file.Addition, testcase.addition)
|
||||
|
Reference in New Issue
Block a user