@@ -163,6 +163,18 @@ func (pushService *pushService) createRepository() (*github.Repository, error) {
163
163
return repository , nil
164
164
}
165
165
166
+ func splitLargeRefSpecs (refSpecs []config.RefSpec ) [][]config.RefSpec {
167
+ splitRefSpecs := [][]config.RefSpec {}
168
+ for i := 0 ; i < len (refSpecs ); i += 25 {
169
+ end := i + 100
170
+ if end > len (refSpecs ) {
171
+ end = len (refSpecs )
172
+ }
173
+ splitRefSpecs = append (splitRefSpecs , refSpecs [i :end ])
174
+ }
175
+ return splitRefSpecs
176
+ }
177
+
166
178
func (pushService * pushService ) pushGit (repository * github.Repository , initialPush bool ) error {
167
179
remoteURL := pushService .gitURL
168
180
if remoteURL == "" {
@@ -210,9 +222,10 @@ func (pushService *pushService) pushGit(repository *github.Repository, initialPu
210
222
deleteRefSpecs = append (deleteRefSpecs , config .RefSpec (":" + remoteReference .Name ().String ()))
211
223
}
212
224
}
213
- refSpecBatches = append (refSpecBatches , deleteRefSpecs )
225
+ refSpecBatches = append (refSpecBatches , splitLargeRefSpecs ( deleteRefSpecs ) ... )
214
226
215
- defaultBranchRefSpec := "+refs/heads/main:refs/heads/main"
227
+ defaultBranchRef := "refs/heads/main"
228
+ defaultBranchRefSpec := "+" + defaultBranchRef + ":" + defaultBranchRef
216
229
if initialPush {
217
230
releasePathStats , err := ioutil .ReadDir (pushService .cacheDirectory .ReleasesPath ())
218
231
if err != nil {
@@ -227,20 +240,30 @@ func (pushService *pushService) pushGit(repository *github.Repository, initialPu
227
240
}
228
241
initialRefSpecs = append (initialRefSpecs , config .RefSpec ("+" + tagReferenceName .String ()+ ":" + tagReferenceName .String ()))
229
242
}
230
- refSpecBatches = append (refSpecBatches , initialRefSpecs )
243
+ refSpecBatches = append (refSpecBatches , splitLargeRefSpecs ( initialRefSpecs ) ... )
231
244
} else {
232
245
// We've got to push the default branch on its own, so that it will be made the default branch if the repository has just been created. We then push everything else afterwards.
233
246
refSpecBatches = append (refSpecBatches ,
234
247
[]config.RefSpec {
235
248
config .RefSpec (defaultBranchRefSpec ),
236
249
},
237
- []config.RefSpec {
238
- config .RefSpec ("+refs/*:refs/*" ),
239
- },
240
250
)
251
+ nonDefaultRefSpecs := []config.RefSpec {}
252
+ localReferences , err := gitRepository .References ()
253
+ if err != nil {
254
+ return errors .Wrap (err , "Error listing local references." )
255
+ }
256
+ localReferences .ForEach (func (ref * plumbing.Reference ) error {
257
+ if ref .Name ().String () != defaultBranchRef && strings .HasPrefix (ref .Name ().String (), "refs/" ) {
258
+ nonDefaultRefSpecs = append (nonDefaultRefSpecs , config .RefSpec ("+" + ref .Name ().String ()+ ":" + ref .Name ().String ()))
259
+ }
260
+ return nil
261
+ })
262
+ refSpecBatches = append (refSpecBatches , splitLargeRefSpecs (nonDefaultRefSpecs )... )
241
263
}
242
264
for _ , refSpecs := range refSpecBatches {
243
265
if len (refSpecs ) != 0 {
266
+ log .Debugf ("Pushing refspecs %s." , refSpecs )
244
267
err = remote .PushContext (pushService .ctx , & git.PushOptions {
245
268
RefSpecs : refSpecs ,
246
269
Auth : credentials ,
@@ -393,17 +416,17 @@ func (pushService *pushService) pushReleases() error {
393
416
existingAssets = append (existingAssets , assets ... )
394
417
}
395
418
396
- assetsPath := pushService .cacheDirectory .AssetsPath (releaseName )
397
- assetPathStats , err := ioutil .ReadDir (assetsPath )
419
+ // assetsPath := pushService.cacheDirectory.AssetsPath(releaseName)
420
+ // assetPathStats, err := ioutil.ReadDir(assetsPath)
398
421
if err != nil {
399
422
return errors .Wrap (err , "Error reading release assets." )
400
423
}
401
- for _ , assetPathStat := range assetPathStats {
402
- err := pushService .createOrUpdateReleaseAsset (release , existingAssets , assetPathStat )
403
- if err != nil {
404
- return err
405
- }
406
- }
424
+ // for _, assetPathStat := range assetPathStats {
425
+ // err := pushService.createOrUpdateReleaseAsset(release, existingAssets, assetPathStat)
426
+ // if err != nil {
427
+ // return err
428
+ // }
429
+ // }
407
430
}
408
431
409
432
return nil
0 commit comments