Skip to content

Commit c855dec

Browse files
committed
Pass current state of repository packfile in set branch and tag request
1 parent b68b5ee commit c855dec

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cmd/git-remote-gitopia/gitopia.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/gitopia/git-remote-gitopia/core/wallet"
2323
gitopiatypes "github.com/gitopia/gitopia/v6/x/gitopia/types"
2424
"github.com/gitopia/gitopia/v6/x/gitopia/utils"
25+
storagetypes "github.com/gitopia/gitopia/v6/x/storage/types"
2526
"github.com/go-git/go-git/v5/plumbing"
2627
"github.com/pkg/errors"
2728
"google.golang.org/grpc"
@@ -41,6 +42,7 @@ type GitopiaHandler struct {
4142
queryClient gitopiatypes.QueryClient
4243
feegrantClient feegrant.QueryClient
4344
bankClient banktypes.QueryClient
45+
storageClient storagetypes.QueryClient
4446

4547
chainId string
4648
remoteUserId string
@@ -105,6 +107,7 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error {
105107
serviceClient := tmservice.NewServiceClient(h.grpcConn)
106108
h.feegrantClient = feegrant.NewQueryClient(h.grpcConn)
107109
h.bankClient = banktypes.NewQueryClient(h.grpcConn)
110+
h.storageClient = storagetypes.NewQueryClient(h.grpcConn)
108111

109112
nodeInfoRes, err := serviceClient.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
110113
if err != nil {
@@ -362,19 +365,25 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
362365
}
363366
}
364367

365-
var msg []sdk.Msg
368+
packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{
369+
RepositoryId: h.remoteRepository.Id,
370+
})
371+
if err != nil {
372+
return nil, err
373+
}
366374

375+
var msg []sdk.Msg
367376
if len(setBranches) > 0 {
368377
msg = append(msg, gitopiatypes.NewMsgMultiSetBranch(h.wallet.Address(), gitopiatypes.RepositoryId{
369378
Id: h.remoteRepository.Owner.Id,
370379
Name: h.remoteRepository.Name,
371-
}, setBranches))
380+
}, setBranches, packfileRes.Packfile.Cid))
372381
}
373382
if len(setTags) > 0 {
374383
msg = append(msg, gitopiatypes.NewMsgMultiSetTag(h.wallet.Address(), gitopiatypes.RepositoryId{
375384
Id: h.remoteRepository.Owner.Id,
376385
Name: h.remoteRepository.Name,
377-
}, setTags))
386+
}, setTags, packfileRes.Packfile.Cid))
378387
}
379388
if len(deleteBranches) > 0 {
380389
msg = append(msg, gitopiatypes.NewMsgMultiDeleteBranch(h.wallet.Address(), gitopiatypes.RepositoryId{

0 commit comments

Comments
 (0)