Skip to content

Commit 0de0e8b

Browse files
author
gitopia1c2zfrmhra3spfrc2m5ft64hef30guf60lvtcm3
committed
Merge pull request #25 from git-remote-gitopia/handle-no-storage-update-proposal-case
2 parents 79fa7c7 + 38a3a94 commit 0de0e8b

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes will be documented here.
44

5+
## [v2.0.1] - 2025-09-08
6+
7+
- handle the cases when there is only ref update on chain
8+
59
## [v2.0.0] - 2025-09-08
610

711
- upgrade gitopia version to v6.0.0 and gitopia-go version to v0.7.0

cmd/git-remote-gitopia/gitopia.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,28 +389,38 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
389389

390390
// Only try to approve packfile/LFS updates if we actually pushed something.
391391
if len(allRefspecs) > 0 {
392-
// Approve packfile update
392+
// Try to approve packfile update if proposal exists
393393
packfileUpdateProposalRes, err := h.storageClient.PackfileUpdateProposal(context.Background(), &storagetypes.QueryPackfileUpdateProposalRequest{
394394
RepositoryId: h.remoteRepository.Id,
395395
User: h.wallet.Address(),
396396
})
397-
if err != nil {
397+
if err != nil && strings.Contains(err.Error(), "packfile update proposal not found") {
398+
// There is no change in packfile so set packfile cid to old_cid itself
399+
packfileCid = packfileRes.Packfile.OldCid
400+
} else if err != nil {
398401
return nil, err
399402
}
400-
msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id))
403+
if packfileUpdateProposalRes != nil {
404+
// Packfile update proposal exists, approve it
405+
msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id))
406+
}
407+
// If error occurs (e.g., proposal not found), continue without failing
408+
// This handles cases like tag pushes where objects already exist
401409

402410
lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposalsByRepositoryId(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest{
403411
RepositoryId: h.remoteRepository.Id,
404412
User: h.wallet.Address(),
405413
})
406-
if err != nil {
414+
if err != nil && !strings.Contains(err.Error(), "lfs object update proposal not found") {
407415
return nil, err
408416
}
409-
410-
// Approve LFS object update
411-
for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals {
412-
msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id))
417+
if lfsObjectUpdateProposalRes != nil {
418+
// Approve LFS object updates if proposals exist
419+
for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals {
420+
msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id))
421+
}
413422
}
423+
// If error occurs (e.g., no LFS proposals), continue without failing
414424
}
415425

416426
if len(setBranches) > 0 {

0 commit comments

Comments
 (0)