Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Follow @wxiaoguang's suggestion
  • Loading branch information
lunny committed Jan 29, 2025
commit cb24f729e3a14d3075bc3d1240388c31b025a81e
14 changes: 6 additions & 8 deletions routers/web/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,12 @@ func rejectTransfer(ctx *context.Context) {
}

func handleActionError(ctx *context.Context, err error) {
if err != nil {
if errors.Is(err, user_model.ErrBlockedUser) {
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
} else if errors.Is(err, util.ErrPermissionDenied) {
ctx.Error(http.StatusNotFound)
} else {
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
}
if errors.Is(err, user_model.ErrBlockedUser) {
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
} else if errors.Is(err, util.ErrPermissionDenied) {
ctx.Error(http.StatusNotFound)
} else {
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
}
}

Expand Down
11 changes: 6 additions & 5 deletions services/repository/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,14 @@ func StartRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.Use
return err
}

var isTransfer bool
var isDirectTransfer bool
oldOwnerName := repo.OwnerName

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

Expand All @@ -420,7 +421,7 @@ func StartRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.Use
return err
}
if allowed {
isTransfer = true
isDirectTransfer = true
return transferOwnership(ctx, doer, newOwner.Name, repo, teams)
}
}
Expand All @@ -443,7 +444,7 @@ func StartRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.Use
return err
}

if isTransfer {
if isDirectTransfer {
notify_service.TransferRepository(ctx, doer, repo, oldOwnerName)
} else {
// notify users who are able to accept / reject transfer
Expand Down