aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeripath2021-12-21 18:27:46 +0000
committerGitHub2021-12-21 18:27:46 +0000
commit6de75224de3c8c9bd75e8e4b9e78c22a3cf468e1 (patch)
tree7ac8ea4cce1dbf6861769d0f722e604b330a6972
parent9086916eb79f4afb1cd42dd01298a02da9173874 (diff)
Ensure that git repository is closed before transfer (#18049) (#18057)
Backport #18049 Repository Transfer requires that the repository directory is renamed - which is not possible on Windows if the git repository is open. Fix #17885 Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r--routers/api/v1/repo/transfer.go5
-rw-r--r--routers/web/repo/repo.go5
2 files changed, 10 insertions, 0 deletions
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
}