diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10666537e..002abb1e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,7 +81,7 @@ jobs: -X \"gogs.io/gogs/internal/conf.BuildCommit=$(git rev-parse HEAD)\" " \ $TAGS_FLAG \ - -trimpath -o "$BINARY_NAME" + -trimpath -o "$BINARY_NAME" ./cmd/gogs - name: Prepare archive contents run: | mkdir -p dist/gogs diff --git a/Taskfile.yml b/Taskfile.yml index 20b50f6cb..63d2db404 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -24,7 +24,7 @@ tasks: -X "{{.PKG_PATH}}.BuildCommit={{.BUILD_COMMIT}}" ' -tags '{{.TAGS}}' - -trimpath -o .bin/gogs{{.BINARY_EXT}} + -trimpath -o .bin/gogs{{.BINARY_EXT}} ./cmd/gogs vars: PKG_PATH: gogs.io/gogs/internal/conf BUILD_TIME: @@ -33,7 +33,7 @@ tasks: sh: git rev-parse HEAD sources: - go.mod - - gogs.go + - cmd/gogs/*.go - internal/**/*.go - conf/**/* - public/**/* diff --git a/internal/cmd/admin.go b/cmd/gogs/admin.go similarity index 99% rename from internal/cmd/admin.go rename to cmd/gogs/admin.go index 4542ec2af..b2a8623b0 100644 --- a/internal/cmd/admin.go +++ b/cmd/gogs/admin.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "context" @@ -14,7 +14,7 @@ import ( ) var ( - Admin = cli.Command{ + adminCommand = cli.Command{ Name: "admin", Usage: "Perform admin operations on command line", Description: `Allow using internal logic of Gogs without hacking into the source code diff --git a/internal/cmd/backup.go b/cmd/gogs/backup.go similarity index 99% rename from internal/cmd/backup.go rename to cmd/gogs/backup.go index af45a73ab..b27f7232b 100644 --- a/internal/cmd/backup.go +++ b/cmd/gogs/backup.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "context" @@ -20,7 +20,7 @@ import ( "gogs.io/gogs/internal/osutil" ) -var Backup = cli.Command{ +var backupCommand = cli.Command{ Name: "backup", Usage: "Backup files and database", Description: `Backup dumps and compresses all related files and database into zip file, diff --git a/internal/cmd/cert.go b/cmd/gogs/cert.go similarity index 99% rename from internal/cmd/cert.go rename to cmd/gogs/cert.go index e90c11687..5d7665ad8 100644 --- a/internal/cmd/cert.go +++ b/cmd/gogs/cert.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package cmd +package main import ( "crypto/ecdsa" @@ -22,7 +22,7 @@ import ( "github.com/urfave/cli" ) -var Cert = cli.Command{ +var certCommand = cli.Command{ Name: "cert", Usage: "Generate self-signed certificate", Description: `Generate a self-signed X.509 certificate for a TLS server. diff --git a/internal/cmd/cmd.go b/cmd/gogs/cmd.go similarity index 90% rename from internal/cmd/cmd.go rename to cmd/gogs/cmd.go index 90b3ece2d..e17a1bd2c 100644 --- a/internal/cmd/cmd.go +++ b/cmd/gogs/cmd.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "time" @@ -21,7 +21,6 @@ func boolFlag(name, usage string) cli.BoolFlag { } } -//nolint:deadcode,unused func intFlag(name string, value int, usage string) cli.IntFlag { return cli.IntFlag{ Name: name, @@ -30,7 +29,6 @@ func intFlag(name string, value int, usage string) cli.IntFlag { } } -//nolint:deadcode,unused func durationFlag(name string, value time.Duration, usage string) cli.DurationFlag { return cli.DurationFlag{ Name: name, diff --git a/internal/cmd/hook.go b/cmd/gogs/hook.go similarity index 99% rename from internal/cmd/hook.go rename to cmd/gogs/hook.go index 030aa2202..248a3bad9 100644 --- a/internal/cmd/hook.go +++ b/cmd/gogs/hook.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "bufio" @@ -24,7 +24,7 @@ import ( ) var ( - Hook = cli.Command{ + hookCommand = cli.Command{ Name: "hook", Usage: "Delegate commands to corresponding Git hooks", Description: "All sub-commands should only be called by Git", diff --git a/internal/cmd/import.go b/cmd/gogs/import.go similarity index 98% rename from internal/cmd/import.go rename to cmd/gogs/import.go index b8bbd55f7..ef01609cf 100644 --- a/internal/cmd/import.go +++ b/cmd/gogs/import.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "bufio" @@ -16,7 +16,7 @@ import ( ) var ( - Import = cli.Command{ + importCommand = 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/gogs.go b/cmd/gogs/main.go similarity index 78% rename from gogs.go rename to cmd/gogs/main.go index 2e2e5409e..0c6d8d05c 100644 --- a/gogs.go +++ b/cmd/gogs/main.go @@ -7,7 +7,6 @@ import ( "github.com/urfave/cli" log "unknwon.dev/clog/v2" - "gogs.io/gogs/internal/cmd" "gogs.io/gogs/internal/conf" ) @@ -21,14 +20,14 @@ func main() { app.Usage = "A painless self-hosted Git service" app.Version = conf.App.Version app.Commands = []cli.Command{ - cmd.Web, - cmd.Serv, - cmd.Hook, - cmd.Cert, - cmd.Admin, - cmd.Import, - cmd.Backup, - cmd.Restore, + webCommand, + servCommand, + hookCommand, + certCommand, + adminCommand, + importCommand, + backupCommand, + restoreCommand, } if err := app.Run(os.Args); err != nil { log.Fatal("Failed to start application: %v", err) diff --git a/internal/cmd/restore.go b/cmd/gogs/restore.go similarity index 99% rename from internal/cmd/restore.go rename to cmd/gogs/restore.go index 04731e989..0290ec0c9 100644 --- a/internal/cmd/restore.go +++ b/cmd/gogs/restore.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "context" @@ -18,7 +18,7 @@ import ( "gogs.io/gogs/internal/semverutil" ) -var Restore = cli.Command{ +var restoreCommand = cli.Command{ Name: "restore", Usage: "Restore files and database from backup", Description: `Restore imports all related files and database from a backup archive. diff --git a/internal/cmd/serv.go b/cmd/gogs/serv.go similarity index 99% rename from internal/cmd/serv.go rename to cmd/gogs/serv.go index 38a69c9aa..104960008 100644 --- a/internal/cmd/serv.go +++ b/cmd/gogs/serv.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "context" @@ -21,7 +21,7 @@ const ( accessDeniedMessage = "Repository does not exist or you do not have access" ) -var Serv = cli.Command{ +var servCommand = cli.Command{ Name: "serv", Usage: "This command should only be called by SSH shell", Description: `Serv provide access auth for repositories`, diff --git a/internal/cmd/web.go b/cmd/gogs/web.go similarity index 99% rename from internal/cmd/web.go rename to cmd/gogs/web.go index 919b99b25..558d3c1f3 100644 --- a/internal/cmd/web.go +++ b/cmd/gogs/web.go @@ -1,4 +1,4 @@ -package cmd +package main import ( "crypto/tls" @@ -45,7 +45,7 @@ import ( "gogs.io/gogs/templates" ) -var Web = cli.Command{ +var webCommand = cli.Command{ Name: "web", Usage: "Start web server", Description: `Gogs web server is the only thing you need to run, diff --git a/internal/conf/static.go b/internal/conf/static.go index cbfc3eaac..777cf4e83 100644 --- a/internal/conf/static.go +++ b/internal/conf/static.go @@ -231,7 +231,7 @@ var ( ) type AppOpts struct { - // ⚠️ WARNING: Should only be set by the main package (i.e. "gogs.go"). + // ⚠️ WARNING: Should only be set by the main package (i.e. "cmd/gogs/main.go"). Version string `ini:"-"` BrandName string @@ -502,7 +502,7 @@ func checkInvalidOptions(config *ini.File) (warnings []string) { // HookMode indicates whether program starts as Git server-side hook callback. // All operations should be done synchronously to prevent program exits before finishing. // -// ⚠️ WARNING: Should only be set by "internal/cmd/serv.go". +// ⚠️ WARNING: Should only be set by "cmd/gogs/serv.go". var HookMode bool // Indicates which database backend is currently being used.