mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-25 17:30:36 +00:00
Work on mirror repo
This commit is contained in:
parent
5f6bd323f5
commit
9f7bd5007b
4 changed files with 12 additions and 45 deletions
|
@ -55,36 +55,34 @@ 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"
|
||||
func Mirror(ctx *middleware.Context, form auth.CreateRepoForm) {
|
||||
ctx.Data["Title"] = "Mirror 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")
|
||||
ctx.HTML(200, "repo/mirror")
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "repo/import")
|
||||
ctx.HTML(200, "repo/mirror")
|
||||
return
|
||||
}
|
||||
|
||||
_, err := models.CreateRepository(ctx.User, form.RepoName, form.Description,
|
||||
form.Language, form.License, form.Visibility == "private", form.InitReadme == "on")
|
||||
"", form.License, form.Visibility == "private", false)
|
||||
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)
|
||||
ctx.RenderWithErr("Repository name has already been used", "repo/mirror", &form)
|
||||
return
|
||||
} else if err == models.ErrRepoNameIllegal {
|
||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "repo/import", &form)
|
||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "repo/mirror", &form)
|
||||
return
|
||||
}
|
||||
ctx.Handle(200, "repo.Import", err)
|
||||
ctx.Handle(200, "repo.Mirror", err)
|
||||
}
|
||||
|
||||
func Single(ctx *middleware.Context, params martini.Params) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">URL<strong class="text-danger">*</strong></label>
|
||||
<div class="col-md-8">
|
||||
<input name="url" type="text" class="form-control" placeholder="Type your imported repository url link" required="required">
|
||||
<input name="url" type="text" class="form-control" placeholder="Type your mirror repository url link" required="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -70,40 +70,9 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">Language</label>
|
||||
<div class="col-md-8">
|
||||
<select class="form-control" name="language">
|
||||
<option value="">Select a language</option>
|
||||
{{range .LanguageIgns}}<option value="{{.}}">{{.}}</option>{{end}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">License</label>
|
||||
<div class="col-md-8">
|
||||
<select class="form-control" name="license">
|
||||
<option value="">Select a license</option>
|
||||
{{range .Licenses}}<option value="{{.}}">{{.}}</option>{{end}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--<div class="form-group">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="initReadme" {{if .initReadme}}checked{{end}}>
|
||||
<strong>Initialize this repository with a README</strong>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-8">
|
||||
<button type="submit" class="btn btn-lg btn-primary">Import repository</button>
|
||||
<button type="submit" class="btn btn-lg btn-primary">Mirror repository</button>
|
||||
<a href="/" class="text-danger">Cancel</a>
|
||||
</div>
|
||||
</div>
|
|
@ -37,7 +37,7 @@
|
|||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<ul class="list-unstyled">
|
||||
<li><a href="/repo/create"><i class="fa fa-book"></i>Repository</a></li>
|
||||
<li><a href="/repo/import"><i class="fa fa-clipboard"></i>Mirror</a></li>
|
||||
<li><a href="/repo/mirror"><i class="fa fa-clipboard"></i>Mirror</a></li>
|
||||
<li><a href="#"><i class="fa fa-users"></i>Organization</a></li>
|
||||
</ul>
|
||||
|
||||
|
|
2
web.go
2
web.go
|
@ -116,7 +116,7 @@ func runWeb(*cli.Context) {
|
|||
m.Get("/user/:username", ignSignIn, user.Profile)
|
||||
|
||||
m.Any("/repo/create", reqSignIn, binding.BindIgnErr(auth.CreateRepoForm{}), repo.Create)
|
||||
m.Any("/repo/import", reqSignIn, binding.BindIgnErr(auth.CreateRepoForm{}), repo.Import)
|
||||
m.Any("/repo/mirror", reqSignIn, binding.BindIgnErr(auth.CreateRepoForm{}), repo.Mirror)
|
||||
|
||||
adminReq := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true, AdminRequire: true})
|
||||
|
||||
|
|
Loading…
Reference in a new issue