@@ -232,7 +232,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
232
232
}
233
233
234
234
if len (addTags )+ len (delTags ) > 0 {
235
- if err := PushUpdateAddDeleteTags (ctx , repo , gitRepo , addTags , delTags ); err != nil {
235
+ if err := PushUpdateAddDeleteTags (ctx , repo , gitRepo , pusher , addTags , delTags ); err != nil {
236
236
return fmt .Errorf ("PushUpdateAddDeleteTags: %w" , err )
237
237
}
238
238
}
@@ -342,17 +342,17 @@ func pushDeleteBranch(ctx context.Context, repo *repo_model.Repository, pusher *
342
342
}
343
343
344
344
// PushUpdateAddDeleteTags updates a number of added and delete tags
345
- func PushUpdateAddDeleteTags (ctx context.Context , repo * repo_model.Repository , gitRepo * git.Repository , addTags , delTags []string ) error {
345
+ func PushUpdateAddDeleteTags (ctx context.Context , repo * repo_model.Repository , gitRepo * git.Repository , pusher * user_model. User , addTags , delTags []string ) error {
346
346
return db .WithTx (ctx , func (ctx context.Context ) error {
347
347
if err := repo_model .PushUpdateDeleteTags (ctx , repo , delTags ); err != nil {
348
348
return err
349
349
}
350
- return pushUpdateAddTags (ctx , repo , gitRepo , addTags )
350
+ return pushUpdateAddTags (ctx , repo , gitRepo , pusher , addTags )
351
351
})
352
352
}
353
353
354
354
// pushUpdateAddTags updates a number of add tags
355
- func pushUpdateAddTags (ctx context.Context , repo * repo_model.Repository , gitRepo * git.Repository , tags []string ) error {
355
+ func pushUpdateAddTags (ctx context.Context , repo * repo_model.Repository , gitRepo * git.Repository , pusher * user_model. User , tags []string ) error {
356
356
if len (tags ) == 0 {
357
357
return nil
358
358
}
@@ -378,8 +378,6 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
378
378
379
379
newReleases := make ([]* repo_model.Release , 0 , len (lowerTags )- len (relMap ))
380
380
381
- emailToUser := make (map [string ]* user_model.User )
382
-
383
381
for i , lowerTag := range lowerTags {
384
382
tag , err := gitRepo .GetTag (tags [i ])
385
383
if err != nil {
@@ -397,21 +395,9 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
397
395
if sig == nil {
398
396
sig = commit .Committer
399
397
}
400
- var author * user_model.User
401
- createdAt := time .Unix (1 , 0 )
402
398
399
+ createdAt := time .Unix (1 , 0 )
403
400
if sig != nil {
404
- var ok bool
405
- author , ok = emailToUser [sig .Email ]
406
- if ! ok {
407
- author , err = user_model .GetUserByEmail (ctx , sig .Email )
408
- if err != nil && ! user_model .IsErrUserNotExist (err ) {
409
- return fmt .Errorf ("GetUserByEmail: %w" , err )
410
- }
411
- if author != nil {
412
- emailToUser [sig .Email ] = author
413
- }
414
- }
415
401
createdAt = sig .When
416
402
}
417
403
@@ -435,11 +421,9 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
435
421
IsDraft : false ,
436
422
IsPrerelease : false ,
437
423
IsTag : true ,
424
+ PublisherID : pusher .ID ,
438
425
CreatedUnix : timeutil .TimeStamp (createdAt .Unix ()),
439
426
}
440
- if author != nil {
441
- rel .PublisherID = author .ID
442
- }
443
427
444
428
newReleases = append (newReleases , rel )
445
429
} else {
@@ -448,12 +432,10 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
448
432
if rel .IsTag {
449
433
rel .Title = parts [0 ]
450
434
rel .Note = note
451
- if author != nil {
452
- rel .PublisherID = author .ID
453
- }
454
435
} else {
455
436
rel .IsDraft = false
456
437
}
438
+ rel .PublisherID = pusher .ID
457
439
if err = repo_model .UpdateRelease (ctx , rel ); err != nil {
458
440
return fmt .Errorf ("Update: %w" , err )
459
441
}
0 commit comments