diff --git a/Dockerfile b/Dockerfile index 3ed86570a..8453b4791 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,6 +91,7 @@ ENTRYPOINT ["/usr/bin/entrypoint"] CMD ["/bin/s6-svscan", "/etc/s6"] COPY --from=build-env /tmp/local / +RUN cd /usr/local/bin ; ln -s gitea forgejo COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh diff --git a/Dockerfile.rootless b/Dockerfile.rootless index e66266962..ff319e595 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -79,6 +79,7 @@ RUN mkdir -p /var/lib/gitea /etc/gitea RUN chown git:git /var/lib/gitea /etc/gitea COPY --from=build-env /tmp/local / +RUN cd /usr/local/bin ; ln -s gitea forgejo COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh diff --git a/Makefile b/Makefile index 724511a29..46531481b 100644 --- a/Makefile +++ b/Makefile @@ -150,6 +150,7 @@ SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEs SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|"basePath": "/api/v1"|g SWAGGER_EXCLUDE := code.gitea.io/sdk SWAGGER_NEWLINE_COMMAND := -e '$$a\' +SWAGGER_SPEC_BRANDING := s|Gitea API|Forgejo API|g TEST_MYSQL_HOST ?= mysql:3306 TEST_MYSQL_DBNAME ?= testgitea @@ -340,6 +341,7 @@ $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA) $(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)' $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)' + $(SED_INPLACE) '$(SWAGGER_SPEC_BRANDING)' './$(SWAGGER_SPEC)' .PHONY: swagger-check swagger-check: generate-swagger @@ -849,6 +851,9 @@ security-check: $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ +forgejo: $(EXECUTABLE) + ln -f $(EXECUTABLE) forgejo + static-executable: $(GO_SOURCES) $(TAGS_PREREQ) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags 'netgo osusergo $(TAGS)' -ldflags '-s -w -linkmode external -extldflags "-static" $(LDFLAGS)' -o $(EXECUTABLE) diff --git a/README.md b/README.md index e223979d4..2c0a3ef3e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
- +

Welcome to Forgejo

