From 9ba322dbe3ea752c9a6a4b186d3f2aba8ea5a955 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 26 Feb 2021 08:52:06 +0100 Subject: [PATCH 1/2] re-enable transfer repo back from org to user account --- services/repository/transfer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/repository/transfer.go b/services/repository/transfer.go index a80f8635bb6f..05f7a56b0174 100644 --- a/services/repository/transfer.go +++ b/services/repository/transfer.go @@ -80,8 +80,8 @@ func StartRepositoryTransfer(doer, newOwner *models.User, repo *models.Repositor return fmt.Errorf("repository is not ready for transfer") } - // Admin is always allowed to transfer - if doer.IsAdmin { + // Admin is always allowed to transfer || user transfer repo back to his account + if doer.IsAdmin || doer.ID == newOwner.ID { return TransferOwnership(doer, newOwner, repo, teams) } From 27de2bf5f0176bbba1c10de97c38ef96d780834d Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 26 Feb 2021 09:37:14 +0100 Subject: [PATCH 2/2] add test case --- integrations/api_repo_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 7cabd51add76..8798fe091453 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -450,6 +450,7 @@ func TestAPIRepoTransfer(t *testing.T) { {ctxUserID: 1, newOwner: "user2", teams: &[]int64{2}, expectedStatus: http.StatusUnprocessableEntity}, {ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden}, {ctxUserID: 1, newOwner: "user3", teams: &[]int64{2}, expectedStatus: http.StatusAccepted}, + {ctxUserID: 2, newOwner: "user2", teams: nil, expectedStatus: http.StatusAccepted}, } defer prepareTestEnv(t)()