diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go index 2e052aa4f..11e56defe 100644 --- a/routers/api/v1/repo/transfer.go +++ b/routers/api/v1/repo/transfer.go @@ -96,6 +96,11 @@ func Transfer(ctx *context.APIContext) { } } + if ctx.Repo.GitRepo != nil { + ctx.Repo.GitRepo.Close() + ctx.Repo.GitRepo = nil + } + if err := repo_service.StartRepositoryTransfer(ctx.User, newOwner, ctx.Repo.Repository, teams); err != nil { if models.IsErrRepoTransferInProgress(err) { ctx.Error(http.StatusConflict, "CreatePendingRepositoryTransfer", err) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 8d5546f8c..0b300d32b 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -319,6 +319,11 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error { } if accept { + if ctx.Repo.GitRepo != nil { + ctx.Repo.GitRepo.Close() + ctx.Repo.GitRepo = nil + } + if err := repo_service.TransferOwnership(repoTransfer.Doer, repoTransfer.Recipient, ctx.Repo.Repository, repoTransfer.Teams); err != nil { return err }