diff --git a/assets/favicon.svg b/assets/favicon.svg index 9df6b83b5..bcacdc020 100644 --- a/assets/favicon.svg +++ b/assets/favicon.svg @@ -1,31 +1,27 @@ - - - - - - - - - - - + + + + + + + + + diff --git a/assets/logo.svg b/assets/logo.svg index 9df6b83b5..bcacdc020 100644 --- a/assets/logo.svg +++ b/assets/logo.svg @@ -1,31 +1,27 @@ - - - - - - - - - - - + + + + + + + + + diff --git a/cmd/actions.go b/cmd/actions.go index 052afb9eb..6b9ce19d6 100644 --- a/cmd/actions.go +++ b/cmd/actions.go @@ -17,7 +17,7 @@ var ( CmdActions = &cli.Command{ Name: "actions", Usage: "", - Description: "Commands for managing Gitea Actions", + Description: "Commands for managing Forgejo Actions", Subcommands: []*cli.Command{ subcmdActionsGenRunnerToken, }, diff --git a/cmd/cert.go b/cmd/cert.go index 38241d71a..bf83af389 100644 --- a/cmd/cert.go +++ b/cmd/cert.go @@ -136,7 +136,7 @@ func runCert(c *cli.Context) error { SerialNumber: serialNumber, Subject: pkix.Name{ Organization: []string{"Acme Co"}, - CommonName: "Gitea", + CommonName: "Forgejo", }, NotBefore: notBefore, NotAfter: notAfter, diff --git a/cmd/docs.go b/cmd/docs.go index 605d02e3e..1dc0980c0 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -15,7 +15,7 @@ import ( var CmdDocs = &cli.Command{ Name: "docs", Usage: "Output CLI documentation", - Description: "A command to output Gitea's CLI documentation, optionally to a file.", + Description: "A command to output Forgejo's CLI documentation, optionally to a file.", Action: runDocs, Flags: []cli.Flag{ &cli.BoolFlag{ diff --git a/cmd/doctor.go b/cmd/doctor.go index d040a3af1..3230893fd 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -25,7 +25,7 @@ import ( var cmdDoctorCheck = &cli.Command{ Name: "check", Usage: "Diagnose and optionally fix problems", - Description: "A command to diagnose problems with the current Gitea instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.", + Description: "A command to diagnose problems with the current Forgejo instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.", Action: runDoctorCheck, Flags: []cli.Flag{ &cli.BoolFlag{ @@ -64,7 +64,7 @@ var cmdDoctorCheck = &cli.Command{ var CmdDoctor = &cli.Command{ Name: "doctor", Usage: "Diagnose and optionally fix problems", - Description: "A command to diagnose problems with the current Gitea instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.", + Description: "A command to diagnose problems with the current Forgejo instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.", Subcommands: []*cli.Command{ cmdDoctorCheck, @@ -83,7 +83,7 @@ var cmdRecreateTable = &cli.Command{ Usage: "Print SQL commands sent", }, }, - Description: `The database definitions Gitea uses change across versions, sometimes changing default values and leaving old unused columns. + Description: `The database definitions Forgejo uses change across versions, sometimes changing default values and leaving old unused columns. This command will cause Xorm to recreate tables, copying over the data and deleting the old table. diff --git a/cmd/dump.go b/cmd/dump.go index 97f292ae0..99d9f3897 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -98,15 +98,15 @@ var outputTypeEnum = &outputType{ // CmdDump represents the available dump sub-command. var CmdDump = &cli.Command{ Name: "dump", - Usage: "Dump Gitea files and database", + Usage: "Dump Forgejo files and database", Description: `Dump compresses all related files and database into zip file. -It can be used for backup and capture Gitea server image to send to maintainer`, +It can be used for backup and capture Forgejo server image to send to maintainer`, Action: runDump, Flags: []cli.Flag{ &cli.StringFlag{ Name: "file", Aliases: []string{"f"}, - Value: fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()), + Value: fmt.Sprintf("forgejo-dump-%d.zip", time.Now().Unix()), Usage: "Name of the dump file which will be created. Supply '-' for stdout. See type for available types.", }, &cli.BoolFlag{ @@ -209,7 +209,7 @@ func runDump(ctx *cli.Context) error { if !setting.InstallLock { log.Error("Is '%s' really the right config path?\n", setting.CustomConf) - return fmt.Errorf("gitea is not initialized") + return fmt.Errorf("forgejo is not initialized") } setting.LoadSettings() // cannot access session settings otherwise @@ -288,7 +288,7 @@ func runDump(ctx *cli.Context) error { fatal("Path does not exist: %s", tmpDir) } - dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql") + dbDump, err := os.CreateTemp(tmpDir, "forgejo-db.sql") if err != nil { fatal("Failed to create tmp file: %v", err) } @@ -310,8 +310,8 @@ func runDump(ctx *cli.Context) error { fatal("Failed to dump database: %v", err) } - if err := addFile(w, "gitea-db.sql", dbDump.Name(), verbose); err != nil { - fatal("Failed to include gitea-db.sql: %v", err) + if err := addFile(w, "forgejo-db.sql", dbDump.Name(), verbose); err != nil { + fatal("Failed to include forgejo-db.sql: %v", err) } if len(setting.CustomConf) > 0 { diff --git a/cmd/hook.go b/cmd/hook.go index f38fd8831..403f2c6ea 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -172,9 +172,9 @@ func runHookPreReceive(c *cli.Context) error { if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 { if setting.OnlyAllowPushIfGiteaEnvironmentSet { - return fail(ctx, `Rejecting changes as Gitea environment not set. + return fail(ctx, `Rejecting changes as Forgejo environment not set. If you are pushing over SSH you must push with a key managed by -Gitea or set your environment appropriately.`, "") +Forgejo or set your environment appropriately.`, "") } return nil } @@ -316,9 +316,9 @@ func runHookPostReceive(c *cli.Context) error { if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 { if setting.OnlyAllowPushIfGiteaEnvironmentSet { - return fail(ctx, `Rejecting changes as Gitea environment not set. + return fail(ctx, `Rejecting changes as Forgejo environment not set. If you are pushing over SSH you must push with a key managed by -Gitea or set your environment appropriately.`, "") +Forgejo or set your environment appropriately.`, "") } return nil } @@ -485,9 +485,9 @@ func runHookProcReceive(c *cli.Context) error { if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 { if setting.OnlyAllowPushIfGiteaEnvironmentSet { - return fail(ctx, `Rejecting changes as Gitea environment not set. + return fail(ctx, `Rejecting changes as Forgejo environment not set. If you are pushing over SSH you must push with a key managed by -Gitea or set your environment appropriately.`, "") +Forgejo or set your environment appropriately.`, "") } return nil } diff --git a/cmd/keys.go b/cmd/keys.go index b84678252..94ccfd985 100644 --- a/cmd/keys.go +++ b/cmd/keys.go @@ -17,7 +17,7 @@ import ( // CmdKeys represents the available keys sub-command var CmdKeys = &cli.Command{ Name: "keys", - Usage: "This command queries the Gitea database to get the authorized command for a given ssh key fingerprint", + Usage: "This command queries the Forgejo database to get the authorized command for a given ssh key fingerprint", Before: PrepareConsoleLoggerLevel(log.FATAL), Action: runKeys, Flags: []cli.Flag{ diff --git a/cmd/main.go b/cmd/main.go index 04209c824..6bc0ba515 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -78,7 +78,7 @@ func appGlobalFlags() []cli.Flag { &cli.StringFlag{ Name: "work-path", Aliases: []string{"w"}, - Usage: "Set Gitea's working path (defaults to the Gitea's binary directory)", + Usage: "Set Forgejo's working path (defaults to the directory of the Forgejo binary)", }, } } @@ -153,9 +153,9 @@ func NewMainApp(version, versionExtra string) *cli.App { func innerNewMainApp(version, versionExtra string, subCmdsStandaloneArgs, subCmdWithConfigArgs []*cli.Command) *cli.App { app := cli.NewApp() - app.Name = "Gitea" - app.Usage = "A painless self-hosted Git service" - app.Description = `By default, Gitea will start serving using the web-server with no argument, which can alternatively be run by running the subcommand "web".` + app.Name = "Forgejo" + app.Usage = "Beyond coding. We forge." + app.Description = `By default, forgejo will start serving using the web-server with no argument, which can alternatively be run by running the subcommand "web".` app.Version = version + versionExtra app.EnableBashCompletion = true diff --git a/cmd/manager.go b/cmd/manager.go index bd2da8edc..b74771e53 100644 --- a/cmd/manager.go +++ b/cmd/manager.go @@ -16,8 +16,8 @@ var ( // CmdManager represents the manager command CmdManager = &cli.Command{ Name: "manager", - Usage: "Manage the running gitea process", - Description: "This is a command for managing the running gitea process", + Usage: "Manage the running forgejo process", + Description: "This is a command for managing the running forgejo process", Subcommands: []*cli.Command{ subcmdShutdown, subcmdRestart, diff --git a/cmd/manager_logging.go b/cmd/manager_logging.go index 7d34fc9ac..2c701f267 100644 --- a/cmd/manager_logging.go +++ b/cmd/manager_logging.go @@ -62,7 +62,7 @@ var ( Subcommands: []*cli.Command{ { Name: "pause", - Usage: "Pause logging (Gitea will buffer logs up to a certain point and will drop them after that point)", + Usage: "Pause logging (Forgejo will buffer logs up to a certain point and will drop them after that point)", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "debug", @@ -80,7 +80,7 @@ var ( Action: runResumeLogging, }, { Name: "release-and-reopen", - Usage: "Cause Gitea to release and re-open files used for logging", + Usage: "Cause Forgejo to release and re-open files used for logging", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "debug", diff --git a/cmd/serv.go b/cmd/serv.go index 26fc91a3b..43e6eaba2 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -103,12 +103,12 @@ func fail(ctx context.Context, userMessage, logMsgFmt string, args ...any) error // There appears to be a chance to cause a zombie process and failure to read the Exit status // if nothing is outputted on stdout. _, _ = fmt.Fprintln(os.Stdout, "") - _, _ = fmt.Fprintln(os.Stderr, "Gitea:", userMessage) + _, _ = fmt.Fprintln(os.Stderr, "Forgejo:", userMessage) if logMsgFmt != "" { logMsg := fmt.Sprintf(logMsgFmt, args...) if !setting.IsProd { - _, _ = fmt.Fprintln(os.Stderr, "Gitea:", logMsg) + _, _ = fmt.Fprintln(os.Stderr, "Forgejo:", logMsg) } if userMessage != "" { if unicode.IsPunct(rune(userMessage[len(userMessage)-1])) { @@ -143,7 +143,7 @@ func runServ(c *cli.Context) error { setup(ctx, c.Bool("debug")) if setting.SSH.Disabled { - println("Gitea: SSH has been disabled") + println("Forgejo: SSH has been disabled") return nil } @@ -171,13 +171,13 @@ func runServ(c *cli.Context) error { } switch key.Type { case asymkey_model.KeyTypeDeploy: - println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.") + println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Forgejo does not provide shell access.") case asymkey_model.KeyTypePrincipal: - println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Gitea does not provide shell access.") + println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Forgejo does not provide shell access.") default: - println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.") + println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Forgejo does not provide shell access.") } - println("If this is unexpected, please log in with password and setup Gitea under another user.") + println("If this is unexpected, please log in with password and setup Forgejo under another user.") return nil } else if c.Bool("debug") { log.Debug("SSH_ORIGINAL_COMMAND: %s", os.Getenv("SSH_ORIGINAL_COMMAND")) diff --git a/cmd/web.go b/cmd/web.go index 01386251b..ef82486c1 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -34,8 +34,8 @@ var PIDFile = "/run/gitea.pid" // CmdWeb represents the available web sub-command. var CmdWeb = &cli.Command{ Name: "web", - Usage: "Start Gitea web server", - Description: `Gitea web server is the only thing you need to run, + Usage: "Start the Forgejo web server", + Description: `The Forgejo web server is the only thing you need to run, and it takes care of all the other things for you`, Before: PrepareConsoleLoggerLevel(log.INFO), Action: runWeb, @@ -108,7 +108,7 @@ func createPIDFile(pidPath string) { } func showWebStartupMessage(msg string) { - log.Info("Gitea version: %s%s", setting.AppVer, setting.AppBuiltWith) + log.Info("Forgejo version: %s%s", setting.AppVer, setting.AppBuiltWith) log.Info("* RunMode: %s", setting.RunMode) log.Info("* AppPath: %s", setting.AppPath) log.Info("* WorkPath: %s", setting.AppWorkPath) @@ -136,13 +136,13 @@ func serveInstall(ctx *cli.Context) error { c := install.Routes() err := listen(c, false) if err != nil { - log.Critical("Unable to open listener for installer. Is Gitea already running?") + log.Critical("Unable to open listener for installer. Is Forgejo already running?") graceful.GetManager().DoGracefulShutdown() } select { case <-graceful.GetManager().IsShutdown(): <-graceful.GetManager().Done() - log.Info("PID: %d Gitea Web Finished", os.Getpid()) + log.Info("PID: %d Forgejo Web Finished", os.Getpid()) log.GetManager().Close() return err default: @@ -211,7 +211,7 @@ func serveInstalled(ctx *cli.Context) error { webRoutes := routers.NormalRoutes() err := listen(webRoutes, true) <-graceful.GetManager().Done() - log.Info("PID: %d Gitea Web Finished", os.Getpid()) + log.Info("PID: %d Forgejo Web Finished", os.Getpid()) log.GetManager().Close() return err } @@ -237,9 +237,9 @@ func runWeb(ctx *cli.Context) error { defer cancel() if os.Getppid() > 1 && len(os.Getenv("LISTEN_FDS")) > 0 { - log.Info("Restarting Gitea on PID: %d from parent PID: %d", os.Getpid(), os.Getppid()) + log.Info("Restarting Forgejo on PID: %d from parent PID: %d", os.Getpid(), os.Getppid()) } else { - log.Info("Starting Gitea on PID: %d", os.Getpid()) + log.Info("Starting Forgejo on PID: %d", os.Getpid()) } // Set pid file setting @@ -299,7 +299,7 @@ func listen(m http.Handler, handleRedirector bool) error { if setting.Protocol != setting.HTTPUnix && setting.Protocol != setting.FCGIUnix { listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort) } - _, _, finished := process.GetManager().AddTypedContext(graceful.GetManager().HammerContext(), "Web: Gitea Server", process.SystemProcessType, true) + _, _, finished := process.GetManager().AddTypedContext(graceful.GetManager().HammerContext(), "Web: Forgejo Server", process.SystemProcessType, true) defer finished() log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL) // This can be useful for users, many users do wrong to their config and get strange behaviors behind a reverse-proxy. diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index 7758045fd..4cdda2b2b 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -16,15 +16,15 @@ func main() { app := cli.NewApp() app.Name = "environment-to-ini" app.Usage = "Use provided environment to update configuration ini" - app.Description = `As a helper to allow docker users to update the gitea configuration + app.Description = `As a helper to allow docker users to update the forgejo configuration through the environment, this command allows environment variables to be mapped to values in the ini. - Environment variables of the form "GITEA__SECTION_NAME__KEY_NAME" + Environment variables of the form "FORGEJO__SECTION_NAME__KEY_NAME" will be mapped to the ini section "[section_name]" and the key "KEY_NAME" with the value as provided. - Environment variables of the form "GITEA__SECTION_NAME__KEY_NAME__FILE" + Environment variables of the form "FORGEJO__SECTION_NAME__KEY_NAME__FILE" will be mapped to the ini section "[section_name]" and the key "KEY_NAME" with the value loaded from the specified file. @@ -42,8 +42,8 @@ func main() { ... """ - You would set the environment variables: "GITEA__LOG_0x2E_CONSOLE__COLORIZE=false" - and "GITEA__LOG_0x2E_CONSOLE__STDERR=false". Other examples can be found + You would set the environment variables: "FORGEJO__LOG_0x2E_CONSOLE__COLORIZE=false" + and "FORGEJO__LOG_0x2E_CONSOLE__STDERR=false". Other examples can be found on the configuration cheat sheet.` app.Flags = []cli.Flag{ &cli.StringFlag{ @@ -59,7 +59,7 @@ func main() { &cli.StringFlag{ Name: "work-path, w", Value: setting.AppWorkPath, - Usage: "Set the gitea working path", + Usage: "Set the forgejo working path", }, &cli.StringFlag{ Name: "out, o", diff --git a/contrib/systemd/gitea.service b/contrib/systemd/forgejo.service similarity index 58% rename from contrib/systemd/gitea.service rename to contrib/systemd/forgejo.service index c097fb0d1..04ef69adc 100644 --- a/contrib/systemd/gitea.service +++ b/contrib/systemd/forgejo.service @@ -1,5 +1,5 @@ [Unit] -Description=Gitea (Git with a cup of tea) +Description=Forgejo (Beyond coding. We forge.) After=syslog.target After=network.target ### @@ -25,21 +25,21 @@ After=network.target # If using socket activation for main http/s ### # -#After=gitea.main.socket -#Requires=gitea.main.socket +#After=forgejo.main.socket +#Requires=forgejo.main.socket # ### -# (You can also provide gitea an http fallback and/or ssh socket too) +# (You can also provide forgejo an http fallback and/or ssh socket too) # -# An example of /etc/systemd/system/gitea.main.socket +# An example of /etc/systemd/system/forgejo.main.socket ### ## ## [Unit] -## Description=Gitea Web Socket -## PartOf=gitea.service +## Description=Forgejo Web Socket +## PartOf=forgejo.service ## ## [Socket] -## Service=gitea.service +## Service=forgejo.service ## ListenStream= ## NoDelay=true ## @@ -52,32 +52,31 @@ After=network.target # Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that # LimitNOFILE=524288:524288 RestartSec=2s -Type=notify +Type=simple User=git Group=git -WorkingDirectory=/var/lib/gitea/ -# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file -# (manually creating /run/gitea doesn't work, because it would not persist across reboots) -#RuntimeDirectory=gitea -ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini +WorkingDirectory=/var/lib/forgejo/ +# If using Unix socket: tells systemd to create the /run/forgejo folder, which will contain the forgejo.sock file +# (manually creating /run/forgejo doesn't work, because it would not persist across reboots) +#RuntimeDirectory=forgejo +ExecStart=/usr/local/bin/forgejo web --config /etc/forgejo/app.ini Restart=always -Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea -WatchdogSec=30s +Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/forgejo # If you install Git to directory prefix other than default PATH (which happens # for example if you install other versions of Git side-to-side with # distribution version), uncomment below line and add that prefix to PATH # Don't forget to place git-lfs binary on the PATH below if you want to enable # Git LFS support #Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin -# If you want to bind Gitea to a port below 1024, uncomment -# the two values below, or use socket activation to pass Gitea its ports as above +# If you want to bind Forgejo to a port below 1024, uncomment +# the two values below, or use socket activation to pass Forgejo its ports as above ### #CapabilityBoundingSet=CAP_NET_BIND_SERVICE #AmbientCapabilities=CAP_NET_BIND_SERVICE ### # In some cases, when using CapabilityBoundingSet and AmbientCapabilities option, you may want to -# set the following value to false to allow capabilities to be applied on gitea process. The following -# value if set to true sandboxes gitea service and prevent any processes from running with privileges +# set the following value to false to allow capabilities to be applied on Forgejo process. The following +# value if set to true sandboxes Forgejo service and prevent any processes from running with privileges # in the host user namespace. ### #PrivateUsers=false diff --git a/contrib/upgrade.sh b/contrib/upgrade.sh index 4b166a02a..4240b5694 100755 --- a/contrib/upgrade.sh +++ b/contrib/upgrade.sh @@ -1,42 +1,42 @@ #!/usr/bin/env bash -# This is an update script for gitea installed via the binary distribution -# from dl.gitea.com on linux as systemd service. It performs a backup and updates -# Gitea in place. -# NOTE: This adds the GPG Signing Key of the Gitea maintainers to the keyring. +# This is an update script for forgejo installed via the binary distribution +# from codeberg.org/forgejo/forgejo on linux as systemd service. It +# performs a backup and updates Forgejo in place. +# NOTE: This adds the GPG Signing Key of the Forgejo maintainers to the keyring. # Depends on: bash, curl, xz, sha256sum. optionally jq, gpg # See section below for available environment vars. # When no version is specified, updates to the latest release. # Examples: # upgrade.sh 1.15.10 -# giteahome=/opt/gitea giteaconf=$giteahome/app.ini upgrade.sh +# forgejohome=/opt/forgejo forgejoconf=$forgejohome/app.ini upgrade.sh -# Check if gitea service is running -if ! pidof gitea &> /dev/null; then - echo "Error: gitea is not running." +# Check if forgejo service is running +if ! pidof forgejo &> /dev/null; then + echo "Error: forgejo is not running." exit 1 fi -# Continue with rest of the script if gitea is running -echo "Gitea is running. Continuing with rest of script..." +# Continue with rest of the script if forgejo is running +echo "Forgejo is running. Continuing with rest of script..." # apply variables from environment -: "${giteabin:="/usr/local/bin/gitea"}" -: "${giteahome:="/var/lib/gitea"}" -: "${giteaconf:="/etc/gitea/app.ini"}" -: "${giteauser:="git"}" +: "${forgejobin:="/usr/local/bin/forgejo"}" +: "${forgejohome:="/var/lib/forgejo"}" +: "${forgejoconf:="/etc/forgejo/app.ini"}" +: "${forgejouser:="git"}" : "${sudocmd:="sudo"}" : "${arch:="linux-amd64"}" -: "${service_start:="$sudocmd systemctl start gitea"}" -: "${service_stop:="$sudocmd systemctl stop gitea"}" -: "${service_status:="$sudocmd systemctl status gitea"}" -: "${backupopts:=""}" # see `gitea dump --help` for available options +: "${service_start:="$sudocmd systemctl start forgejo"}" +: "${service_stop:="$sudocmd systemctl stop forgejo"}" +: "${service_status:="$sudocmd systemctl status forgejo"}" +: "${backupopts:=""}" # see `forgejo dump --help` for available options -function giteacmd { +function forgejocmd { if [[ $sudocmd = "su" ]]; then # `-c` only accept one string as argument. - "$sudocmd" - "$giteauser" -c "$(printf "%q " "$giteabin" "--config" "$giteaconf" "--work-path" "$giteahome" "$@")" + "$sudocmd" - "$forgejouser" -c "$(printf "%q " "$forgejobin" "--config" "$forgejoconf" "--work-path" "$forgejohome" "$@")" else - "$sudocmd" --user "$giteauser" "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@" + "$sudocmd" --user "$forgejouser" "$forgejobin" --config "$forgejoconf" --work-path "$forgejohome" "$@" fi } @@ -49,7 +49,7 @@ function require { # parse command line arguments while true; do case "$1" in - -v | --version ) giteaversion="$2"; shift 2 ;; + -v | --version ) forgejoversion="$2"; shift 2 ;; -y | --yes ) no_confirm="yes"; shift ;; --ignore-gpg) ignore_gpg="yes"; shift ;; "" | -- ) shift; break ;; @@ -65,9 +65,9 @@ if [[ -f /etc/os-release ]]; then if [[ "$os_release" =~ "OpenWrt" ]]; then sudocmd="su" - service_start="/etc/init.d/gitea start" - service_stop="/etc/init.d/gitea stop" - service_status="/etc/init.d/gitea status" + service_start="/etc/init.d/forgejo start" + service_stop="/etc/init.d/forgejo stop" + service_status="/etc/init.d/forgejo status" else require systemctl fi @@ -76,31 +76,31 @@ fi require curl xz sha256sum "$sudocmd" # select version to install -if [[ -z "${giteaversion:-}" ]]; then +if [[ -z "${forgejoversion:-}" ]]; then require jq - giteaversion=$(curl --connect-timeout 10 -sL https://dl.gitea.com/gitea/version.json | jq -r .latest.version) - echo "Latest available version is $giteaversion" + forgejoversion=$(curl --connect-timeout 10 -sL 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases?draft=false&pre-release=false&limit=1' -H 'accept: application/json' | jq -r '.[0].tag_name | sub("v"; "")') + echo "Latest available version is $forgejoversion" fi # confirm update echo "Checking currently installed version..." -current=$(giteacmd --version | cut -d ' ' -f 3) -[[ "$current" == "$giteaversion" ]] && echo "$current is already installed, stopping." && exit 1 +current=$(forgejocmd --version | cut -d ' ' -f 3) +[[ "$current" == "$forgejoversion" ]] && echo "$current is already installed, stopping." && exit 1 if [[ -z "${no_confirm:-}" ]]; then - echo "Make sure to read the changelog first: https://github.com/go-gitea/gitea/blob/main/CHANGELOG.md" - echo "Are you ready to update Gitea from ${current} to ${giteaversion}? (y/N)" + echo "Make sure to read the changelog first: https://codeberg.org/forgejo/forgejo/src/branch/forgejo/CHANGELOG.md" + echo "Are you ready to update forgejo from ${current} to ${forgejoversion}? (y/N)" read -r confirm [[ "$confirm" == "y" ]] || [[ "$confirm" == "Y" ]] || exit 1 fi -echo "Upgrading gitea from $current to $giteaversion ..." +echo "Upgrading forgejo from $current to $forgejoversion ..." pushd "$(pwd)" &>/dev/null -cd "$giteahome" # needed for gitea dump later +cd "$forgejohome" # needed for forgejo dump later # download new binary -binname="gitea-${giteaversion}-${arch}" -binurl="https://dl.gitea.com/gitea/${giteaversion}/${binname}.xz" +binname="forgejo-${forgejoversion}-${arch}" +binurl="https://codeberg.org/forgejo/forgejo/releases/download/v${forgejoversion}/${binname}.xz" echo "Downloading $binurl..." curl --connect-timeout 10 --silent --show-error --fail --location -O "$binurl{,.sha256,.asc}" @@ -108,28 +108,28 @@ curl --connect-timeout 10 --silent --show-error --fail --location -O "$binurl{,. sha256sum -c "${binname}.xz.sha256" if [[ -z "${ignore_gpg:-}" ]]; then require gpg - gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 + gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710 gpg --verify "${binname}.xz.asc" "${binname}.xz" || { echo 'Signature does not match'; exit 1; } fi rm "${binname}".xz.{sha256,asc} # unpack binary + make executable xz --decompress --force "${binname}.xz" -chown "$giteauser" "$binname" +chown "$forgejouser" "$binname" chmod +x "$binname" -# stop gitea, create backup, replace binary, restart gitea -echo "Flushing gitea queues at $(date)" -giteacmd manager flush-queues -echo "Stopping gitea at $(date)" +# stop forgejo, create backup, replace binary, restart forgejo +echo "Flushing forgejo queues at $(date)" +forgejocmd manager flush-queues +echo "Stopping forgejo at $(date)" $service_stop -echo "Creating backup in $giteahome" -giteacmd dump $backupopts -echo "Updating binary at $giteabin" -cp -f "$giteabin" "$giteabin.bak" && mv -f "$binname" "$giteabin" +echo "Creating backup in $forgejohome" +forgejocmd dump $backupopts +echo "Updating binary at $forgejobin" +cp -f "$forgejobin" "$forgejobin.bak" && mv -f "$binname" "$forgejobin" $service_start $service_status -echo "Upgrade to $giteaversion successful!" +echo "Upgrade to $forgejoversion successful!" popd diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6a9ab3da5..f3c17514e 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -368,7 +368,7 @@ USER = root ;; SQLite Configuration ;; ;DB_TYPE = sqlite3 -;PATH= ; defaults to data/gitea.db +;PATH= ; defaults to data/forgejo.db ;SQLITE_TIMEOUT = ; Query timeout defaults to: 500 ;SQLITE_JOURNAL_MODE = ; defaults to sqlite database default (often DELETE), can be used to enable WAL mode. https://www.sqlite.org/pragma.html#pragma_journal_mode ;; diff --git a/docker/README.md b/docker/README.md index a6d7c9a84..5f65c8c97 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,7 +1,7 @@ -# Gitea - Docker +# Forgejo - Docker -Dockerfile is found in root of repository. +The Dockerfile can be found in the root of repository. [Dockerfile](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/Dockerfile) & [Dockerfile.rootless](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/Dockerfile.rootless). -Docker image can be found on [docker hub](https://hub.docker.com/r/gitea/gitea) +The Docker image can be found on [Coddeberg](https://codeberg.org/forgejo/-/packages/container/forgejo/). -Documentation on using docker image can be found on [Gitea Docs site](https://docs.gitea.com/installation/install-with-docker-rootless) +Documentation on how you can use the docker image can be found on the [Forgejo documentation website](https://forgejo.org/docs/latest/admin/installation/#installation-with-docker). diff --git a/docker/root/etc/s6/gitea/setup b/docker/root/etc/s6/gitea/setup index b801ef4e0..f8d76273c 100755 --- a/docker/root/etc/s6/gitea/setup +++ b/docker/root/etc/s6/gitea/setup @@ -32,7 +32,7 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then fi # Substitute the environment variables in the template - APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \ + APP_NAME=${APP_NAME:-"Forgejo: Beyond coding. We forge."} \ RUN_MODE=${RUN_MODE:-"prod"} \ DOMAIN=${DOMAIN:-"localhost"} \ SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \ diff --git a/docker/rootless/usr/local/bin/docker-setup.sh b/docker/rootless/usr/local/bin/docker-setup.sh index feab02a37..b48068586 100755 --- a/docker/rootless/usr/local/bin/docker-setup.sh +++ b/docker/rootless/usr/local/bin/docker-setup.sh @@ -26,7 +26,7 @@ if [ ! -f ${GITEA_APP_INI} ]; then fi # Substitute the environment variables in the template - APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \ + APP_NAME=${APP_NAME:-"Forgejo: Beyond coding. We forge."} \ RUN_MODE=${RUN_MODE:-"prod"} \ RUN_USER=${USER:-"git"} \ SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \ diff --git a/main.go b/main.go index 700b75d74..56f97caf2 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,16 @@ func init() { setting.AppStartTime = time.Now().UTC() } +func forgejoEnv() { + for _, k := range []string{"CUSTOM", "WORK_DIR"} { + if v, ok := os.LookupEnv("FORGEJO_" + k); ok { + os.Setenv("GITEA_"+k, v) + } + } +} + func main() { + forgejoEnv() cli.OsExiter = func(code int) { log.GetManager().Close() os.Exit(code) diff --git a/models/fixtures/repo_unit.yml b/models/fixtures/repo_unit.yml index 6afef2a43..b359f547b 100644 --- a/models/fixtures/repo_unit.yml +++ b/models/fixtures/repo_unit.yml @@ -681,3 +681,23 @@ repo_id: 49 type: 2 created_unix: 946684810 + +- + id: 98 + repo_id: 1 + type: 8 + created_unix: 946684810 + +- + id: 99 + repo_id: 1 + type: 9 + config: "{}" + created_unix: 946684810 + +- + id: 100 + repo_id: 1 + type: 10 + config: "{}" + created_unix: 946684810 diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index de1569e0f..c6d5ea328 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -584,7 +584,7 @@ func EnsureUpToDate(x *xorm.Engine) error { expected := ExpectedVersion() if currentDB != expected { - return fmt.Errorf(`Current database version %d is not equal to the expected version %d. Please run "gitea [--config /path/to/app.ini] migrate" to update the database version`, currentDB, expected) + return fmt.Errorf(`Current database version %d is not equal to the expected version %d. Please run "forgejo [--config /path/to/app.ini] migrate" to update the database version`, currentDB, expected) } return nil diff --git a/models/user/user.go b/models/user/user.go index 39e758a04..851db0731 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -564,6 +564,7 @@ var ( "user", "v2", "gitea-actions", + "forgejo-actions", } // DON'T ADD ANY NEW STUFF, WE SOLVE THIS WITH `/user/{obj}` PATHS! diff --git a/models/user/user_system.go b/models/user/user_system.go index ecf235abc..2a3f96475 100644 --- a/models/user/user_system.go +++ b/models/user/user_system.go @@ -39,9 +39,9 @@ func NewReplaceUser(name string) *User { const ( ActionsUserID = -2 - ActionsUserName = "gitea-actions" - ActionsFullName = "Gitea Actions" - ActionsEmail = "teabot@gitea.io" + ActionsUserName = "forgejo-actions" + ActionsFullName = "Forgejo Actions" + ActionsEmail = "noreply@forgejo.org" ) // NewActionsUser creates and returns a fake user for running the actions. diff --git a/modules/context/api.go b/modules/context/api.go index 044ec51b5..65ceb05c2 100644 --- a/modules/context/api.go +++ b/modules/context/api.go @@ -205,13 +205,20 @@ func (ctx *APIContext) SetLinkHeader(total, pageSize int) { } } +func getOtpHeader(header http.Header) string { + otpHeader := header.Get("X-Gitea-OTP") + if forgejoHeader := header.Get("X-Forgejo-OTP"); forgejoHeader != "" { + otpHeader = forgejoHeader + } + return otpHeader +} + // CheckForOTP validates OTP func (ctx *APIContext) CheckForOTP() { if skip, ok := ctx.Data["SkipLocalTwoFA"]; ok && skip.(bool) { return // Skip 2FA } - otpHeader := ctx.Req.Header.Get("X-Gitea-OTP") twofa, err := auth.GetTwoFactorByUID(ctx, ctx.Doer.ID) if err != nil { if auth.IsErrTwoFactorNotEnrolled(err) { @@ -220,7 +227,7 @@ func (ctx *APIContext) CheckForOTP() { ctx.Error(http.StatusInternalServerError, "GetTwoFactorByUID", err) return } - ok, err := twofa.ValidateTOTP(otpHeader) + ok, err := twofa.ValidateTOTP(getOtpHeader(ctx.Req.Header)) if err != nil { ctx.Error(http.StatusInternalServerError, "ValidateTOTP", err) return diff --git a/modules/context/api_forgejo_test.go b/modules/context/api_forgejo_test.go new file mode 100644 index 000000000..b85de5590 --- /dev/null +++ b/modules/context/api_forgejo_test.go @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT + +package context + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetOtpHeader(t *testing.T) { + header := http.Header{} + assert.EqualValues(t, "", getOtpHeader(header)) + // Gitea + giteaOtp := "123456" + header.Set("X-Gitea-OTP", giteaOtp) + assert.EqualValues(t, giteaOtp, getOtpHeader(header)) + // Forgejo has precedence + forgejoOtp := "abcdef" + header.Set("X-Forgejo-OTP", forgejoOtp) + assert.EqualValues(t, forgejoOtp, getOtpHeader(header)) +} diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index b57b32183..10f626b3f 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -30,6 +30,7 @@ func SetCacheControlInHeader(h http.Header, maxAge time.Duration, additionalDire // to remind users they are using non-prod setting. h.Set("X-Gitea-Debug", "RUN_MODE="+setting.RunMode) + h.Set("X-Forgejo-Debug", "RUN_MODE="+setting.RunMode) } h.Set("Cache-Control", strings.Join(append(directives, additionalDirectives...), ", ")) diff --git a/modules/httpcache/httpcache_test.go b/modules/httpcache/httpcache_test.go index d81f06097..65a8a9b8f 100644 --- a/modules/httpcache/httpcache_test.go +++ b/modules/httpcache/httpcache_test.go @@ -18,6 +18,9 @@ func countFormalHeaders(h http.Header) (c int) { if strings.HasPrefix(k, "X-Gitea-") { continue } + if strings.HasPrefix(k, "X-Forgejo-") { + continue + } c++ } return c diff --git a/modules/setting/config_env.go b/modules/setting/config_env.go index 242f40914..522e36030 100644 --- a/modules/setting/config_env.go +++ b/modules/setting/config_env.go @@ -14,7 +14,7 @@ import ( ) const ( - EnvConfigKeyPrefixGitea = "GITEA__" + EnvConfigKeyPrefixGitea = "^(FORGEJO|GITEA)__" EnvConfigKeySuffixFile = "__FILE" ) @@ -97,19 +97,21 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) { // decodeEnvironmentKey decode the environment key to section and key // The environment key is in the form of GITEA__SECTION__KEY or GITEA__SECTION__KEY__FILE -func decodeEnvironmentKey(prefixGitea, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) { - if !strings.HasPrefix(envKey, prefixGitea) { - return false, "", "", false - } +func decodeEnvironmentKey(prefixRegexp *regexp.Regexp, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) { if strings.HasSuffix(envKey, suffixFile) { useFileValue = true envKey = envKey[:len(envKey)-len(suffixFile)] } - ok, section, key = decodeEnvSectionKey(envKey[len(prefixGitea):]) + loc := prefixRegexp.FindStringIndex(envKey) + if loc == nil { + return false, "", "", false + } + ok, section, key = decodeEnvSectionKey(envKey[loc[1]:]) return ok, section, key, useFileValue } func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) { + prefixRegexp := regexp.MustCompile(EnvConfigKeyPrefixGitea) for _, kv := range envs { idx := strings.IndexByte(kv, '=') if idx < 0 { @@ -119,7 +121,7 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) { // parse the environment variable to config section name and key name envKey := kv[:idx] envValue := kv[idx+1:] - ok, sectionName, keyName, useFileValue := decodeEnvironmentKey(EnvConfigKeyPrefixGitea, EnvConfigKeySuffixFile, envKey) + ok, sectionName, keyName, useFileValue := decodeEnvironmentKey(prefixRegexp, EnvConfigKeySuffixFile, envKey) if !ok { continue } diff --git a/modules/setting/config_env_test.go b/modules/setting/config_env_test.go index 7d07c479a..572486aec 100644 --- a/modules/setting/config_env_test.go +++ b/modules/setting/config_env_test.go @@ -5,6 +5,7 @@ package setting import ( "os" + "regexp" "testing" "github.com/stretchr/testify/assert" @@ -33,7 +34,7 @@ func TestDecodeEnvSectionKey(t *testing.T) { } func TestDecodeEnvironmentKey(t *testing.T) { - prefix := "GITEA__" + prefix := regexp.MustCompile(EnvConfigKeyPrefixGitea) suffix := "__FILE" ok, section, key, file := decodeEnvironmentKey(prefix, suffix, "SEC__KEY") @@ -60,6 +61,12 @@ func TestDecodeEnvironmentKey(t *testing.T) { assert.Equal(t, "KEY", key) assert.False(t, file) + ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "FORGEJO__SEC__KEY") + assert.True(t, ok) + assert.Equal(t, "sec", section) + assert.Equal(t, "KEY", key) + assert.False(t, file) + // with "__FILE" suffix, it doesn't support to write "[sec].FILE" to config (no such key FILE is used in Gitea) // but it could be fixed in the future by adding a new suffix like "__VALUE" (no such key VALUE is used in Gitea either) ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__FILE") diff --git a/modules/setting/database.go b/modules/setting/database.go index 6ece1e7c0..4ff20fbdb 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -71,7 +71,7 @@ func loadDBSetting(rootCfg ConfigProvider) { Database.SSLMode = sec.Key("SSL_MODE").MustString("disable") Database.MysqlCharset = sec.Key("MYSQL_CHARSET").MustString("utf8mb4") // do not document it, end users won't need it. - Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db")) + Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "forgejo.db")) Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500) Database.SQLiteJournalMode = sec.Key("SQLITE_JOURNAL_MODE").MustString("") diff --git a/modules/setting/path.go b/modules/setting/path.go index 0fdc305aa..85d0e0630 100644 --- a/modules/setting/path.go +++ b/modules/setting/path.go @@ -129,6 +129,14 @@ func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkP } } + envWorkPath = getEnvFn("FORGEJO_WORK_DIR") + if envWorkPath != "" { + tmpWorkPath.Set(envWorkPath) + if !filepath.IsAbs(tmpWorkPath.Value) { + log.Fatal("FORGEJO_WORK_DIR (work path) must be absolute path") + } + } + envCustomPath := getEnvFn("GITEA_CUSTOM") if envCustomPath != "" { tmpCustomPath.Set(envCustomPath) @@ -136,6 +144,14 @@ func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkP log.Fatal("GITEA_CUSTOM (custom path) must be absolute path") } } + + envCustomPath = getEnvFn("FORGEJO_CUSTOM") + if envCustomPath != "" { + tmpCustomPath.Set(envCustomPath) + if !filepath.IsAbs(tmpCustomPath.Value) { + log.Fatal("FORGEJO_CUSTOM (custom path) must be absolute path") + } + } } readFromArgs := func() { @@ -180,7 +196,7 @@ func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkP log.Fatal("WORK_PATH in %q must be absolute path", configWorkPath) } configWorkPath = filepath.Clean(configWorkPath) - if tmpWorkPath.Value != "" && (getEnvFn("GITEA_WORK_DIR") != "" || args.WorkPath != "") { + if tmpWorkPath.Value != "" && (getEnvFn("GITEA_WORK_DIR") != "" || getEnvFn("FORGEJO_WORK_DIR") != "" || args.WorkPath != "") { fi1, err1 := os.Stat(tmpWorkPath.Value) fi2, err2 := os.Stat(configWorkPath) if err1 != nil || err2 != nil || !os.SameFile(fi1, fi2) { diff --git a/modules/setting/path_test.go b/modules/setting/path_test.go index fc6a2116d..4508bae50 100644 --- a/modules/setting/path_test.go +++ b/modules/setting/path_test.go @@ -60,6 +60,22 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) { assert.Equal(t, fp(dirXxx, "custom/conf/app.ini"), CustomConf) }) + t.Run("WorkDir(env)", func(t *testing.T) { + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{}) + assert.Equal(t, dirBar, AppWorkPath) + assert.Equal(t, fp(dirBar, "custom"), CustomPath) + assert.Equal(t, fp(dirBar, "custom/conf/app.ini"), CustomConf) + }) + + t.Run("WorkDir(env,arg)", func(t *testing.T) { + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{WorkPath: dirXxx}) + assert.Equal(t, dirXxx, AppWorkPath) + assert.Equal(t, fp(dirXxx, "custom"), CustomPath) + assert.Equal(t, fp(dirXxx, "custom/conf/app.ini"), CustomConf) + }) + t.Run("CustomPath(env)", func(t *testing.T) { testInit(dirFoo, "", "") InitWorkPathAndCommonConfig(envVars{"GITEA_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{}) @@ -76,6 +92,22 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) { assert.Equal(t, fp(dirFoo, "custom2/conf/app.ini"), CustomConf) }) + t.Run("CustomPath(env)", func(t *testing.T) { + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{}) + assert.Equal(t, dirFoo, AppWorkPath) + assert.Equal(t, fp(dirBar, "custom1"), CustomPath) + assert.Equal(t, fp(dirBar, "custom1/conf/app.ini"), CustomConf) + }) + + t.Run("CustomPath(env,arg)", func(t *testing.T) { + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{CustomPath: "custom2"}) + assert.Equal(t, dirFoo, AppWorkPath) + assert.Equal(t, fp(dirFoo, "custom2"), CustomPath) + assert.Equal(t, fp(dirFoo, "custom2/conf/app.ini"), CustomConf) + }) + t.Run("CustomConf", func(t *testing.T) { testInit(dirFoo, "", "") InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{CustomConf: "app1.ini"}) @@ -115,6 +147,32 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) { assert.True(t, AppWorkPathMismatch) }) + t.Run("CustomConfOverrideWorkPath", func(t *testing.T) { + iniWorkPath := fp(tmpDir, "app-workpath.ini") + _ = os.WriteFile(iniWorkPath, []byte("WORK_PATH="+dirXxx), 0o644) + + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{CustomConf: iniWorkPath}) + assert.Equal(t, dirXxx, AppWorkPath) + assert.Equal(t, fp(dirXxx, "custom"), CustomPath) + assert.Equal(t, iniWorkPath, CustomConf) + assert.False(t, AppWorkPathMismatch) + + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{CustomConf: iniWorkPath}) + assert.Equal(t, dirXxx, AppWorkPath) + assert.Equal(t, fp(dirXxx, "custom"), CustomPath) + assert.Equal(t, iniWorkPath, CustomConf) + assert.True(t, AppWorkPathMismatch) + + testInit(dirFoo, "", "") + InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{WorkPath: dirBar, CustomConf: iniWorkPath}) + assert.Equal(t, dirXxx, AppWorkPath) + assert.Equal(t, fp(dirXxx, "custom"), CustomPath) + assert.Equal(t, iniWorkPath, CustomConf) + assert.True(t, AppWorkPathMismatch) + }) + t.Run("Builtin", func(t *testing.T) { testInit(dirFoo, dirBar, dirXxx) InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{}) @@ -148,4 +206,38 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) { assert.Equal(t, fp(dirXxx, "custom1"), CustomPath) assert.Equal(t, iniWorkPath, CustomConf) }) + + t.Run("Builtin", func(t *testing.T) { + testInit(dirFoo, dirBar, dirXxx) + InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{}) + assert.Equal(t, dirFoo, AppWorkPath) + assert.Equal(t, dirBar, CustomPath) + assert.Equal(t, dirXxx, CustomConf) + + testInit(dirFoo, "custom1", "cfg.ini") + InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{}) + assert.Equal(t, dirFoo, AppWorkPath) + assert.Equal(t, fp(dirFoo, "custom1"), CustomPath) + assert.Equal(t, fp(dirFoo, "custom1/cfg.ini"), CustomConf) + + testInit(dirFoo, "custom1", "cfg.ini") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_WORK_DIR": dirYyy}.Getenv, ArgWorkPathAndCustomConf{}) + assert.Equal(t, dirYyy, AppWorkPath) + assert.Equal(t, fp(dirYyy, "custom1"), CustomPath) + assert.Equal(t, fp(dirYyy, "custom1/cfg.ini"), CustomConf) + + testInit(dirFoo, "custom1", "cfg.ini") + InitWorkPathAndCommonConfig(envVars{"FORGEJO_CUSTOM": dirYyy}.Getenv, ArgWorkPathAndCustomConf{}) + assert.Equal(t, dirFoo, AppWorkPath) + assert.Equal(t, dirYyy, CustomPath) + assert.Equal(t, fp(dirYyy, "cfg.ini"), CustomConf) + + iniWorkPath := fp(tmpDir, "app-workpath.ini") + _ = os.WriteFile(iniWorkPath, []byte("WORK_PATH="+dirXxx), 0o644) + testInit(dirFoo, "custom1", "cfg.ini") + InitWorkPathAndCommonConfig(envVars{}.Getenv, ArgWorkPathAndCustomConf{CustomConf: iniWorkPath}) + assert.Equal(t, dirXxx, AppWorkPath) + assert.Equal(t, fp(dirXxx, "custom1"), CustomPath) + assert.Equal(t, iniWorkPath, CustomConf) + }) } diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 42ffb9913..2d15a5893 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -276,7 +276,7 @@ func loadRepositoryFrom(rootCfg ConfigProvider) { Repository.GoGetCloneURLProtocol = sec.Key("GO_GET_CLONE_URL_PROTOCOL").MustString("https") Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1) Repository.DefaultBranch = sec.Key("DEFAULT_BRANCH").MustString(Repository.DefaultBranch) - RepoRootPath = sec.Key("ROOT").MustString(path.Join(AppDataPath, "gitea-repositories")) + RepoRootPath = sec.Key("ROOT").MustString(path.Join(AppDataPath, "forgejo-repositories")) if !filepath.IsAbs(RepoRootPath) { RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath) } else { diff --git a/modules/setting/server.go b/modules/setting/server.go index 08eb82fb3..964a8162f 100644 --- a/modules/setting/server.go +++ b/modules/setting/server.go @@ -168,7 +168,7 @@ func MakeAbsoluteAssetURL(appURL, staticURLPrefix string) string { func loadServerFrom(rootCfg ConfigProvider) { sec := rootCfg.Section("server") - AppName = rootCfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea") + AppName = rootCfg.Section("").Key("APP_NAME").MustString("Forgejo: Beyond coding. We Forge.") Domain = sec.Key("DOMAIN").MustString("localhost") HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0") diff --git a/modules/setting/ui.go b/modules/setting/ui.go index 41438db40..c8ad75856 100644 --- a/modules/setting/ui.go +++ b/modules/setting/ui.go @@ -76,11 +76,11 @@ var UI = struct { CodeCommentLines: 4, ReactionMaxUserNum: 10, MaxDisplayFileSize: 8388608, - DefaultTheme: `auto`, - Themes: []string{`auto`, `gitea`, `arc-green`}, + DefaultTheme: `forgejo-auto`, + Themes: []string{`forgejo-auto`, `forgejo-light`, `forgejo-dark`, `auto`, `gitea`, `arc-green`}, Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`}, - CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`}, - CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"}, + CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`, `forgejo`}, + CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:", "forgejo": ":forgejo:"}, Notification: struct { MinTimeout time.Duration TimeoutStep time.Duration @@ -123,9 +123,9 @@ var UI = struct { Description string Keywords string }{ - Author: "Gitea - Git with a cup of tea", - Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go", - Keywords: "go,git,self-hosted,gitea", + Author: "Forgejo – Beyond coding. We forge.", + Description: "Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job.", + Keywords: "git,forge,forgejo", }, } diff --git a/modules/setting/webhook.go b/modules/setting/webhook.go index c01261dbb..b56c55c43 100644 --- a/modules/setting/webhook.go +++ b/modules/setting/webhook.go @@ -35,7 +35,7 @@ func loadWebhookFrom(rootCfg ConfigProvider) { Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool() Webhook.AllowedHostList = sec.Key("ALLOWED_HOST_LIST").MustString("") - Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork", "packagist"} + Webhook.Types = []string{"forgejo", "gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork", "packagist"} Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10) Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("") if Webhook.ProxyURL != "" { diff --git a/modules/structs/hook.go b/modules/structs/hook.go index 0babe8441..9afcebdc5 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -41,7 +41,7 @@ type CreateHookOptionConfig map[string]string // CreateHookOption options when create a hook type CreateHookOption struct { // required: true - // enum: dingtalk,discord,gitea,gogs,msteams,slack,telegram,feishu,wechatwork,packagist + // enum: forgejo,dingtalk,discord,gitea,gogs,msteams,slack,telegram,feishu,wechatwork,packagist Type string `json:"type" binding:"Required"` // required: true Config CreateHookOptionConfig `json:"config" binding:"Required"` diff --git a/modules/webhook/type.go b/modules/webhook/type.go index 7042d391b..7f427f2ea 100644 --- a/modules/webhook/type.go +++ b/modules/webhook/type.go @@ -72,6 +72,7 @@ type HookType = string // Types of webhooks const ( + FORGEJO HookType = "forgejo" GITEA HookType = "gitea" GOGS HookType = "gogs" SLACK HookType = "slack" diff --git a/options/locales/gitea_en-US.ini b/options/locales/gitea_en-US.ini index bbba16f2e..1696c1ad5 100644 --- a/options/locales/gitea_en-US.ini +++ b/options/locales/gitea_en-US.ini @@ -751,8 +751,8 @@ add_key = Add Key ssh_desc = These public SSH keys are associated with your account. The corresponding private keys allow full access to your repositories. principal_desc = These SSH certificate principals are associated with your account and allow full access to your repositories. gpg_desc = These public GPG keys are associated with your account. Keep your private keys safe as they allow commits to be verified. -ssh_helper = Need help? Have a look at GitHub's guide to create your own SSH keys or solve common problems you may encounter using SSH. -gpg_helper = Need help? Have a look at GitHub's guide about GPG. +ssh_helper = Need help? Have a look at the guide to create your own SSH keys or solve common problems you may encounter using SSH. +gpg_helper = Need help? Have a look at the guide about GPG. add_new_key = Add SSH Key add_new_gpg_key = Add GPG Key key_content_ssh_placeholder = Begins with 'ssh-ed25519', 'ssh-rsa', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'sk-ecdsa-sha2-nistp256@openssh.com', or 'sk-ssh-ed25519@openssh.com' diff --git a/public/.well-known/security.txt b/public/.well-known/security.txt index 2cae3cbea..f301a0054 100644 --- a/public/.well-known/security.txt +++ b/public/.well-known/security.txt @@ -1,6 +1,8 @@ -# This site is running a Gitea instance. -# Gitea related security problems could be reported to Gitea community. -# Site related security problems should be reported to this site's admin. -Contact: https://github.com/go-gitea/gitea/blob/main/SECURITY.md -Policy: https://github.com/go-gitea/gitea/blob/main/SECURITY.md +# This site is running a Forgejo instance. +# Forgejo-related security problems should be reported to the Forgejo security team. +# Site-related security problems should be reported to this site's admin. +Policy: https://codeberg.org/forgejo/forgejo/src/branch/forgejo/CONTRIBUTING.md +Contact: mailto:security@forgejo.org +Encryption: https://keys.openpgp.org/vks/v1/by-fingerprint/1B638BDF10969D627926B8D9F585D0F99E1FB56F Preferred-Languages: en +Expires: 2025-06-25T00:00:00Z diff --git a/public/assets/img/apple-touch-icon.png b/public/assets/img/apple-touch-icon.png index 0c803d35d..1f6c1544f 100644 Binary files a/public/assets/img/apple-touch-icon.png and b/public/assets/img/apple-touch-icon.png differ diff --git a/public/assets/img/avatar_default.png b/public/assets/img/avatar_default.png index 129967112..f335e51da 100644 Binary files a/public/assets/img/avatar_default.png and b/public/assets/img/avatar_default.png differ diff --git a/public/assets/img/emoji/forgejo.png b/public/assets/img/emoji/forgejo.png new file mode 100644 index 000000000..f335e51da Binary files /dev/null and b/public/assets/img/emoji/forgejo.png differ diff --git a/public/assets/img/failed.png b/public/assets/img/failed.png deleted file mode 100644 index b37545f90..000000000 Binary files a/public/assets/img/failed.png and /dev/null differ diff --git a/public/assets/img/favicon.png b/public/assets/img/favicon.png index dcd4edb1a..eda0347ef 100644 Binary files a/public/assets/img/favicon.png and b/public/assets/img/favicon.png differ diff --git a/public/assets/img/favicon.svg b/public/assets/img/favicon.svg index afeeacb77..804b05e28 100644 --- a/public/assets/img/favicon.svg +++ b/public/assets/img/favicon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/img/forgejo-loading.svg b/public/assets/img/forgejo-loading.svg new file mode 100644 index 000000000..919552ebb --- /dev/null +++ b/public/assets/img/forgejo-loading.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/public/assets/img/forgejo.svg b/public/assets/img/forgejo.svg new file mode 100644 index 000000000..804b05e28 --- /dev/null +++ b/public/assets/img/forgejo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/img/gitea-original.svg b/public/assets/img/gitea-original.svg new file mode 100644 index 000000000..dca9b4f4d --- /dev/null +++ b/public/assets/img/gitea-original.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/img/gitea.svg b/public/assets/img/gitea.svg index dca9b4f4d..804b05e28 100644 --- a/public/assets/img/gitea.svg +++ b/public/assets/img/gitea.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/img/loading.png b/public/assets/img/loading.png deleted file mode 100644 index c5ba3d9cd..000000000 Binary files a/public/assets/img/loading.png and /dev/null differ diff --git a/public/assets/img/logo.png b/public/assets/img/logo.png index c7971f918..1b2d9b402 100644 Binary files a/public/assets/img/logo.png and b/public/assets/img/logo.png differ diff --git a/public/assets/img/logo.svg b/public/assets/img/logo.svg index afeeacb77..804b05e28 100644 --- a/public/assets/img/logo.svg +++ b/public/assets/img/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b4f1a06a3..2e09e8c93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "gitea" +name = "forgejo" version = "0.0.0" description = "" authors = [] diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8052ea1f4..542c8c057 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -56,7 +56,7 @@ // description: Sudo API request as the user provided as the key. Admin privileges are required. // TOTPHeader: // type: apiKey -// name: X-GITEA-OTP +// name: X-FORGEJO-OTP // in: header // description: Must be used in combination with BasicAuth if two-factor authentication is enabled. // @@ -835,7 +835,7 @@ func Routes() *web.Route { // setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option AllowedMethods: setting.CORSConfig.Methods, AllowCredentials: setting.CORSConfig.AllowCredentials, - AllowedHeaders: append([]string{"Authorization", "X-Gitea-OTP"}, setting.CORSConfig.Headers...), + AllowedHeaders: append([]string{"Authorization", "X-Gitea-OTP", "X-Forgejo-OTP"}, setting.CORSConfig.Headers...), MaxAge: int(setting.CORSConfig.MaxAge.Seconds()), })) } diff --git a/routers/api/v1/misc/nodeinfo.go b/routers/api/v1/misc/nodeinfo.go index f0d8d80dd..d25b1fbb9 100644 --- a/routers/api/v1/misc/nodeinfo.go +++ b/routers/api/v1/misc/nodeinfo.go @@ -65,10 +65,10 @@ func NodeInfo(ctx *context.APIContext) { nodeInfo := &structs.NodeInfo{ Version: "2.1", Software: structs.NodeInfoSoftware{ - Name: "gitea", + Name: "forgejo", Version: setting.AppVer, - Repository: "https://github.com/go-gitea/gitea.git", - Homepage: "https://gitea.io/", + Repository: "https://codeberg.org/forgejo/forgejo.git", + Homepage: "https://forgejo.org/", }, Protocols: []string{"activitypub"}, Services: structs.NodeInfoServices{ diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index ea311c320..9ee10f6ce 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -33,7 +33,10 @@ import ( files_service "code.gitea.io/gitea/services/repository/files" ) -const giteaObjectTypeHeader = "X-Gitea-Object-Type" +const ( + giteaObjectTypeHeader = "X-Gitea-Object-Type" + forgejoObjectTypeHeader = "X-Forgejo-Object-Type" +) // GetRawFile get a file by path on a repository func GetRawFile(ctx *context.APIContext) { @@ -80,6 +83,7 @@ func GetRawFile(ctx *context.APIContext) { } ctx.RespHeader().Set(giteaObjectTypeHeader, string(files_service.GetObjectTypeFromTreeEntry(entry))) + ctx.RespHeader().Set(forgejoObjectTypeHeader, string(files_service.GetObjectTypeFromTreeEntry(entry))) if err := common.ServeBlob(ctx.Base, ctx.Repo.TreePath, blob, lastModified); err != nil { ctx.Error(http.StatusInternalServerError, "ServeBlob", err) @@ -129,6 +133,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) { } ctx.RespHeader().Set(giteaObjectTypeHeader, string(files_service.GetObjectTypeFromTreeEntry(entry))) + ctx.RespHeader().Set(forgejoObjectTypeHeader, string(files_service.GetObjectTypeFromTreeEntry(entry))) // LFS Pointer files are at most 1024 bytes - so any blob greater than 1024 bytes cannot be an LFS file if blob.Size() > 1024 { diff --git a/routers/common/db.go b/routers/common/db.go index 547f727ce..666ccd867 100644 --- a/routers/common/db.go +++ b/routers/common/db.go @@ -54,7 +54,7 @@ func migrateWithSetting(x *xorm.Engine) error { return migrations.Migrate(x) } else if expected := migrations.ExpectedVersion(); current != expected { log.Fatal(`"database.AUTO_MIGRATION" is disabled, but current database version %d is not equal to the expected version %d.`+ - `You can set "database.AUTO_MIGRATION" to true or migrate manually by running "gitea [--config /path/to/app.ini] migrate"`, current, expected) + `You can set "database.AUTO_MIGRATION" to true or migrate manually by running "forgejo [--config /path/to/app.ini] migrate"`, current, expected) } return nil } diff --git a/routers/install/install.go b/routers/install/install.go index cb7818bd3..648425df3 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -181,7 +181,7 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool { if err = db.InitEngine(ctx); err != nil { if strings.Contains(err.Error(), `Unknown database type: sqlite3`) { ctx.Data["Err_DbType"] = true - ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://docs.gitea.com/installation/install-from-binary"), tplInstall, form) + ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://forgejo.org/download#installation-from-binary"), tplInstall, form) } else { ctx.Data["Err_DbSetting"] = true ctx.RenderWithErr(ctx.Tr("install.invalid_db_setting", err), tplInstall, form) diff --git a/routers/web/healthcheck/check.go b/routers/web/healthcheck/check.go index ecb73a928..e89498a8a 100644 --- a/routers/web/healthcheck/check.go +++ b/routers/web/healthcheck/check.go @@ -105,7 +105,7 @@ func checkDatabase(ctx context.Context, checks checks) status { if !setting.EnableSQLite3 { st.Status = fail st.Time = getCheckTime() - log.Error("SQLite3 health check failed with error: %v", "this Gitea binary is built without SQLite3 enabled") + log.Error("SQLite3 health check failed with error: %v", "this Forgejo binary is built without SQLite3 enabled") } else { if _, err := os.Stat(setting.Database.Path); err != nil { st.Status = fail diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index 33ea2c206..718e2a0bc 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -44,7 +44,7 @@ func Webhooks(ctx *context.Context) { ctx.Data["PageIsSettingsHooks"] = true ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks" ctx.Data["BaseLinkNew"] = ctx.Repo.RepoLink + "/settings/hooks" - ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.com/usage/webhooks") + ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://forgejo.org/docs/latest/user/webhooks/") ws, err := webhook.ListWebhooksByOpts(ctx, &webhook.ListWebhookOptions{RepoID: ctx.Repo.Repository.ID}) if err != nil { @@ -309,6 +309,34 @@ func editWebhook(ctx *context.Context, params webhookParams) { ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID)) } +// ForgejoHooksNewPost response for creating Forgejo webhook +func ForgejoHooksNewPost(ctx *context.Context) { + createWebhook(ctx, forgejoHookParams(ctx)) +} + +// ForgejoHooksEditPost response for editing Forgejo webhook +func ForgejoHooksEditPost(ctx *context.Context) { + editWebhook(ctx, forgejoHookParams(ctx)) +} + +func forgejoHookParams(ctx *context.Context) webhookParams { + form := web.GetForm(ctx).(*forms.NewWebhookForm) + + contentType := webhook.ContentTypeJSON + if webhook.HookContentType(form.ContentType) == webhook.ContentTypeForm { + contentType = webhook.ContentTypeForm + } + + return webhookParams{ + Type: webhook_module.FORGEJO, + URL: form.PayloadURL, + ContentType: contentType, + Secret: form.Secret, + HTTPMethod: form.HTTPMethod, + WebhookForm: form.WebhookForm, + } +} + // GiteaHooksNewPost response for creating Gitea webhook func GiteaHooksNewPost(ctx *context.Context) { createWebhook(ctx, giteaHookParams(ctx)) diff --git a/routers/web/web.go b/routers/web/web.go index 6419094f3..285a5e3d4 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -385,6 +385,7 @@ func registerRoutes(m *web.Route) { addWebhookAddRoutes := func() { m.Get("/{type}/new", repo_setting.WebhooksNew) + m.Post("/forgejo/new", web.Bind(forms.NewWebhookForm{}), repo_setting.ForgejoHooksNewPost) m.Post("/gitea/new", web.Bind(forms.NewWebhookForm{}), repo_setting.GiteaHooksNewPost) m.Post("/gogs/new", web.Bind(forms.NewGogshookForm{}), repo_setting.GogsHooksNewPost) m.Post("/slack/new", web.Bind(forms.NewSlackHookForm{}), repo_setting.SlackHooksNewPost) @@ -399,6 +400,7 @@ func registerRoutes(m *web.Route) { } addWebhookEditRoutes := func() { + m.Post("/forgejo/{id}", web.Bind(forms.NewWebhookForm{}), repo_setting.ForgejoHooksEditPost) m.Post("/gitea/{id}", web.Bind(forms.NewWebhookForm{}), repo_setting.GiteaHooksEditPost) m.Post("/gogs/{id}", web.Bind(forms.NewGogshookForm{}), repo_setting.GogsHooksEditPost) m.Post("/slack/{id}", web.Bind(forms.NewSlackHookForm{}), repo_setting.SlackHooksEditPost) diff --git a/services/mailer/mail.go b/services/mailer/mail.go index 83f58bad0..2ee0b1f4a 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -60,7 +60,7 @@ func SendTestMail(email string) error { // No mail service configured return nil } - return gomail.Send(Sender, NewMessage(email, "Gitea Test Email!", "Gitea Test Email!").ToMessage()) + return gomail.Send(Sender, NewMessage(email, "Forgejo Test Email!", "Forgejo Test Email!").ToMessage()) } // sendUserMail sends a mail to the user @@ -399,6 +399,16 @@ func generateAdditionalHeaders(ctx *mailCommentContext, reason string, recipient "X-Gitea-Issue-ID": strconv.FormatInt(ctx.Issue.Index, 10), "X-Gitea-Issue-Link": ctx.Issue.HTMLURL(), + "X-Forgejo-Reason": reason, + "X-Forgejo-Sender": ctx.Doer.DisplayName(), + "X-Forgejo-Recipient": recipient.DisplayName(), + "X-Forgejo-Recipient-Address": recipient.Email, + "X-Forgejo-Repository": repo.Name, + "X-Forgejo-Repository-Path": repo.FullName(), + "X-Forgejo-Repository-Link": repo.HTMLURL(), + "X-Forgejo-Issue-ID": strconv.FormatInt(ctx.Issue.Index, 10), + "X-Forgejo-Issue-Link": ctx.Issue.HTMLURL(), + "X-GitHub-Reason": reason, "X-GitHub-Sender": ctx.Doer.DisplayName(), "X-GitHub-Recipient": recipient.DisplayName(), diff --git a/services/webhook/deliver.go b/services/webhook/deliver.go index 8d6868665..dbeb3c3bf 100644 --- a/services/webhook/deliver.go +++ b/services/webhook/deliver.go @@ -123,6 +123,10 @@ func Deliver(ctx context.Context, t *webhook_model.HookTask) error { event := t.EventType.Event() eventType := string(t.EventType) + req.Header.Add("X-Forgejo-Delivery", t.UUID) + req.Header.Add("X-Forgejo-Event", event) + req.Header.Add("X-Forgejo-Event-Type", eventType) + req.Header.Add("X-Forgejo-Signature", signatureSHA256) req.Header.Add("X-Gitea-Delivery", t.UUID) req.Header.Add("X-Gitea-Event", event) req.Header.Add("X-Gitea-Event-Type", eventType) diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go index 9d5dab85f..f15c85333 100644 --- a/services/webhook/webhook.go +++ b/services/webhook/webhook.go @@ -70,7 +70,7 @@ var webhooks = map[webhook_module.HookType]*webhook{ // IsValidHookTaskType returns true if a webhook registered func IsValidHookTaskType(name string) bool { - if name == webhook_module.GITEA || name == webhook_module.GOGS { + if name == webhook_module.FORGEJO || name == webhook_module.GITEA || name == webhook_module.GOGS { return true } _, ok := webhooks[name] @@ -177,7 +177,7 @@ func PrepareWebhook(ctx context.Context, w *webhook_model.Webhook, event webhook // Avoid sending "0 new commits" to non-integration relevant webhooks (e.g. slack, discord, etc.). // Integration webhooks (e.g. drone) still receive the required data. if pushEvent, ok := p.(*api.PushPayload); ok && - w.Type != webhook_module.GITEA && w.Type != webhook_module.GOGS && + w.Type != webhook_module.FORGEJO && w.Type != webhook_module.GITEA && w.Type != webhook_module.GOGS && len(pushEvent.Commits) == 0 { return nil } diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 25abefae0..65e82ba26 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -132,7 +132,7 @@
- +
@@ -359,7 +359,7 @@
- +
diff --git a/templates/admin/auth/source/ldap.tmpl b/templates/admin/auth/source/ldap.tmpl index a584ac762..b945a1ab1 100644 --- a/templates/admin/auth/source/ldap.tmpl +++ b/templates/admin/auth/source/ldap.tmpl @@ -106,7 +106,7 @@
- +
diff --git a/templates/admin/auth/source/oauth.tmpl b/templates/admin/auth/source/oauth.tmpl index 63ad77e67..da3a4f913 100644 --- a/templates/admin/auth/source/oauth.tmpl +++ b/templates/admin/auth/source/oauth.tmpl @@ -100,7 +100,7 @@
- +
diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index f0a786560..75b784531 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -1,6 +1,6 @@
- + {{ctx.Locale.Tr "install.domain_helper"}}
@@ -139,7 +139,7 @@
- + {{ctx.Locale.Tr "install.app_url_helper"}}
@@ -347,5 +347,5 @@
- + {{template "base/footer" .}} diff --git a/templates/package/content/alpine.tmpl b/templates/package/content/alpine.tmpl index a1003cd6f..48e1dff93 100644 --- a/templates/package/content/alpine.tmpl +++ b/templates/package/content/alpine.tmpl @@ -18,7 +18,7 @@
- +
diff --git a/templates/package/content/cargo.tmpl b/templates/package/content/cargo.tmpl index da9fc4ab3..5b4c80909 100644 --- a/templates/package/content/cargo.tmpl +++ b/templates/package/content/cargo.tmpl @@ -5,10 +5,10 @@
[registry]
-default = "gitea"
+default = "forgejo"
 
-[registries.gitea]
-index = "" # Sparse index
+[registries.forgejo]
+index = "sparse+" # Sparse index
 # index = "" # Git
 
 [net]
@@ -19,7 +19,7 @@ git-fetch-with-cli = true
cargo add {{.PackageDescriptor.Package.Name}}@{{.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/chef.tmpl b/templates/package/content/chef.tmpl index 0588c6e4b..a2f69b8f8 100644 --- a/templates/package/content/chef.tmpl +++ b/templates/package/content/chef.tmpl @@ -11,7 +11,7 @@
knife supermarket install {{.PackageDescriptor.Package.Name}} {{.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/composer.tmpl b/templates/package/content/composer.tmpl index 862f1c692..3a4025fb3 100644 --- a/templates/package/content/composer.tmpl +++ b/templates/package/content/composer.tmpl @@ -17,7 +17,7 @@
composer require {{.PackageDescriptor.Package.Name}}:{{.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/conan.tmpl b/templates/package/content/conan.tmpl index 55b84d12b..fbbb44d8b 100644 --- a/templates/package/content/conan.tmpl +++ b/templates/package/content/conan.tmpl @@ -8,10 +8,10 @@
-
conan install --remote=gitea {{.PackageDescriptor.Package.Name}}/{{.PackageDescriptor.Version.Version}}
+
conan install --remote=forgejo {{.PackageDescriptor.Package.Name}}/{{.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/conda.tmpl b/templates/package/content/conda.tmpl index 0fd0c3db3..d5905c76f 100644 --- a/templates/package/content/conda.tmpl +++ b/templates/package/content/conda.tmpl @@ -16,7 +16,7 @@ default_channels:
conda install{{if $channel}} -c {{$channel}}{{end}} {{.PackageDescriptor.PackageProperties.GetByName "conda.name"}}={{.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/container.tmpl b/templates/package/content/container.tmpl index f5ee902c9..b8d2768fa 100644 --- a/templates/package/content/container.tmpl +++ b/templates/package/content/container.tmpl @@ -19,7 +19,7 @@
{{range .PackageDescriptor.Files}}{{if eq .File.LowerName "manifest.json"}}{{.Properties.GetByName "container.digest"}}{{end}}{{end}}
- +
diff --git a/templates/package/content/cran.tmpl b/templates/package/content/cran.tmpl index f9a3f7010..54ead877b 100644 --- a/templates/package/content/cran.tmpl +++ b/templates/package/content/cran.tmpl @@ -4,14 +4,14 @@
-
options("repos" = c(getOption("repos"), c(gitea="")))
+
options("repos" = c(getOption("repos"), c(forgejo="")))
install.packages("{{.PackageDescriptor.Package.Name}}")
- +
diff --git a/templates/package/content/debian.tmpl b/templates/package/content/debian.tmpl index 242ee1fba..1aa25d9fa 100644 --- a/templates/package/content/debian.tmpl +++ b/templates/package/content/debian.tmpl @@ -4,8 +4,8 @@
-
sudo curl  -o /etc/apt/trusted.gpg.d/gitea-{{$.PackageDescriptor.Owner.Name}}.asc
-echo "deb  $distribution $component" | sudo tee -a /etc/apt/sources.list.d/gitea.list
+				
sudo curl  -o /etc/apt/trusted.gpg.d/forgejo-{{$.PackageDescriptor.Owner.Name}}.asc
+echo "deb  $distribution $component" | sudo tee -a /etc/apt/sources.list.d/forgejo.list
 sudo apt update

{{ctx.Locale.Tr "packages.debian.registry.info" | Safe}}

@@ -16,7 +16,7 @@ sudo apt update
- +
diff --git a/templates/package/content/generic.tmpl b/templates/package/content/generic.tmpl index ba4df0a57..8a9fc5999 100644 --- a/templates/package/content/generic.tmpl +++ b/templates/package/content/generic.tmpl @@ -11,7 +11,7 @@ curl - + diff --git a/templates/package/content/go.tmpl b/templates/package/content/go.tmpl index f98fc69fb..3b2b478e0 100644 --- a/templates/package/content/go.tmpl +++ b/templates/package/content/go.tmpl @@ -7,7 +7,7 @@
GOPROXY= go install {{$.PackageDescriptor.Package.Name}}@{{$.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/helm.tmpl b/templates/package/content/helm.tmpl index 68e53133f..7f39a0e78 100644 --- a/templates/package/content/helm.tmpl +++ b/templates/package/content/helm.tmpl @@ -12,7 +12,7 @@ helm repo update
helm install {{.PackageDescriptor.Package.Name}} {{AppDomain}}/{{.PackageDescriptor.Package.Name}}
- +
diff --git a/templates/package/content/maven.tmpl b/templates/package/content/maven.tmpl index 100c12e18..7880eb63d 100644 --- a/templates/package/content/maven.tmpl +++ b/templates/package/content/maven.tmpl @@ -40,7 +40,7 @@
mvn dependency:get -DremoteRepositories= -Dartifact={{.PackageDescriptor.Metadata.GroupID}}:{{.PackageDescriptor.Metadata.ArtifactID}}:{{.PackageDescriptor.Version.Version}}
- +
diff --git a/templates/package/content/npm.tmpl b/templates/package/content/npm.tmpl index 882e999be..3c493d38e 100644 --- a/templates/package/content/npm.tmpl +++ b/templates/package/content/npm.tmpl @@ -15,7 +15,7 @@
"{{.PackageDescriptor.Package.Name}}": "{{.PackageDescriptor.Version.Version}}"
- +
diff --git a/templates/package/content/nuget.tmpl b/templates/package/content/nuget.tmpl index 04dac8984..80c7917ae 100644 --- a/templates/package/content/nuget.tmpl +++ b/templates/package/content/nuget.tmpl @@ -11,7 +11,7 @@
dotnet add package --source {{.PackageDescriptor.Owner.Name}} --version {{.PackageDescriptor.Version.Version}} {{.PackageDescriptor.Package.Name}}
- +
diff --git a/templates/package/content/pub.tmpl b/templates/package/content/pub.tmpl index 8657d55db..316001a96 100644 --- a/templates/package/content/pub.tmpl +++ b/templates/package/content/pub.tmpl @@ -7,7 +7,7 @@
dart pub add {{.PackageDescriptor.Package.Name}}:{{.PackageDescriptor.Version.Version}} --hosted-url=
- +
diff --git a/templates/package/content/pypi.tmpl b/templates/package/content/pypi.tmpl index ef9beb428..c4bfe487e 100644 --- a/templates/package/content/pypi.tmpl +++ b/templates/package/content/pypi.tmpl @@ -7,7 +7,7 @@
pip install --index-url  {{.PackageDescriptor.Package.Name}}
- +
diff --git a/templates/package/content/rpm.tmpl b/templates/package/content/rpm.tmpl index 3fd979567..59b189f1a 100644 --- a/templates/package/content/rpm.tmpl +++ b/templates/package/content/rpm.tmpl @@ -21,7 +21,7 @@ zypper install {{$.PackageDescriptor.Package.Name}}
- +
diff --git a/templates/package/content/rubygems.tmpl b/templates/package/content/rubygems.tmpl index 180ff60f7..bc99af4a7 100644 --- a/templates/package/content/rubygems.tmpl +++ b/templates/package/content/rubygems.tmpl @@ -13,7 +13,7 @@ end
- +
diff --git a/templates/package/content/swift.tmpl b/templates/package/content/swift.tmpl index ca36033df..9c2e35eba 100644 --- a/templates/package/content/swift.tmpl +++ b/templates/package/content/swift.tmpl @@ -17,7 +17,7 @@
swift package resolve
- +
diff --git a/templates/package/content/vagrant.tmpl b/templates/package/content/vagrant.tmpl index bbb461e4f..61a4ae8b2 100644 --- a/templates/package/content/vagrant.tmpl +++ b/templates/package/content/vagrant.tmpl @@ -7,7 +7,7 @@
vagrant box add --box-version {{.PackageDescriptor.Version.Version}} ""
- +
diff --git a/templates/package/shared/cargo.tmpl b/templates/package/shared/cargo.tmpl index b45206588..9015bc661 100644 --- a/templates/package/shared/cargo.tmpl +++ b/templates/package/shared/cargo.tmpl @@ -18,7 +18,7 @@
- +
diff --git a/templates/package/shared/list.tmpl b/templates/package/shared/list.tmpl index a572d98bb..48b80af1b 100644 --- a/templates/package/shared/list.tmpl +++ b/templates/package/shared/list.tmpl @@ -45,7 +45,7 @@ {{$packagesUrl := URLJoin .Owner.HomeLink "-" "packages"}}

{{ctx.Locale.Tr "packages.empty.repo" $packagesUrl | Safe}}

{{end}} -

{{ctx.Locale.Tr "packages.empty.documentation" "https://docs.gitea.com/usage/packages/overview/" | Safe}}

+

{{ctx.Locale.Tr "packages.empty.documentation" "https://forgejo.org/docs/latest/user/packages/" | Safe}}

{{else}}

{{ctx.Locale.Tr "packages.filter.no_result"}}

diff --git a/templates/post-install.tmpl b/templates/post-install.tmpl index fb234008f..0dbfbdc31 100644 --- a/templates/post-install.tmpl +++ b/templates/post-install.tmpl @@ -7,7 +7,7 @@
- {{ctx.Locale.Tr + {{ctx.Locale.Tr
diff --git a/templates/repo/migrate/migrating.tmpl b/templates/repo/migrate/migrating.tmpl index 649d14ad9..8921d9727 100644 --- a/templates/repo/migrate/migrating.tmpl +++ b/templates/repo/migrate/migrating.tmpl @@ -9,12 +9,12 @@
- +
- + {{svg "octicon-git-pull-request-closed" 256 "ui red icon"}}
diff --git a/templates/repo/settings/webhook/base_list.tmpl b/templates/repo/settings/webhook/base_list.tmpl index ed6e670d6..1f38c035c 100644 --- a/templates/repo/settings/webhook/base_list.tmpl +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -4,6 +4,10 @@