mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 13:45:19 +00:00
Implement single Repo validation and saving POC
This commit is contained in:
parent
1cbd5e33cb
commit
d1190423bb
|
@ -190,25 +190,30 @@ func SettingsPost(ctx *context.Context) {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
ctx.Flash.Info("Federation Not enabled")
|
ctx.Flash.Info("Federation Not enabled")
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
// ToDo: Proper string handling
|
|
||||||
log.Info("web/repo/setting.go:Federation was detected as enabled.")
|
switch {
|
||||||
// ToDo: Ability to delete repos
|
// Allow clearing the field
|
||||||
// TODO: Review jem: no add and remove - just set
|
case form.FederationRepos == "":
|
||||||
// repo.FederationRepos = form.FederationRepos
|
repo.FederationRepos = ""
|
||||||
repo.FederationRepos = repo.FederationRepos + form.FederationRepos
|
// Validate
|
||||||
|
case validation.IsValidFederatedRepoURL(form.FederationRepos):
|
||||||
|
repo.FederationRepos = form.FederationRepos
|
||||||
|
default:
|
||||||
|
ctx.Data["ERR_FederationRepos"] = true
|
||||||
|
ctx.Flash.Error("The given Repo URL was not valid")
|
||||||
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := repo_service.UpdateRepository(ctx, repo, false); err != nil {
|
if err := repo_service.UpdateRepository(ctx, repo, false); err != nil {
|
||||||
ctx.ServerError("UpdateRepository", err)
|
ctx.ServerError("UpdateRepository", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("Repos are: %v", repo.FederationRepos)
|
|
||||||
|
log.Info("Repo Saved: %v", repo.FederationRepos)
|
||||||
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
|
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
|
||||||
ctx.Redirect(repo.Link() + "/settings")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Validate semicolon separation
|
|
||||||
// TODO: Validate Element isURL
|
|
||||||
// TODO: Validate Element denominates Repository
|
|
||||||
|
|
||||||
case "mirror":
|
case "mirror":
|
||||||
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
|
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
|
||||||
|
|
Loading…
Reference in a new issue