diff options
author | Unknwon <u@gogs.io> | 2016-02-15 14:26:21 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-02-15 14:26:21 -0500 |
commit | dc89c51f3efec39e120dd5b3878a8a9c922721ef (patch) | |
tree | 79b0eac741fe27d1ad681dbf4dd00ed147821c71 /routers | |
parent | e9b9e6eb53d423bf7c8266a5ef9eeb463d8eb059 (diff) | |
parent | bb595666ac3bdb5f16fa10663bd8890eb320fcb1 (diff) | |
download | gitea-dc89c51f3efec39e120dd5b3878a8a9c922721ef.tar.gz gitea-dc89c51f3efec39e120dd5b3878a8a9c922721ef.zip |
Merge pull request #2624 from mhartkorn/convert-mirror-to-repo
Convert mirrors to regular repositories
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/setting.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 507984e56d..3712a088b0 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -141,6 +141,38 @@ 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 + } + } + + if !repo.IsMirror { + ctx.Error(404) + return + } + repo.IsMirror = false + + if _, err := models.CleanUpMigrateInfo(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.DeleteMirrorByRepoID(ctx.Repo.Repository.ID); err != nil { + ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form) + return + } + log.Trace("Repository converted from mirror to regular: %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) |