diff options
author | Martin Hartkorn <github@hartkorn.net> | 2016-02-14 21:12:00 +0100 |
---|---|---|
committer | Martin Hartkorn <github@hartkorn.net> | 2016-02-14 21:12:00 +0100 |
commit | 3650bd8528a8c0f43eb3d9083939735bf740fa3b (patch) | |
tree | 267f881bfb964101b66aef2973d8e27c440ffd41 /routers/repo/setting.go | |
parent | 10e4887b2bf2e201c7acc38f09731a218ae1a7bc (diff) | |
download | gitea-3650bd8528a8c0f43eb3d9083939735bf740fa3b.tar.gz gitea-3650bd8528a8c0f43eb3d9083939735bf740fa3b.zip |
Convert mirrors to regular repositories.
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r-- | routers/repo/setting.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 507984e56d..9d7e4074c3 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -141,6 +141,34 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings") + case "convert": + if repo.Name != form.RepoName { + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) + return + } + + if ctx.Repo.Owner.IsOrganization() { + if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { + ctx.Error(404) + return + } + } + + repo.IsMirror = false + + if _, err := models.FinishMigrateRepository(repo, models.RepoPath(ctx.Repo.Owner.Name, repo.Name)); err != nil { + ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form) + return + } + + if err := models.UpdateRepository(repo, false); err != nil { + ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form) + return + } + log.Trace("Repository converted: %s/%s", ctx.Repo.Owner.Name, repo.Name) + ctx.Flash.Success(ctx.Tr("repo.settings.convert_succeed")) + ctx.Redirect(setting.AppSubUrl + "/" + ctx.Repo.Owner.Name + "/" + repo.Name) + case "transfer": if repo.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) |