aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/admin.go2
-rw-r--r--cmd/backup.go135
-rw-r--r--cmd/cert.go4
-rw-r--r--cmd/cert_stub.go2
-rw-r--r--cmd/dump.go122
-rw-r--r--cmd/hook.go2
-rw-r--r--cmd/import.go2
-rw-r--r--cmd/restore.go129
-rw-r--r--cmd/web.go116
9 files changed, 328 insertions, 186 deletions
diff --git a/cmd/admin.go b/cmd/admin.go
index bad36b1c..58e82f5f 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -14,7 +14,7 @@ import (
)
var (
- CmdAdmin = cli.Command{
+ Admin = cli.Command{
Name: "admin",
Usage: "Preform admin operations on command line",
Description: `Allow using internal logic of Gogs without hacking into the source code
diff --git a/cmd/backup.go b/cmd/backup.go
new file mode 100644
index 00000000..6f5cb899
--- /dev/null
+++ b/cmd/backup.go
@@ -0,0 +1,135 @@
+// Copyright 2017 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package cmd
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path"
+ "time"
+
+ "github.com/Unknwon/cae/zip"
+ "github.com/Unknwon/com"
+ "github.com/urfave/cli"
+ log "gopkg.in/clog.v1"
+ "gopkg.in/ini.v1"
+
+ "github.com/gogits/gogs/models"
+ "github.com/gogits/gogs/modules/setting"
+)
+
+var Backup = cli.Command{
+ Name: "backup",
+ Usage: "Backup files and database",
+ Description: `Backup dumps and compresses all related files and database into zip file,
+which can be used for migrating Gogs to another server. The output format is meant to be
+portable among all supported database engines.`,
+ Action: runBackup,
+ Flags: []cli.Flag{
+ stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+ boolFlag("verbose, v", "Show process details"),
+ stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
+ stringFlag("target", "./", "Target directory path to save backup archive"),
+ boolFlag("database-only", "Only dump database"),
+ boolFlag("exclude-repos", "Exclude repositories"),
+ },
+}
+
+const _ARCHIVE_ROOT_DIR = "gogs-backup"
+
+func runBackup(c *cli.Context) error {
+ zip.Verbose = c.Bool("verbose")
+ if c.IsSet("config") {
+ setting.CustomConf = c.String("config")
+ }
+ setting.NewContext()
+ models.LoadConfigs()
+ models.SetEngine()
+
+ tmpDir := c.String("tempdir")
+ if !com.IsExist(tmpDir) {
+ log.Fatal(0, "'--tempdir' does not exist: %s", tmpDir)
+ }
+ rootDir, err := ioutil.TempDir(tmpDir, "gogs-backup-")
+ if err != nil {
+ log.Fatal(0, "Fail to create backup root directory '%s': %v", rootDir, err)
+ }
+ log.Info("Backup root directory: %s", rootDir)
+
+ // Metadata
+ metaFile := path.Join(rootDir, "metadata.ini")
+ metadata := ini.Empty()
+ metadata.Section("").Key("VERSION").SetValue("1")
+ metadata.Section("").Key("DATE_TIME").SetValue(time.Now().String())
+ metadata.Section("").Key("GOGS_VERSION").SetValue(setting.AppVer)
+ if err = metadata.SaveTo(metaFile); err != nil {
+ log.Fatal(0, "Fail to save metadata '%s': %v", metaFile, err)
+ }
+
+ archiveName := path.Join(c.String("target"), fmt.Sprintf("gogs-backup-%d.zip", time.Now().Unix()))
+ log.Info("Packing backup files to: %s", archiveName)
+
+ z, err := zip.Create(archiveName)
+ if err != nil {
+ log.Fatal(0, "Fail to create backup archive '%s': %v", archiveName, err)
+ }
+ if err = z.AddFile(_ARCHIVE_ROOT_DIR+"/metadata.ini", metaFile); err != nil {
+ log.Fatal(0, "Fail to include 'metadata.ini': %v", err)
+ }
+
+ // Database
+ dbDir := path.Join(rootDir, "db")
+ if err = models.DumpDatabase(dbDir); err != nil {
+ log.Fatal(0, "Fail to dump database: %v", err)
+ }
+ if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/db", dbDir); err != nil {
+ log.Fatal(0, "Fail to include 'db': %v", err)
+ }
+
+ // Custom files
+ if !c.Bool("database-only") {
+ if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/custom", setting.CustomPath); err != nil {
+ log.Fatal(0, "Fail to include 'custom': %v", err)
+ }
+ }
+
+ // Data files
+ if !c.Bool("database-only") {
+ for _, dir := range []string{"attachments", "avatars"} {
+ dirPath := path.Join(setting.AppDataPath, dir)
+ if !com.IsDir(dirPath) {
+ continue
+ }
+
+ if err = z.AddDir(path.Join(_ARCHIVE_ROOT_DIR+"/data", dir), dirPath); err != nil {
+ log.Fatal(0, "Fail to include 'data': %v", err)
+ }
+ }
+ }
+
+ // Repositories
+ if !c.Bool("exclude-repos") && !c.Bool("database-only") {
+ reposDump := path.Join(rootDir, "repositories.zip")
+ log.Info("Dumping repositories in '%s'", setting.RepoRootPath)
+ if err = zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil {
+ log.Fatal(0, "Fail to dump repositories: %v", err)
+ }
+ log.Info("Repositories dumped to: %s", reposDump)
+
+ if err = z.AddFile(_ARCHIVE_ROOT_DIR+"/repositories.zip", reposDump); err != nil {
+ log.Fatal(0, "Fail to include 'repositories.zip': %v", err)
+ }
+ }
+
+ if err = z.Close(); err != nil {
+ log.Fatal(0, "Fail to save backup archive '%s': %v", archiveName, err)
+ }
+
+ os.RemoveAll(rootDir)
+ log.Info("Backup succeed! Archive is located at: %s", archiveName)
+ log.Shutdown()
+ return nil
+}
diff --git a/cmd/cert.go b/cmd/cert.go
index 6cd5bfad..7c91c2c6 100644
--- a/cmd/cert.go
+++ b/cmd/cert.go
@@ -25,10 +25,10 @@ import (
"github.com/urfave/cli"
)
-var CmdCert = cli.Command{
+var Cert = cli.Command{
Name: "cert",
Usage: "Generate self-signed certificate",
- Description: `Generate a self-signed X.509 certificate for a TLS server.
+ Description: `Generate a self-signed X.509 certificate for a TLS server.
Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`,
Action: runCert,
Flags: []cli.Flag{
diff --git a/cmd/cert_stub.go b/cmd/cert_stub.go
index 1c076f64..6164c83e 100644
--- a/cmd/cert_stub.go
+++ b/cmd/cert_stub.go
@@ -13,7 +13,7 @@ import (
"github.com/urfave/cli"
)
-var CmdCert = cli.Command{
+var Cert = cli.Command{
Name: "cert",
Usage: "Generate self-signed certificate",
Description: `Please use build tags "cert" to rebuild Gogs in order to have this ability`,
diff --git a/cmd/dump.go b/cmd/dump.go
deleted file mode 100644
index 2a243e41..00000000
--- a/cmd/dump.go
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package cmd
-
-import (
- "fmt"
- "log"
- "os"
- "path"
- "time"
-
- "io/ioutil"
-
- "github.com/Unknwon/cae/zip"
- "github.com/Unknwon/com"
- "github.com/urfave/cli"
-
- "github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/setting"
-)
-
-var CmdDump = cli.Command{
- Name: "dump",
- Usage: "Dump Gogs files and database",
- Description: `Dump compresses all related files and database into zip file.
-It can be used for backup and capture Gogs server image to send to maintainer`,
- Action: runDump,
- Flags: []cli.Flag{
- stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
- boolFlag("verbose, v", "Show process details"),
- stringFlag("tempdir, t", os.TempDir(), "Temporary dir path"),
- },
-}
-
-func runDump(ctx *cli.Context) error {
- if ctx.IsSet("config") {
- setting.CustomConf = ctx.String("config")
- }
- setting.NewContext()
- models.LoadConfigs()
- models.SetEngine()
-
- tmpDir := ctx.String("tempdir")
- if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
- log.Fatalf("Path does not exist: %s", tmpDir)
- }
- TmpWorkDir, err := ioutil.TempDir(tmpDir, "gogs-dump-")
- if err != nil {
- log.Fatalf("Fail to create tmp work directory: %v", err)
- }
- log.Printf("Creating tmp work dir: %s", TmpWorkDir)
-
- reposDump := path.Join(TmpWorkDir, "gogs-repo.zip")
- dbDump := path.Join(TmpWorkDir, "gogs-db.sql")
-
- log.Printf("Dumping local repositories...%s", setting.RepoRootPath)
- zip.Verbose = ctx.Bool("verbose")
- if err := zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil {
- log.Fatalf("Fail to dump local repositories: %v", err)
- }
-
- log.Printf("Dumping database...")
- if err := models.DumpDatabase(dbDump); err != nil {
- log.Fatalf("Fail to dump database: %v", err)
- }
-
- fileName := fmt.Sprintf("gogs-dump-%d.zip", time.Now().Unix())
- log.Printf("Packing dump files...")
- z, err := zip.Create(fileName)
- if err != nil {
- os.Remove(fileName)
- log.Fatalf("Fail to create %s: %v", fileName, err)
- }
-
- if err := z.AddFile("gogs-repo.zip", reposDump); err != nil {
- log.Fatalf("Fail to include gogs-repo.zip: %v", err)
- }
- if err := z.AddFile("gogs-db.sql", dbDump); err != nil {
- log.Fatalf("Fail to include gogs-db.sql: %v", err)
- }
- customDir, err := os.Stat(setting.CustomPath)
- if err == nil && customDir.IsDir() {
- if err := z.AddDir("custom", setting.CustomPath); err != nil {
- log.Fatalf("Fail to include custom: %v", err)
- }
- } else {
- log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
- }
-
- if err := z.AddDir("log", setting.LogRootPath); err != nil {
- log.Fatalf("Fail to include log: %v", err)
- }
-
- for _, dir := range []string{"attachments", "avatars"} {
- dirPath := path.Join(setting.AppDataPath, dir)
- if !com.IsDir(dirPath) {
- continue
- }
-
- if err := z.AddDir(path.Join("data", dir), dirPath); err != nil {
- log.Fatalf("Fail to include '%s': %v", dirPath, err)
- }
- }
-
- // FIXME: SSH key file.
- if err = z.Close(); err != nil {
- os.Remove(fileName)
- log.Fatalf("Fail to save %s: %v", fileName, err)
- }
-
- if err := os.Chmod(fileName, 0600); err != nil {
- log.Printf("Can't change file access permissions mask to 0600: %v", err)
- }
-
- log.Printf("Removing tmp work dir: %s", TmpWorkDir)
- os.RemoveAll(TmpWorkDir)
- log.Printf("Finish dumping in file %s", fileName)
-
- return nil
-}
diff --git a/cmd/hook.go b/cmd/hook.go
index 32461745..fede8649 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -27,7 +27,7 @@ import (
)
var (
- CmdHook = cli.Command{
+ Hook = cli.Command{
Name: "hook",
Usage: "Delegate commands to corresponding Git hooks",
Description: "All sub-commands should only be called by Git",
diff --git a/cmd/import.go b/cmd/import.go
index e575736a..f71e4b18 100644
--- a/cmd/import.go
+++ b/cmd/import.go
@@ -19,7 +19,7 @@ import (
)
var (
- CmdImport = cli.Command{
+ Import = cli.Command{
Name: "import",
Usage: "Import portable data as local Gogs data",
Description: `Allow user import data from other Gogs installations to local instance
diff --git a/cmd/restore.go b/cmd/restore.go
new file mode 100644
index 00000000..4b9cbed2
--- /dev/null
+++ b/cmd/restore.go
@@ -0,0 +1,129 @@
+// Copyright 2017 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package cmd
+
+import (
+ "os"
+ "path"
+
+ "github.com/Unknwon/cae/zip"
+ "github.com/Unknwon/com"
+ "github.com/mcuadros/go-version"
+ "github.com/urfave/cli"
+ log "gopkg.in/clog.v1"
+ "gopkg.in/ini.v1"
+
+ "github.com/gogits/gogs/models"
+ "github.com/gogits/gogs/modules/setting"
+)
+
+var Restore = cli.Command{
+ Name: "restore",
+ Usage: "Restore files and database from backup",
+ Description: `Restore imports all related files and database from a backup archive.
+The backup version must lower or equal to current Gogs version. You can also import
+backup from other database engines, which is useful for database migrating.
+
+If corresponding files or database tables are not presented in the archive, they will
+be skipped and remian unchanged.`,
+ Action: runRestore,
+ Flags: []cli.Flag{
+ stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
+ boolFlag("verbose, v", "Show process details"),
+ stringFlag("tempdir, t", os.TempDir(), "Temporary directory path"),
+ stringFlag("from", "", "Path to backup archive"),
+ boolFlag("database-only", "Only import database"),
+ boolFlag("exclude-repos", "Exclude repositories"),
+ },
+}
+
+func runRestore(c *cli.Context) error {
+ zip.Verbose = c.Bool("verbose")
+
+ tmpDir := c.String("tempdir")
+ if !com.IsExist(tmpDir) {
+ log.Fatal(0, "'--tempdir' does not exist: %s", tmpDir)
+ }
+
+ log.Info("Restore backup from: %s", c.String("from"))
+ if err := zip.ExtractTo(c.String("from"), tmpDir); err != nil {
+ log.Fatal(0, "Fail to extract backup archive: %v", err)
+ }
+ archivePath := path.Join(tmpDir, _ARCHIVE_ROOT_DIR)
+
+ // Check backup version
+ metaFile := path.Join(archivePath, "metadata.ini")
+ if !com.IsExist(metaFile) {
+ log.Fatal(0, "File 'metadata.ini' is missing")
+ }
+ metadata, err := ini.Load(metaFile)
+ if err != nil {
+ log.Fatal(0, "Fail to load metadata '%s': %v", metaFile, err)
+ }
+ backupVersion := metadata.Section("").Key("GOGS_VERSION").MustString("999.0")
+ if version.Compare(setting.AppVer, backupVersion, "<") {
+ log.Fatal(0, "Current Gogs version is lower than backup version: %s < %s", setting.AppVer, backupVersion)
+ }
+
+ // If config file is not present in backup, user must set this file via flag.
+ // Otherwise, it's optional to set config file flag.
+ configFile := path.Join(archivePath, "custom/conf/app.ini")
+ if c.IsSet("config") {
+ setting.CustomConf = c.String("config")
+ } else if !com.IsExist(configFile) {
+ log.Fatal(0, "'--config' is not specified and custom config file is not found in backup")
+ } else {
+ setting.CustomConf = configFile
+ }
+ setting.NewContext()
+ models.LoadConfigs()
+ models.SetEngine()
+
+ // Database
+ dbDir := path.Join(archivePath, "db")
+ if err = models.ImportDatabase(dbDir); err != nil {
+ log.Fatal(0, "Fail to import database: %v", err)
+ }
+
+ // Custom files
+ if !c.Bool("database-only") {
+ if com.IsExist(setting.CustomPath) {
+ if err = os.Rename(setting.CustomPath, setting.CustomPath+".bak"); err != nil {
+ log.Fatal(0, "Fail to backup current 'custom': %v", err)
+ }
+ }
+ if err = os.Rename(path.Join(archivePath, "custom"), setting.CustomPath); err != nil {
+ log.Fatal(0, "Fail to import 'custom': %v", err)
+ }
+ }
+
+ // Data files
+ if !c.Bool("database-only") {
+ for _, dir := range []string{"attachments", "avatars"} {
+ dirPath := path.Join(setting.AppDataPath, dir)
+ if com.IsExist(dirPath) {
+ if err = os.Rename(dirPath, dirPath+".bak"); err != nil {
+ log.Fatal(0, "Fail to backup current 'data': %v", err)
+ }
+ }
+ if err = os.Rename(path.Join(archivePath, "data", dir), dirPath); err != nil {
+ log.Fatal(0, "Fail to import 'data': %v", err)
+ }
+ }
+ }
+
+ // Repositories
+ reposPath := path.Join(archivePath, "repositories.zip")
+ if !c.Bool("exclude-repos") && !c.Bool("database-only") && com.IsExist(reposPath) {
+ if err := zip.ExtractTo(reposPath, path.Dir(setting.RepoRootPath)); err != nil {
+ log.Fatal(0, "Fail to extract 'repositories.zip': %v", err)
+ }
+ }
+
+ os.RemoveAll(path.Join(tmpDir, _ARCHIVE_ROOT_DIR))
+ log.Info("Restore succeed!")
+ log.Shutdown()
+ return nil
+}
diff --git a/cmd/web.go b/cmd/web.go
index cdbe1bfb..73e4ee49 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -34,9 +34,9 @@ import (
"github.com/gogits/go-gogs-client"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/bindata"
"github.com/gogits/gogs/modules/context"
+ "github.com/gogits/gogs/modules/form"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/modules/template"
@@ -49,9 +49,9 @@ import (
"github.com/gogits/gogs/routers/user"
)
-var CmdWeb = cli.Command{
+var Web = cli.Command{
Name: "web",
- Usage: "Start Gogs web server",
+ Usage: "Start web server",
Description: `Gogs web server is the only thing you need to run,
and it takes care of all the other things for you`,
Action: runWeb,
@@ -219,35 +219,35 @@ func runWeb(ctx *cli.Context) error {
m.Get("/organizations", routers.ExploreOrganizations)
}, ignSignIn)
m.Combo("/install", routers.InstallInit).Get(routers.Install).
- Post(bindIgnErr(auth.InstallForm{}), routers.InstallPost)
+ Post(bindIgnErr(form.Install{}), routers.InstallPost)
m.Get("/^:type(issues|pulls)$", reqSignIn, user.Issues)
// ***** START: User *****
m.Group("/user", func() {
m.Get("/login", user.SignIn)
- m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost)
+ m.Post("/login", bindIgnErr(form.SignIn{}), user.SignInPost)
m.Get("/sign_up", user.SignUp)
- m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost)
+ m.Post("/sign_up", bindIgnErr(form.Register{}), user.SignUpPost)
m.Get("/reset_password", user.ResetPasswd)
m.Post("/reset_password", user.ResetPasswdPost)
}, reqSignOut)
m.Group("/user/settings", func() {
m.Get("", user.Settings)
- m.Post("", bindIgnErr(auth.UpdateProfileForm{}), user.SettingsPost)
+ m.Post("", bindIgnErr(form.UpdateProfile{}), user.SettingsPost)
m.Combo("/avatar").Get(user.SettingsAvatar).
- Post(binding.MultipartForm(auth.AvatarForm{}), user.SettingsAvatarPost)
+ Post(binding.MultipartForm(form.Avatar{}), user.SettingsAvatarPost)
m.Post("/avatar/delete", user.SettingsDeleteAvatar)
m.Combo("/email").Get(user.SettingsEmails).
- Post(bindIgnErr(auth.AddEmailForm{}), user.SettingsEmailPost)
+ Post(bindIgnErr(form.AddEmail{}), user.SettingsEmailPost)
m.Post("/email/delete", user.DeleteEmail)
m.Get("/password", user.SettingsPassword)
- m.Post("/password", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsPasswordPost)
+ m.Post("/password", bindIgnErr(form.ChangePassword{}), user.SettingsPasswordPost)
m.Combo("/ssh").Get(user.SettingsSSHKeys).
- Post(bindIgnErr(auth.AddSSHKeyForm{}), user.SettingsSSHKeysPost)
+ Post(bindIgnErr(form.AddSSHKey{}), user.SettingsSSHKeysPost)
m.Post("/ssh/delete", user.DeleteSSHKey)
m.Combo("/applications").Get(user.SettingsApplications).
- Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost)
+ Post(bindIgnErr(form.NewAccessToken{}), user.SettingsApplicationsPost)
m.Post("/applications/delete", user.SettingsDeleteApplication)
m.Group("/organizations", func() {
@@ -261,7 +261,7 @@ func runWeb(ctx *cli.Context) error {
})
m.Group("/user", func() {
- // r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
+ // r.Get("/feeds", binding.Bind(form.Feeds{}), user.Feeds)
m.Any("/activate", user.Activate)
m.Any("/activate_email", user.ActivateEmail)
m.Get("/email2user", user.Email2User)
@@ -282,8 +282,8 @@ func runWeb(ctx *cli.Context) error {
m.Group("/users", func() {
m.Get("", admin.Users)
- m.Combo("/new").Get(admin.NewUser).Post(bindIgnErr(auth.AdminCrateUserForm{}), admin.NewUserPost)
- m.Combo("/:userid").Get(admin.EditUser).Post(bindIgnErr(auth.AdminEditUserForm{}), admin.EditUserPost)
+ m.Combo("/new").Get(admin.NewUser).Post(bindIgnErr(form.AdminCrateUser{}), admin.NewUserPost)
+ m.Combo("/:userid").Get(admin.EditUser).Post(bindIgnErr(form.AdminEditUser{}), admin.EditUserPost)
m.Post("/:userid/delete", admin.DeleteUser)
})
@@ -298,9 +298,9 @@ func runWeb(ctx *cli.Context) error {
m.Group("/auths", func() {
m.Get("", admin.Authentications)
- m.Combo("/new").Get(admin.NewAuthSource).Post(bindIgnErr(auth.AuthenticationForm{}), admin.NewAuthSourcePost)
+ m.Combo("/new").Get(admin.NewAuthSource).Post(bindIgnErr(form.Authentication{}), admin.NewAuthSourcePost)
m.Combo("/:authid").Get(admin.EditAuthSource).
- Post(bindIgnErr(auth.AuthenticationForm{}), admin.EditAuthSourcePost)
+ Post(bindIgnErr(form.Authentication{}), admin.EditAuthSourcePost)
m.Post("/:authid/delete", admin.DeleteAuthSource)
})
@@ -365,7 +365,7 @@ func runWeb(ctx *cli.Context) error {
m.Group("/org", func() {
m.Group("", func() {
m.Get("/create", org.Create)
- m.Post("/create", bindIgnErr(auth.CreateOrgForm{}), org.CreatePost)
+ m.Post("/create", bindIgnErr(form.CreateOrg{}), org.CreatePost)
}, func(ctx *context.Context) {
if !ctx.User.CanCreateOrganization() {
ctx.NotFound()
@@ -390,28 +390,28 @@ func runWeb(ctx *cli.Context) error {
m.Group("/:org", func() {
m.Get("/teams/new", org.NewTeam)
- m.Post("/teams/new", bindIgnErr(auth.CreateTeamForm{}), org.NewTeamPost)
+ m.Post("/teams/new", bindIgnErr(form.CreateTeam{}), org.NewTeamPost)
m.Get("/teams/:team/edit", org.EditTeam)
- m.Post("/teams/:team/edit", bindIgnErr(auth.CreateTeamForm{}), org.EditTeamPost)
+ m.Post("/teams/:team/edit", bindIgnErr(form.CreateTeam{}), org.EditTeamPost)
m.Post("/teams/:team/delete", org.DeleteTeam)
m.Group("/settings", func() {
m.Combo("").Get(org.Settings).
- Post(bindIgnErr(auth.UpdateOrgSettingForm{}), org.SettingsPost)
- m.Post("/avatar", binding.MultipartForm(auth.AvatarForm{}), org.SettingsAvatar)
+ Post(bindIgnErr(form.UpdateOrgSetting{}), org.SettingsPost)
+ m.Post("/avatar", binding.MultipartForm(form.Avatar{}), org.SettingsAvatar)
m.Post("/avatar/delete", org.SettingsDeleteAvatar)
m.Group("/hooks", func() {
m.Get("", org.Webhooks)
m.Post("/delete", org.DeleteWebhook)
m.Get("/:type/new", repo.WebhooksNew)
- m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
- m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
- m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
+ m.Post("/gogs/new", bindIgnErr(form.NewWebhook{}), repo.WebHooksNewPost)
+ m.Post("/slack/new", bindIgnErr(form.NewSlackHook{}), repo.SlackHooksNewPost)
+ m.Post("/discord/new", bindIgnErr(form.NewDiscordHook{}), repo.DiscordHooksNewPost)
m.Get("/:id", repo.WebHooksEdit)
- m.Post("/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
- m.Post("/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
- m.Post("/discord/:id", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksEditPost)
+ m.Post("/gogs/:id", bindIgnErr(form.NewWebhook{}), repo.WebHooksEditPost)
+ m.Post("/slack/:id", bindIgnErr(form.NewSlackHook{}), repo.SlackHooksEditPost)
+ m.Post("/discord/:id", bindIgnErr(form.NewDiscordHook{}), repo.DiscordHooksEditPost)
})
m.Route("/delete", "GET,POST", org.SettingsDelete)
@@ -425,17 +425,17 @@ func runWeb(ctx *cli.Context) error {
// ***** START: Repository *****
m.Group("/repo", func() {
m.Get("/create", repo.Create)
- m.Post("/create", bindIgnErr(auth.CreateRepoForm{}), repo.CreatePost)
+ m.Post("/create", bindIgnErr(form.CreateRepo{}), repo.CreatePost)
m.Get("/migrate", repo.Migrate)
- m.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), repo.MigratePost)
+ m.Post("/migrate", bindIgnErr(form.MigrateRepo{}), repo.MigratePost)
m.Combo("/fork/:repoid").Get(repo.Fork).
- Post(bindIgnErr(auth.CreateRepoForm{}), repo.ForkPost)
+ Post(bindIgnErr(form.CreateRepo{}), repo.ForkPost)
}, reqSignIn)
m.Group("/:username/:reponame", func() {
m.Group("/settings", func() {
m.Combo("").Get(repo.Settings).
- Post(bindIgnErr(auth.RepoSettingForm{}), repo.SettingsPost)
+ Post(bindIgnErr(form.RepoSetting{}), repo.SettingsPost)
m.Group("/collaboration", func() {
m.Combo("").Get(repo.SettingsCollaboration).Post(repo.SettingsCollaborationPost)
m.Post("/access_mode", repo.ChangeCollaborationAccessMode)
@@ -445,7 +445,7 @@ func runWeb(ctx *cli.Context) error {
m.Get("", repo.SettingsBranches)
m.Post("/default_branch", repo.UpdateDefaultBranch)
m.Combo("/*").Get(repo.SettingsProtectedBranch).
- Post(bindIgnErr(auth.ProtectBranchForm{}), repo.SettingsProtectedBranchPost)
+ Post(bindIgnErr(form.ProtectBranch{}), repo.SettingsProtectedBranchPost)
}, func(ctx *context.Context) {
if ctx.Repo.Repository.IsMirror {
ctx.NotFound()
@@ -457,14 +457,14 @@ func runWeb(ctx *cli.Context) error {
m.Get("", repo.Webhooks)
m.Post("/delete", repo.DeleteWebhook)
m.Get("/:type/new", repo.WebhooksNew)
- m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
- m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
- m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
+ m.Post("/gogs/new", bindIgnErr(form.NewWebhook{}), repo.WebHooksNewPost)
+ m.Post("/slack/new", bindIgnErr(form.NewSlackHook{}), repo.SlackHooksNewPost)
+ m.Post("/discord/new", bindIgnErr(form.NewDiscordHook{}), repo.DiscordHooksNewPost)
m.Get("/:id", repo.WebHooksEdit)
m.Post("/:id/test", repo.TestWebhook)
- m.Post("/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
- m.Post("/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
- m.Post("/discord/:id", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksEditPost)
+ m.Post("/gogs/:id", bindIgnErr(form.NewWebhook{}), repo.WebHooksEditPost)
+ m.Post("/slack/:id", bindIgnErr(form.NewSlackHook{}), repo.SlackHooksEditPost)
+ m.Post("/discord/:id", bindIgnErr(form.NewDiscordHook{}), repo.DiscordHooksEditPost)
m.Group("/git", func() {
m.Get("", repo.SettingsGitHooks)
@@ -475,7 +475,7 @@ func runWeb(ctx *cli.Context) error {
m.Group("/keys", func() {
m.Combo("").Get(repo.SettingsDeployKeys).
- Post(bindIgnErr(auth.AddSSHKeyForm{}), repo.SettingsDeployKeysPost)
+ Post(bindIgnErr(form.AddSSHKey{}), repo.SettingsDeployKeysPost)
m.Post("/delete", repo.DeleteDeployKey)
})
@@ -490,7 +490,7 @@ func runWeb(ctx *cli.Context) error {
// So they can apply their own enable/disable logic on routers.
m.Group("/issues", func() {
m.Combo("/new", repo.MustEnableIssues).Get(context.RepoRef(), repo.NewIssue).
- Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost)
+ Post(bindIgnErr(form.CreateIssue{}), repo.NewIssuePost)
m.Group("/:index", func() {
m.Post("/label", repo.UpdateIssueLabel)
@@ -501,7 +501,7 @@ func runWeb(ctx *cli.Context) error {
m.Group("/:index", func() {
m.Post("/title", repo.UpdateIssueTitle)
m.Post("/content", repo.UpdateIssueContent)
- m.Combo("/comments").Post(bindIgnErr(auth.CreateCommentForm{}), repo.NewComment)
+ m.Combo("/comments").Post(bindIgnErr(form.CreateComment{}), repo.NewComment)
})
})
m.Group("/comments/:id", func() {
@@ -509,26 +509,26 @@ func runWeb(ctx *cli.Context) error {
m.Post("/delete", repo.DeleteComment)
})
m.Group("/labels", func() {
- m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
- m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
+ m.Post("/new", bindIgnErr(form.CreateLabel{}), repo.NewLabel)
+ m.Post("/edit", bindIgnErr(form.CreateLabel{}), repo.UpdateLabel)
m.Post("/delete", repo.DeleteLabel)
- m.Post("/initialize", bindIgnErr(auth.InitializeLabelsForm{}), repo.InitializeLabels)
+ m.Post("/initialize", bindIgnErr(form.InitializeLabels{}), repo.InitializeLabels)
}, reqRepoWriter, context.RepoRef())
m.Group("/milestones", func() {
m.Combo("/new").Get(repo.NewMilestone).
- Post(bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
+ Post(bindIgnErr(form.CreateMilestone{}), repo.NewMilestonePost)
m.Get("/:id/edit", repo.EditMilestone)
- m.Post("/:id/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.EditMilestonePost)
+ m.Post("/:id/edit", bindIgnErr(form.CreateMilestone{}), repo.EditMilestonePost)
m.Get("/:id/:action", repo.ChangeMilestonStatus)
m.Post("/delete", repo.DeleteMilestone)
}, reqRepoWriter, context.RepoRef())
m.Group("/releases", func() {
m.Get("/new", repo.NewRelease)
- m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
+ m.Post("/new", bindIgnErr(form.NewRelease{}), repo.NewReleasePost)
m.Post("/delete", repo.DeleteRelease)
m.Get("/edit/*", repo.EditRelease)
- m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
+ m.Post("/edit/*", bindIgnErr(form.EditRelease{}), repo.EditReleasePost)
}, reqRepoWriter, context.RepoRef())
// FIXME: Should use ctx.Repo.PullRequest to unify template, currently we have inconsistent URL
@@ -536,22 +536,22 @@ func runWeb(ctx *cli.Context) error {
// e.g. /org1/test-repo/compare/master...org1:develop
// which should be /org1/test-repo/compare/master...develop
m.Combo("/compare/*", repo.MustAllowPulls).Get(repo.CompareAndPullRequest).
- Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
+ Post(bindIgnErr(form.CreateIssue{}), repo.CompareAndPullRequestPost)
m.Group("", func() {
m.Combo("/_edit/*").Get(repo.EditFile).
- Post(bindIgnErr(auth.EditRepoFileForm{}), repo.EditFilePost)
+ Post(bindIgnErr(form.EditRepoFile{}), repo.EditFilePost)
m.Combo("/_new/*").Get(repo.NewFile).
- Post(bindIgnErr(auth.EditRepoFileForm{}), repo.NewFilePost)
- m.Post("/_preview/*", bindIgnErr(auth.EditPreviewDiffForm{}), repo.DiffPreviewPost)
+ Post(bindIgnErr(form.EditRepoFile{}), repo.NewFilePost)
+ m.Post("/_preview/*", bindIgnErr(form.EditPreviewDiff{}), repo.DiffPreviewPost)
m.Combo("/_delete/*").Get(repo.DeleteFile).
- Post(bindIgnErr(auth.DeleteRepoFileForm{}), repo.DeleteFilePost)
+ Post(bindIgnErr(form.DeleteRepoFile{}), repo.DeleteFilePost)
m.Group("", func() {
m.Combo("/_upload/*").Get(repo.UploadFile).
- Post(bindIgnErr(auth.UploadRepoFileForm{}), repo.UploadFilePost)
+ Post(bindIgnErr(form.UploadRepoFile{}), repo.UploadFilePost)
m.Post("/upload-file", repo.UploadFileToServer)
- m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
+ m.Post("/upload-remove", bindIgnErr(form.RemoveUploadFile{}), repo.RemoveUploadFileFromServer)
}, func(ctx *context.Context) {
if !setting.Repository.Upload.Enabled {
ctx.NotFound()
@@ -584,9 +584,9 @@ func runWeb(ctx *cli.Context) error {
m.Group("", func() {
m.Combo("/_new").Get(repo.NewWiki).
- Post(bindIgnErr(auth.NewWikiForm{}), repo.NewWikiPost)
+ Post(bindIgnErr(form.NewWiki{}), repo.NewWikiPost)
m.Combo("/:page/_edit").Get(repo.EditWiki).
- Post(bindIgnErr(auth.NewWikiForm{}), repo.EditWikiPost)
+ Post(bindIgnErr(form.NewWiki{}), repo.EditWikiPost)
m.Post("/:page/delete", repo.DeleteWikiPagePost)
}, reqSignIn, reqRepoWriter)
}, repo.MustEnableWiki, context.RepoRef())