Skip to content

Commit 77ce089

Browse files
authored
Re-enable transfer repo back from org to user account (#14807)
* re-enable transfer repo back from org to user account * add test case
1 parent 8f389c5 commit 77ce089

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

integrations/api_repo_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ func TestAPIRepoTransfer(t *testing.T) {
450450
{ctxUserID: 1, newOwner: "user2", teams: &[]int64{2}, expectedStatus: http.StatusUnprocessableEntity},
451451
{ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden},
452452
{ctxUserID: 1, newOwner: "user3", teams: &[]int64{2}, expectedStatus: http.StatusAccepted},
453+
{ctxUserID: 2, newOwner: "user2", teams: nil, expectedStatus: http.StatusAccepted},
453454
}
454455

455456
defer prepareTestEnv(t)()

services/repository/transfer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func StartRepositoryTransfer(doer, newOwner *models.User, repo *models.Repositor
8080
return fmt.Errorf("repository is not ready for transfer")
8181
}
8282

83-
// Admin is always allowed to transfer
84-
if doer.IsAdmin {
83+
// Admin is always allowed to transfer || user transfer repo back to his account
84+
if doer.IsAdmin || doer.ID == newOwner.ID {
8585
return TransferOwnership(doer, newOwner, repo, teams)
8686
}
8787

0 commit comments

Comments
 (0)