diff --git a/.woodpecker/testing-amd64.yml b/.woodpecker/testing-amd64.yml index 340ee55736..94fd9e1844 100644 --- a/.woodpecker/testing-amd64.yml +++ b/.woodpecker/testing-amd64.yml @@ -75,6 +75,14 @@ pipeline: commands: - ./build/test-env-prepare.sh + environment-to-ini: + image: *golang_image + environment: + GOPROXY_OVERRIDE: *goproxy_override + commands: + - *goproxy_setup + - go test contrib/environment-to-ini/environment-to-ini.go contrib/environment-to-ini/environment-to-ini_test.go + build: image: *test_image environment: diff --git a/Dockerfile b/Dockerfile index 93eff1a836..50ff26b180 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ ENTRYPOINT ["/usr/bin/entrypoint"] CMD ["/bin/s6-svscan", "/etc/s6"] COPY docker/root / +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 fe268b9250..54ba72759d 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -52,6 +52,7 @@ RUN mkdir -p /var/lib/gitea /etc/gitea RUN chown git:git /var/lib/gitea /etc/gitea COPY docker/rootless / +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 6d0ba164b8..56215169b0 100644 --- a/Makefile +++ b/Makefile @@ -159,6 +159,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 @@ -334,6 +335,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 diff --git a/README.md b/README.md index e223979d42..2c0a3ef3ea 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 9df6b83b56..bcacdc0200 100644 --- a/assets/favicon.svg +++ b/assets/favicon.svg @@ -1,31 +1,27 @@ - - - - - - - - - - - + + + + + + + + + diff --git a/assets/logo.svg b/assets/logo.svg index 9df6b83b56..bcacdc0200 100644 --- a/assets/logo.svg +++ b/assets/logo.svg @@ -1,31 +1,27 @@ - - - - - - - - - - - + + + + + + + + + diff --git a/cmd/dump.go b/cmd/dump.go index 19589caa75..2703cffb50 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -98,14 +98,14 @@ 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, 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{ @@ -194,7 +194,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 @@ -269,7 +269,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) } @@ -291,8 +291,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/serv.go b/cmd/serv.go index d7510845a5..12f056d91a 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -150,13 +150,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/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index b502c15cec..1b8b63faaa 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -1,3 +1,4 @@ +// Copyright 2023 The Forgejo Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT @@ -18,17 +19,17 @@ import ( ) // EnvironmentPrefix environment variables prefixed with this represent ini values to write -const EnvironmentPrefix = "GITEA" +const prefixRegexpString = "^(FORGEJO|GITEA)" 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. @@ -46,9 +47,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 - on the configuration cheat sheet.` + You would set the environment variables: "FORGEJO__LOG_0x2E_CONSOLE__COLORIZE=false" + and "FORGEJO__LOG_0x2E_CONSOLE__STDERR=false".` app.Flags = []cli.Flag{ cli.StringFlag{ Name: "custom-path, C", @@ -76,7 +76,7 @@ func main() { }, cli.StringFlag{ Name: "prefix, p", - Value: EnvironmentPrefix, + Value: prefixRegexpString, Usage: "Environment prefix to look for - will be suffixed by __ (2 underscores)", }, } @@ -89,6 +89,19 @@ func main() { } } +func splitEnvironmentVariable(prefixRegexp *regexp.Regexp, kv string) (string, string) { + idx := strings.IndexByte(kv, '=') + if idx < 0 { + return "", "" + } + k := kv[:idx] + loc := prefixRegexp.FindStringIndex(k) + if loc == nil { + return "", "" + } + return k[loc[1]:], kv[idx+1:] +} + func runEnvironmentToIni(c *cli.Context) error { providedCustom := c.String("custom-path") providedConf := c.String("config") @@ -111,19 +124,13 @@ func runEnvironmentToIni(c *cli.Context) error { changed := false - prefix := c.String("prefix") + "__" + prefixRegexp := regexp.MustCompile(c.String("prefix") + "__") for _, kv := range os.Environ() { - idx := strings.IndexByte(kv, '=') - if idx < 0 { + eKey, value := splitEnvironmentVariable(prefixRegexp, kv) + if eKey == "" { continue } - eKey := kv[:idx] - value := kv[idx+1:] - if !strings.HasPrefix(eKey, prefix) { - continue - } - eKey = eKey[len(prefix):] sectionName, keyName := DecodeSectionKey(eKey) if len(keyName) == 0 { continue @@ -163,14 +170,11 @@ func runEnvironmentToIni(c *cli.Context) error { } if c.Bool("clear") { for _, kv := range os.Environ() { - idx := strings.IndexByte(kv, '=') - if idx < 0 { + eKey, _ := splitEnvironmentVariable(prefixRegexp, kv) + if eKey == "" { continue } - eKey := kv[:idx] - if strings.HasPrefix(eKey, prefix) { - _ = os.Unsetenv(eKey) - } + _ = os.Unsetenv(eKey) } } return nil diff --git a/contrib/environment-to-ini/environment-to-ini_test.go b/contrib/environment-to-ini/environment-to-ini_test.go new file mode 100644 index 0000000000..6abbb67eff --- /dev/null +++ b/contrib/environment-to-ini/environment-to-ini_test.go @@ -0,0 +1,21 @@ +// Copyright 2023 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package main + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_splitEnvironmentVariable(t *testing.T) { + prefixRegexp := regexp.MustCompile(prefixRegexpString + "__") + k, v := splitEnvironmentVariable(prefixRegexp, "FORGEJO__KEY=VALUE") + assert.Equal(t, k, "KEY") + assert.Equal(t, v, "VALUE") + k, v = splitEnvironmentVariable(prefixRegexp, "nothing=interesting") + assert.Equal(t, k, "") + assert.Equal(t, v, "") +} diff --git a/contrib/systemd/gitea.service b/contrib/systemd/forgejo.service similarity index 59% rename from contrib/systemd/gitea.service rename to contrib/systemd/forgejo.service index d205c6ee8b..04ef69adc0 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 ## @@ -55,28 +55,28 @@ RestartSec=2s 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 +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/custom/conf/app.example.ini b/custom/conf/app.example.ini index fae3395028..ce5626611d 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -365,7 +365,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 ;; @@ -2596,8 +2596,8 @@ ROUTER = console ; [actions] ;; Enable/Disable actions capabilities ;ENABLED = false -;; Default address to get action plugins, e.g. the default value means downloading from "https://gitea.com/actions/checkout" for "uses: actions/checkout@v3" -;DEFAULT_ACTIONS_URL = https://gitea.com +;; Default address to get action plugins, e.g. the default value means downloading from "https://codeberg.org/actions/checkout" for "uses: actions/checkout@v3" +;DEFAULT_ACTIONS_URL = https://codeberg.org ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docker/root/etc/s6/gitea/setup b/docker/root/etc/s6/gitea/setup index d8f6a3b319..958d50a798 100755 --- a/docker/root/etc/s6/gitea/setup +++ b/docker/root/etc/s6/gitea/setup @@ -24,7 +24,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 feab02a379..b480685863 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/docs/content/doc/administration/config-cheat-sheet.en-us.md b/docs/content/doc/administration/config-cheat-sheet.en-us.md index cf92579b36..b77dc01987 100644 --- a/docs/content/doc/administration/config-cheat-sheet.en-us.md +++ b/docs/content/doc/administration/config-cheat-sheet.en-us.md @@ -1355,7 +1355,7 @@ PROXY_HOSTS = *.github.com ## Actions (`actions`) - `ENABLED`: **false**: Enable/Disable actions capabilities -- `DEFAULT_ACTIONS_URL`: **https://gitea.com**: Default address to get action plugins, e.g. the default value means downloading from "" for "uses: actions/checkout@v3" +- `DEFAULT_ACTIONS_URL`: **https://codeberg.org**: Default address to get action plugins, e.g. the default value means downloading from "" for "uses: actions/checkout@v3" `DEFAULT_ACTIONS_URL` indicates where should we find the relative path action plugin. i.e. when use an action in a workflow file like @@ -1375,14 +1375,14 @@ jobs: Now we need to know how to get actions/checkout, this configuration is the default git server to get it. That means we will get the repository via git clone ${DEFAULT_ACTIONS_URL}/actions/checkout and fetch tag v3. -To help people who don't want to mirror these actions in their git instances, the default value is https://gitea.com +To help people who don't want to mirror these actions in their git instances, the default value is https://codeberg.org To help people run actions totally in their network, they can change the value and copy all necessary action repositories into their git server. Of course we should support the form in future PRs like ```yaml steps: - - uses: gitea.com/actions/checkout@v3 + - uses: codeberg.org/actions/checkout@v3 ``` although Github don't support this form. diff --git a/main.go b/main.go index f004d58bea..06343b2698 100644 --- a/main.go +++ b/main.go @@ -50,11 +50,20 @@ func init() { originalSubcommandHelpTemplate = cli.SubcommandHelpTemplate } +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() app := cli.NewApp() - app.Name = "Gitea" - app.Usage = "A painless self-hosted Git service" - app.Description = `By default, gitea will start serving using the webserver with no + app.Name = "Forgejo" + app.Usage = "Beyond coding. We forge." + app.Description = `By default, forgejo will start serving using the webserver with no arguments - which can alternatively be run by running the subcommand web.` app.Version = Version + formatBuiltWith() app.Commands = []cli.Command{ @@ -178,6 +187,9 @@ func adjustHelpTemplate(originalTemplate string) string { if _, ok := os.LookupEnv("GITEA_CUSTOM"); ok { overridden = "(GITEA_CUSTOM)" } + if _, ok := os.LookupEnv("FORGEJO_CUSTOM"); ok { + overridden = "(FORGEJO_CUSTOM)" + } return fmt.Sprintf(`%s DEFAULT CONFIGURATION: diff --git a/models/user/user.go b/models/user/user.go index 82c2d3b6cd..20daebd205 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -535,6 +535,7 @@ var ( "user", "v2", "gitea-actions", + "forgejo-actions", } reservedUserPatterns = []string{"*.keys", "*.gpg", "*.rss", "*.atom"} diff --git a/models/user/user_system.go b/models/user/user_system.go index f54f4e3ffb..e3f79a4baf 100644 --- a/models/user/user_system.go +++ b/models/user/user_system.go @@ -37,9 +37,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/actions/workflows.go b/modules/actions/workflows.go index 738026142b..aa48fdd515 100644 --- a/modules/actions/workflows.go +++ b/modules/actions/workflows.go @@ -19,7 +19,10 @@ import ( ) func ListWorkflows(commit *git.Commit) (git.Entries, error) { - tree, err := commit.SubTree(".gitea/workflows") + tree, err := commit.SubTree(".forgejo/workflows") + if _, ok := err.(git.ErrNotExist); ok { + tree, err = commit.SubTree(".gitea/workflows") + } if _, ok := err.(git.ErrNotExist); ok { tree, err = commit.SubTree(".github/workflows") } diff --git a/modules/context/api.go b/modules/context/api.go index f7a3384691..d511a3ba2d 100644 --- a/modules/context/api.go +++ b/modules/context/api.go @@ -188,13 +188,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.Context.Doer.ID) if err != nil { if auth.IsErrTwoFactorNotEnrolled(err) { @@ -203,7 +210,7 @@ func (ctx *APIContext) CheckForOTP() { ctx.Context.Error(http.StatusInternalServerError) return } - ok, err := twofa.ValidateTOTP(otpHeader) + ok, err := twofa.ValidateTOTP(getOtpHeader(ctx.Req.Header)) if err != nil { ctx.Context.Error(http.StatusInternalServerError) return diff --git a/modules/context/api_forgejo_test.go b/modules/context/api_forgejo_test.go new file mode 100644 index 0000000000..b85de55904 --- /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 46e0152ef4..ee83706d37 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -32,6 +32,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 624d2f4d4b..dac1a63793 100644 --- a/modules/httpcache/httpcache_test.go +++ b/modules/httpcache/httpcache_test.go @@ -29,6 +29,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/actions.go b/modules/setting/actions.go index b11500dab4..a4273c6754 100644 --- a/modules/setting/actions.go +++ b/modules/setting/actions.go @@ -15,7 +15,7 @@ var ( DefaultActionsURL string `ini:"DEFAULT_ACTIONS_URL"` }{ Enabled: false, - DefaultActionsURL: "https://gitea.com", + DefaultActionsURL: "https://codeberg.org", } ) diff --git a/modules/setting/database.go b/modules/setting/database.go index 8c4dfb21d7..bf7508c25c 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -79,7 +79,7 @@ func loadDBSetting(rootCfg ConfigProvider) { log.Error("Deprecated database mysql charset utf8 support, please use utf8mb4 or convert utf8 to utf8mb4.") } - 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/log.go b/modules/setting/log.go index dabdb543ab..d6eeba865f 100644 --- a/modules/setting/log.go +++ b/modules/setting/log.go @@ -240,7 +240,7 @@ func generateLogConfig(sec *ini.Section, name string, defaults defaultLogOptions sendTos[i] = strings.TrimSpace(address) } logConfig["sendTos"] = sendTos - logConfig["subject"] = sec.Key("SUBJECT").MustString("Diagnostic message from Gitea") + logConfig["subject"] = sec.Key("SUBJECT").MustString("Diagnostic message from Forgejo") } logConfig["colorize"] = sec.Key("COLORIZE").MustBool(false) @@ -330,7 +330,7 @@ func initLogFrom(rootCfg ConfigProvider) { Provider: provider, Config: config, }) - log.Info("Gitea Log Mode: %s(%s:%s)", util.ToTitleCase(name), util.ToTitleCase(provider), levelName) + log.Info("Forgejo Log Mode: %s(%s:%s)", util.ToTitleCase(name), util.ToTitleCase(provider), levelName) } AddLogDescription(log.DEFAULT, &description) diff --git a/modules/setting/repository.go b/modules/setting/repository.go index bae3c658a4..6af9791d10 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -275,7 +275,7 @@ func loadRepositoryFrom(rootCfg ConfigProvider) { Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool() 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")) forcePathSeparator(RepoRootPath) if !filepath.IsAbs(RepoRootPath) { RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath) diff --git a/modules/setting/server.go b/modules/setting/server.go index 1839062685..aff0cfba33 100644 --- a/modules/setting/server.go +++ b/modules/setting/server.go @@ -167,7 +167,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/setting.go b/modules/setting/setting.go index 4d7a7caab8..898f8ffb82 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -148,6 +148,9 @@ func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string) if giteaCustom, ok := os.LookupEnv("GITEA_CUSTOM"); ok { CustomPath = giteaCustom } + if forgejoCustom, ok := os.LookupEnv("FORGEJO_CUSTOM"); ok { + CustomPath = forgejoCustom + } if len(providedCustom) != 0 { CustomPath = providedCustom } diff --git a/modules/setting/ui.go b/modules/setting/ui.go index 2df3c35c76..36a775ac61 100644 --- a/modules/setting/ui.go +++ b/modules/setting/ui.go @@ -79,11 +79,11 @@ var UI = struct { ReactionMaxUserNum: 10, ThemeColorMetaTag: `#6cc644`, 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 @@ -126,9 +126,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 c01261dbbd..b56c55c439 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 df5da6790f..5055561a4b 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -40,7 +40,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 db4ab17931..fac5590e21 100644 --- a/modules/webhook/type.go +++ b/modules/webhook/type.go @@ -71,6 +71,7 @@ type HookType = string // Types of webhooks const ( + FORGEJO HookType = "forgejo" GITEA HookType = "gitea" GOGS HookType = "gogs" SLACK HookType = "slack" diff --git a/public/img/apple-touch-icon.png b/public/img/apple-touch-icon.png index 0c803d35dc..1f6c1544f8 100644 Binary files a/public/img/apple-touch-icon.png and b/public/img/apple-touch-icon.png differ diff --git a/public/img/avatar_default.png b/public/img/avatar_default.png index 129967112d..f335e51dad 100644 Binary files a/public/img/avatar_default.png and b/public/img/avatar_default.png differ diff --git a/public/img/emoji/forgejo.png b/public/img/emoji/forgejo.png new file mode 100644 index 0000000000..f335e51dad Binary files /dev/null and b/public/img/emoji/forgejo.png differ diff --git a/public/img/failed.png b/public/img/failed.png deleted file mode 100644 index b37545f90c..0000000000 Binary files a/public/img/failed.png and /dev/null differ diff --git a/public/img/favicon.png b/public/img/favicon.png index dcd4edb1a3..eda0347eff 100644 Binary files a/public/img/favicon.png and b/public/img/favicon.png differ diff --git a/public/img/favicon.svg b/public/img/favicon.svg index afeeacb77c..804b05e284 100644 --- a/public/img/favicon.svg +++ b/public/img/favicon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/img/forgejo-loading.svg b/public/img/forgejo-loading.svg new file mode 100644 index 0000000000..919552ebb5 --- /dev/null +++ b/public/img/forgejo-loading.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/public/img/forgejo.svg b/public/img/forgejo.svg new file mode 100644 index 0000000000..804b05e284 --- /dev/null +++ b/public/img/forgejo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/gitea-original.svg b/public/img/gitea-original.svg new file mode 100644 index 0000000000..dca9b4f4db --- /dev/null +++ b/public/img/gitea-original.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/gitea.svg b/public/img/gitea.svg index dca9b4f4db..804b05e284 100644 --- a/public/img/gitea.svg +++ b/public/img/gitea.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/img/loading.png b/public/img/loading.png deleted file mode 100644 index c5ba3d9cd7..0000000000 Binary files a/public/img/loading.png and /dev/null differ diff --git a/public/img/logo.png b/public/img/logo.png index c7971f9183..1b2d9b4023 100644 Binary files a/public/img/logo.png and b/public/img/logo.png differ diff --git a/public/img/logo.svg b/public/img/logo.svg index afeeacb77c..804b05e284 100644 --- a/public/img/logo.svg +++ b/public/img/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8fd824640f..d0a94df6d5 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. // @@ -675,7 +675,7 @@ func Routes(ctx gocontext.Context) *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 319c3483e1..9e6e2e3db1 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 d5e8924f5d..c76a25f71f 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -32,7 +32,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) { @@ -79,6 +82,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.Context, blob, lastModified); err != nil { ctx.Error(http.StatusInternalServerError, "ServeBlob", err) @@ -128,6 +132,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/install/install.go b/routers/install/install.go index 8e2d19c732..f70cdfa135 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -185,7 +185,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.io/en-us/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/admin/config.go b/routers/web/admin/config.go index 075fb423dc..eb90bb211b 100644 --- a/routers/web/admin/config.go +++ b/routers/web/admin/config.go @@ -175,10 +175,10 @@ func Config(ctx *context.Context) { envVars := map[string]*envVar{} if len(os.Getenv("GITEA_WORK_DIR")) > 0 { - envVars["GITEA_WORK_DIR"] = &envVar{"GITEA_WORK_DIR", os.Getenv("GITEA_WORK_DIR")} + envVars["FORGEJO_WORK_DIR"] = &envVar{"GITEA_WORK_DIR", os.Getenv("GITEA_WORK_DIR")} } if len(os.Getenv("GITEA_CUSTOM")) > 0 { - envVars["GITEA_CUSTOM"] = &envVar{"GITEA_CUSTOM", os.Getenv("GITEA_CUSTOM")} + envVars["FORGEJO_CUSTOM"] = &envVar{"GITEA_CUSTOM", os.Getenv("GITEA_CUSTOM")} } ctx.Data["EnvVars"] = envVars diff --git a/routers/web/repo/webhook.go b/routers/web/repo/webhook.go index f30588967e..aedbe27596 100644 --- a/routers/web/repo/webhook.go +++ b/routers/web/repo/webhook.go @@ -307,6 +307,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 00ccff85f3..78a687055d 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -318,6 +318,7 @@ func RegisterRoutes(m *web.Route) { addWebhookAddRoutes := func() { m.Get("/{type}/new", repo.WebhooksNew) + m.Post("/forgejo/new", web.Bind(forms.NewWebhookForm{}), repo.ForgejoHooksNewPost) m.Post("/gitea/new", web.Bind(forms.NewWebhookForm{}), repo.GiteaHooksNewPost) m.Post("/gogs/new", web.Bind(forms.NewGogshookForm{}), repo.GogsHooksNewPost) m.Post("/slack/new", web.Bind(forms.NewSlackHookForm{}), repo.SlackHooksNewPost) @@ -332,6 +333,7 @@ func RegisterRoutes(m *web.Route) { } addWebhookEditRoutes := func() { + m.Post("/forgejo/{id}", web.Bind(forms.NewWebhookForm{}), repo.ForgejoHooksEditPost) m.Post("/gitea/{id}", web.Bind(forms.NewWebhookForm{}), repo.GiteaHooksEditPost) m.Post("/gogs/{id}", web.Bind(forms.NewGogshookForm{}), repo.GogsHooksEditPost) m.Post("/slack/{id}", web.Bind(forms.NewSlackHookForm{}), repo.SlackHooksEditPost) diff --git a/services/mailer/mail.go b/services/mailer/mail.go index 351b79b5df..030491a467 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -415,6 +415,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 e389b1f9fe..c63b6e8973 100644 --- a/services/webhook/deliver.go +++ b/services/webhook/deliver.go @@ -122,6 +122,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 b862d5bff1..bdbacd7512 100644 --- a/services/webhook/webhook.go +++ b/services/webhook/webhook.go @@ -69,7 +69,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] @@ -172,7 +172,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/hook_new.tmpl b/templates/admin/hook_new.tmpl index 0c018ff293..f15a1c20f4 100644 --- a/templates/admin/hook_new.tmpl +++ b/templates/admin/hook_new.tmpl @@ -14,8 +14,10 @@ {{.locale.Tr "admin.defaulthooks.update_webhook"}} {{end}}
- {{if eq .HookType "gitea"}} - + {{if eq .HookType "forgejo"}} + + {{else if eq .HookType "gitea"}} + {{else if eq .HookType "gogs"}} {{else if eq .HookType "slack"}} @@ -40,6 +42,7 @@
+ {{template "repo/settings/webhook/forgejo" .}} {{template "repo/settings/webhook/gitea" .}} {{template "repo/settings/webhook/gogs" .}} {{template "repo/settings/webhook/slack" .}} diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 53d0a2c77c..09473ff9c9 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -1,7 +1,7 @@
- + {{template "base/footer" .}} diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl index 4685225f4c..35c26c4465 100644 --- a/templates/org/settings/hook_new.tmpl +++ b/templates/org/settings/hook_new.tmpl @@ -9,8 +9,10 @@

{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
- {{if eq .HookType "gitea"}} - + {{if eq .HookType "forgejo"}} + + {{else if eq .HookType "gitea"}} + {{else if eq .HookType "gogs"}} {{else if eq .HookType "slack"}} diff --git a/templates/post-install.tmpl b/templates/post-install.tmpl index f237a6e01b..a1cd4dcd87 100644 --- a/templates/post-install.tmpl +++ b/templates/post-install.tmpl @@ -7,7 +7,7 @@
- +
diff --git a/templates/repo/migrate/migrating.tmpl b/templates/repo/migrate/migrating.tmpl index cd3c5e754e..87e5a81306 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 61c5799513..6c69e3a2a0 100644 --- a/templates/repo/settings/webhook/base_list.tmpl +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -4,8 +4,11 @@