]> source.dussan.org Git - gitea.git/commitdiff
Re-enable transfer repo back from org to user account (#14807)
author6543 <6543@obermui.de>
Fri, 26 Feb 2021 09:08:09 +0000 (10:08 +0100)
committerGitHub <noreply@github.com>
Fri, 26 Feb 2021 09:08:09 +0000 (11:08 +0200)
* re-enable transfer repo back from org to user account

* add test case

integrations/api_repo_test.go
services/repository/transfer.go

index 7cabd51add765d3e30d3ca286ca5c5e5a8dc2424..8798fe0914530afec9aa04f38f8ef2bf8a6d61d8 100644 (file)
@@ -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)()
index a80f8635bb6f64a96e4c1ef495df6ec5b9dfa7bf..05f7a56b0174f4f7c9cf48d55b11a0267b96ae76 100644 (file)
@@ -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)
        }