summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorFuXiaoHei <fuxiaohei@hexiaz.com>2014-04-09 21:28:00 +0800
committerFuXiaoHei <fuxiaohei@hexiaz.com>2014-04-09 21:28:00 +0800
commitc72e1b5c2ac8d2cbd123f3f53db7b4a125045725 (patch)
tree2f82785e8a1431189d5aeed3795bc77302caa7be /routers
parent721834a2673fed7fc21988b8e91a88a26bcef051 (diff)
downloadgitea-c72e1b5c2ac8d2cbd123f3f53db7b4a125045725.tar.gz
gitea-c72e1b5c2ac8d2cbd123f3f53db7b4a125045725.zip
repo-import page ui
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/repo.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index d223600c52..0ab1c9e420 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -55,6 +55,38 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
ctx.Handle(200, "repo.Create", err)
}
+func Import(ctx *middleware.Context, form auth.CreateRepoForm) {
+ ctx.Data["Title"] = "Import repository"
+ ctx.Data["PageIsNewRepo"] = true // For navbar arrow.
+ ctx.Data["LanguageIgns"] = models.LanguageIgns
+ ctx.Data["Licenses"] = models.Licenses
+
+ if ctx.Req.Method == "GET" {
+ ctx.HTML(200, "repo/import")
+ return
+ }
+
+ if ctx.HasError() {
+ ctx.HTML(200, "repo/import")
+ return
+ }
+
+ _, err := models.CreateRepository(ctx.User, form.RepoName, form.Description,
+ form.Language, form.License, form.Visibility == "private", form.InitReadme == "on")
+ if err == nil {
+ log.Trace("%s Repository created: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, form.RepoName)
+ ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName)
+ return
+ } else if err == models.ErrRepoAlreadyExist {
+ ctx.RenderWithErr("Repository name has already been used", "repo/import", &form)
+ return
+ } else if err == models.ErrRepoNameIllegal {
+ ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "repo/import", &form)
+ return
+ }
+ ctx.Handle(200, "repo.Import", err)
+}
+
func Single(ctx *middleware.Context, params martini.Params) {
branchName := ctx.Repo.BranchName
commitId := ctx.Repo.CommitId