1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-05 09:55:20 +02:00

feat: API GET /repos/{owner}/{repo}/git/blobs

This commit is contained in:
oliverpool 2025-06-13 11:36:57 +02:00
parent 07e8684a61
commit a4ea74020f
6 changed files with 167 additions and 7 deletions

View file

@ -202,3 +202,43 @@ func TestGetBlobBySHA(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, expectedGBR, gbr)
}
func TestGetBlobsBySHA(t *testing.T) {
unittest.PrepareTestEnv(t)
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, repo)
require.NoError(t, err)
defer gitRepo.Close()
gbr, err := GetBlobsBySHA(db.DefaultContext, repo, gitRepo, []string{
"ea82fc8777a24b07c26b3a4bf4e2742c03733eab", // Home.md
"6395b68e1feebb1e4c657b4f9f6ba2676a283c0b", // line.svg
"26f842bcad37fa40a1bb34cbb5ee219ee35d863d", // test.xml
})
expectedGBR := []*api.GitBlob{
{
Content: "IyBIb21lIHBhZ2UKClRoaXMgaXMgdGhlIGhvbWUgcGFnZSEK",
Encoding: "base64",
URL: "https://try.gitea.io/api/v1/repos/user2/repo2/git/blobs/ea82fc8777a24b07c26b3a4bf4e2742c03733eab",
SHA: "ea82fc8777a24b07c26b3a4bf4e2742c03733eab",
Size: 36,
},
{
Content: "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZwogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHdpZHRoPSIxMjgiCiAgIGhlaWdodD0iMTI4IgogICB2aWV3Qm94PSIwIDAgMTI4IDEyOCI+CgogIDxsaW5lIHgxPSIwIiB5MT0iNyIgeDI9IjEwIiB5Mj0iNyIgc3Ryb2tlLXdpZHRoPSIxLjUiLz4KPC9zdmc+",
Encoding: "base64",
URL: "https://try.gitea.io/api/v1/repos/user2/repo2/git/blobs/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b",
SHA: "6395b68e1feebb1e4c657b4f9f6ba2676a283c0b",
Size: 246,
},
{
Content: "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHRlc3Q+VGhpcyBpcyBYTUw8L3Rlc3Q+Cg==",
Encoding: "base64",
URL: "https://try.gitea.io/api/v1/repos/user2/repo2/git/blobs/26f842bcad37fa40a1bb34cbb5ee219ee35d863d",
SHA: "26f842bcad37fa40a1bb34cbb5ee219ee35d863d",
Size: 64,
},
}
require.NoError(t, err)
assert.Equal(t, expectedGBR, gbr)
}