mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-05 10:46:45 +02:00
fix: correctly get stats for API commits (#8756)
- Instead of generating a patch and parsing its contents, use a faster and simple way to get it via `--shortstat`. - Resolves forgejo/forgejo#8725 - Regression of forgejo/forgejo#7682 - Adds unit test. - Adds integration test. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8756 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
e4cd25057f
commit
648a75e687
4 changed files with 115 additions and 7 deletions
|
@ -231,3 +231,22 @@ func TestGetFileHistoryNotOnMaster(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "1", resp.Header().Get("X-Total"))
|
||||
}
|
||||
|
||||
func TestAPIReposGitCommit(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
session := loginUser(t, "user2")
|
||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadRepository)
|
||||
|
||||
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441").
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var apiData api.Commit
|
||||
DecodeJSON(t, resp, &apiData)
|
||||
|
||||
assert.Equal(t, "f27c2b2b03dcab38beaf89b0ab4ff61f6de63441", apiData.CommitMeta.SHA)
|
||||
assert.Equal(t, 1, apiData.Stats.Total)
|
||||
assert.Equal(t, 1, apiData.Stats.Additions)
|
||||
assert.Equal(t, 0, apiData.Stats.Deletions)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue