Merge branch 'main' into feature/bots

This commit is contained in:
Jason Song
2023-01-03 09:43:23 +08:00
committed by GitHub
105 changed files with 1084 additions and 631 deletions

View File

@@ -5,7 +5,6 @@ package repository
import (
"context"
"crypto/md5"
"fmt"
"image/png"
"io"
@@ -27,7 +26,7 @@ func UploadAvatar(repo *repo_model.Repository, data []byte) error {
return err
}
newAvatar := fmt.Sprintf("%d-%x", repo.ID, md5.Sum(data))
newAvatar := avatar.HashAvatar(repo.ID, data)
if repo.Avatar == newAvatar { // upload the same picture
return nil
}

View File

@@ -5,14 +5,13 @@ package repository
import (
"bytes"
"crypto/md5"
"fmt"
"image"
"image/png"
"testing"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/avatar"
"github.com/stretchr/testify/assert"
)
@@ -28,7 +27,7 @@ func TestUploadAvatar(t *testing.T) {
err := UploadAvatar(repo, buff.Bytes())
assert.NoError(t, err)
assert.Equal(t, fmt.Sprintf("%d-%x", 10, md5.Sum(buff.Bytes())), repo.Avatar)
assert.Equal(t, avatar.HashAvatar(10, buff.Bytes()), repo.Avatar)
}
func TestUploadBigAvatar(t *testing.T) {