diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go index abaed4d587..dd7730b42c 100644 --- a/routers/api/v1/repo/transfer.go +++ b/routers/api/v1/repo/transfer.go @@ -98,6 +98,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 a1e652f94c..9a36e6ee1d 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -323,6 +323,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 }