@@ -256,6 +256,18 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
256256 return nil , fmt .Errorf ("fatal: you don't have write permissions to this repository" )
257257 }
258258
259+ // Check for existing pending packfile update proposal
260+ _ , err = h .storageClient .PackfileUpdateProposal (context .Background (), & storagetypes.QueryPackfileUpdateProposalRequest {
261+ RepositoryId : h .remoteRepository .Id ,
262+ User : h .wallet .Address (),
263+ })
264+ if err == nil {
265+ return nil , fmt .Errorf ("fatal: there is already a pending packfile update proposal for this repository. Please wait for it to be processed or expired before pushing again" )
266+ }
267+ if ! strings .Contains (err .Error (), "packfile update proposal not found" ) {
268+ return nil , fmt .Errorf ("error checking for pending proposals: %v" , err )
269+ }
270+
259271 gitServerHost , err := config .GitConfigGet (config .GitopiaConfigGitServerHostOption )
260272 if err != nil {
261273 return nil , err
@@ -394,24 +406,19 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
394406 RepositoryId : h .remoteRepository .Id ,
395407 User : h .wallet .Address (),
396408 })
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 {
409+ if err != nil {
401410 return nil , err
402411 }
403412 if packfileUpdateProposalRes != nil {
404413 // Packfile update proposal exists, approve it
405414 msg = append (msg , storagetypes .NewMsgApproveRepositoryPackfileUpdate (h .wallet .Address (), packfileUpdateProposalRes .PackfileUpdateProposal .Id ))
406415 }
407- // If error occurs (e.g., proposal not found), continue without failing
408- // This handles cases like tag pushes where objects already exist
409416
410417 lfsObjectUpdateProposalRes , err := h .storageClient .LFSObjectUpdateProposalsByRepositoryId (context .Background (), & storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest {
411418 RepositoryId : h .remoteRepository .Id ,
412419 User : h .wallet .Address (),
413420 })
414- if err != nil && ! strings . Contains ( err . Error (), "lfs object update proposal not found" ) {
421+ if err != nil {
415422 return nil , err
416423 }
417424 if lfsObjectUpdateProposalRes != nil {
@@ -420,7 +427,6 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush)
420427 msg = append (msg , storagetypes .NewMsgApproveLFSObjectUpdate (h .wallet .Address (), lfsObjectUpdateProposal .Id ))
421428 }
422429 }
423- // If error occurs (e.g., no LFS proposals), continue without failing
424430 }
425431
426432 if len (setBranches ) > 0 {
0 commit comments