@@ -112,20 +112,21 @@ func extraSpecs(repo *git.Repository, refs []*plumbing.Reference) ([]config.RefS
112112
113113// pruneRemote removes all the references in a remote that are not available in
114114// the repo.
115- func pruneRemote (remote * git.Remote , auth transport.AuthMethod , repo * git.Repository ) error {
115+ func pruneRemote (conf Config , logger * Logger , remote * git.Remote , auth transport.AuthMethod , repo * git.Repository ) error {
116116 refs , err := remote .List (& git.ListOptions {
117117 Auth : auth ,
118118 })
119119 if err != nil {
120120 return fmt .Errorf ("failed to list the destination remote: %w" , err )
121121 }
122122
123- deleteSpecs , err := extraSpecs (repo , refs )
124- if err != nil {
125- return fmt .Errorf ("failed to get the prune specs: %w" , err )
126- }
123+ deleteRefs , _ := extraRefs (repo , refs )
124+
125+ deleteSpecs := refsToDeleteSpecs (deleteRefs )
127126
128127 if len (deleteSpecs ) > 0 {
128+ logger .Debug (conf .Debug , "Pruning the following refs:" , deleteRefs )
129+
129130 err := remote .Push (& git.PushOptions {
130131 RemoteName : remote .Config ().Name ,
131132 Auth : auth ,
@@ -134,6 +135,8 @@ func pruneRemote(remote *git.Remote, auth transport.AuthMethod, repo *git.Reposi
134135 if err != nil && errors .Is (err , git .NoErrAlreadyUpToDate ) {
135136 return fmt .Errorf ("failed to prune destination: %w" , err )
136137 }
138+ } else {
139+ logger .Debug (conf .Debug , "No refs found to prune." )
137140 }
138141
139142 return nil
@@ -259,7 +262,7 @@ func pushWithAuth(conf Config, logger *Logger, stagingRepo *git.Repository) erro
259262 // with the prunning with a separate push.
260263 logger .Info ("Pruning the destination..." )
261264
262- err = pruneRemote (dst , auth , stagingRepo )
265+ err = pruneRemote (conf , logger , dst , auth , stagingRepo )
263266 if err != nil {
264267 return nil
265268 }
0 commit comments