Skip to content

Commit cb24f72

Browse files
committed
Follow @wxiaoguang's suggestion
1 parent 9e53ad7 commit cb24f72

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

routers/web/repo/repo.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,12 @@ func rejectTransfer(ctx *context.Context) {
330330
}
331331

332332
func handleActionError(ctx *context.Context, err error) {
333-
if err != nil {
334-
if errors.Is(err, user_model.ErrBlockedUser) {
335-
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
336-
} else if errors.Is(err, util.ErrPermissionDenied) {
337-
ctx.Error(http.StatusNotFound)
338-
} else {
339-
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
340-
}
333+
if errors.Is(err, user_model.ErrBlockedUser) {
334+
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
335+
} else if errors.Is(err, util.ErrPermissionDenied) {
336+
ctx.Error(http.StatusNotFound)
337+
} else {
338+
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
341339
}
342340
}
343341

services/repository/transfer.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,14 @@ func StartRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.Use
399399
return err
400400
}
401401

402-
var isTransfer bool
402+
var isDirectTransfer bool
403403
oldOwnerName := repo.OwnerName
404404

405405
if err := db.WithTx(ctx, func(ctx context.Context) error {
406-
// Admin is always allowed to transfer || user transfer repo back to his account
406+
// Admin is always allowed to transfer || user transfer repo back to his account,
407+
// then it will transfer directly without acceptance.
407408
if doer.IsAdmin || doer.ID == newOwner.ID {
408-
isTransfer = true
409+
isDirectTransfer = true
409410
return transferOwnership(ctx, doer, newOwner.Name, repo, teams)
410411
}
411412

@@ -420,7 +421,7 @@ func StartRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.Use
420421
return err
421422
}
422423
if allowed {
423-
isTransfer = true
424+
isDirectTransfer = true
424425
return transferOwnership(ctx, doer, newOwner.Name, repo, teams)
425426
}
426427
}
@@ -443,7 +444,7 @@ func StartRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.Use
443444
return err
444445
}
445446

446-
if isTransfer {
447+
if isDirectTransfer {
447448
notify_service.TransferRepository(ctx, doer, repo, oldOwnerName)
448449
} else {
449450
// notify users who are able to accept / reject transfer

0 commit comments

Comments
 (0)