Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions builder/git/gitserver/gitaly/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (c *Client) getBlobInfo(ctx context.Context, repo *gitalypb.Repository, pat
if err != nil {
return nil, err
}
oidFiles := map[string]*types.File{}
oidFiles := map[string][]*types.File{}
for {
listBlobResp, err := listBlobsStream.Recv()
if err != nil {
Expand Down Expand Up @@ -421,7 +421,7 @@ func (c *Client) getBlobInfo(ctx context.Context, repo *gitalypb.Repository, pat
LfsRelativePath: LfsRelativePath,
}
if listBlobResp.Oid != "" && fileSize < lfsMaxPointerSize {
oidFiles[listBlobResp.Oid] = file
oidFiles[listBlobResp.Oid] = append(oidFiles[listBlobResp.Oid], file)
}
files = append(files, file)
}
Expand Down Expand Up @@ -454,12 +454,13 @@ func (c *Client) getBlobInfo(ctx context.Context, repo *gitalypb.Repository, pat
for _, pointer := range pointers {
p, _ := ReadPointerFromBuffer(pointer.Data)
if p.Valid() {
file := oidFiles[string(pointer.Oid)]
file.Size = p.Size
file.Lfs = true
file.SHA = p.Oid
file.LfsRelativePath = p.RelativePath()
file.LfsPointerSize = int(pointer.Size)
for _, file := range oidFiles[string(pointer.Oid)] {
file.Size = p.Size
file.Lfs = true
file.SHA = p.Oid
file.LfsRelativePath = p.RelativePath()
file.LfsPointerSize = int(pointer.Size)
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions builder/git/gitserver/gitaly/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ func TestGitalyFile_GetTree(t *testing.T) {
{Entries: []*gitalypb.TreeEntry{
{Path: []byte(prefix + "a")},
{Path: []byte(prefix + "b")},
{Path: []byte(prefix + "c")},
}, PaginationCursor: &gitalypb.PaginationCursor{NextCursor: "nc"}},
},
}, nil)
Expand All @@ -598,12 +599,14 @@ func TestGitalyFile_GetTree(t *testing.T) {
RevisionPaths: []*gitalypb.GetBlobsRequest_RevisionPath{
{Revision: "main", Path: []byte(prefix + "a")},
{Revision: "main", Path: []byte(prefix + "b")},
{Revision: "main", Path: []byte(prefix + "c")},
},
Limit: 0,
}).Return(&MockGrpcStreamClient[*gitalypb.GetBlobsResponse]{
data: []*gitalypb.GetBlobsResponse{
{Path: []byte(prefix + "a"), Mode: 1, Oid: "o1"},
{Path: []byte(prefix + "b"), Mode: 1, Oid: "o2"},
{Path: []byte(prefix + "c"), Mode: 1, Oid: "o1"},
},
}, nil)

Expand Down Expand Up @@ -643,6 +646,12 @@ size 507607173`
LfsPointerSize: 1234,
},
{Name: "b", Path: prefix + "b", Type: "dir", Mode: "1", SHA: "o2"},
{Name: "c", Path: prefix + "c", Type: "dir", Mode: "1",
SHA: "a4f0e7e96b4f6af4a1b597c2fc4a42ec9a997c64ab7da96760c40582a0ac27a5",
Lfs: true, Size: 507607173,
LfsRelativePath: "a4/f0/e7e96b4f6af4a1b597c2fc4a42ec9a997c64ab7da96760c40582a0ac27a5",
LfsPointerSize: 1234,
},
}, tree.Files)
require.Equal(t, "nc", tree.Cursor)
})
Expand Down
Loading