diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 9178f85538..d704869c91 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -127,7 +127,7 @@ jobs: - name: Build test binary run: | - go build -tags="bindata sqlite sqlite_unlock_notify" -o gitea . + go build -tags="bindata sqlite sqlite_unlock_notify" -o gitcaddy-server . - name: Generate test config run: | @@ -182,7 +182,7 @@ jobs: RESPONSE=$(curl -sf -X POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: application/json" \ - -d '{"tag_name":"'"$TAG"'","name":"Gitea '"$TAG"'","body":"Official release of Gitea '"$TAG"'.","draft":false,"prerelease":false}' \ + -d '{"tag_name":"'"$TAG"'","name":"Gitea '"$TAG"'","body":"Official release of GitCaddy Server '"$TAG"'.","draft":false,"prerelease":false}' \ "https://direct.git.marketally.com/api/v1/repos/${{ github.repository }}/releases" 2>&1) if echo "$RESPONSE" | grep -q '"id":[0-9]'; then @@ -258,7 +258,7 @@ jobs: EXT=".exe" fi - OUTPUT="gitea-${VERSION}-${GOOS}-${GOARCH}${EXT}" + OUTPUT="gitcaddy-server-${VERSION}-${GOOS}-${GOARCH}${EXT}" go build -v -trimpath -tags "${TAGS}" -ldflags "${LDFLAGS}" -o "dist/${OUTPUT}" . diff --git a/Makefile b/Makefile index ee75906b7f..38ef1d1d77 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.9 -DOCKER_IMAGE ?= gitea/gitea +DOCKER_IMAGE ?= gitcaddy/gitcaddy-server DOCKER_TAG ?= latest DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG) @@ -70,10 +70,10 @@ else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows) endif ifeq ($(IS_WINDOWS),yes) GOFLAGS := -v -buildmode=exe - EXECUTABLE ?= gitea.exe + EXECUTABLE ?= gitcaddy-server.exe else GOFLAGS := -v - EXECUTABLE ?= gitea + EXECUTABLE ?= gitcaddy-server endif ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu) diff --git a/README.md b/README.md index 75cd364a3e..9e54226e17 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ Download from [Releases](https://git.marketally.com/gitcaddy/gitea/releases): ```bash # Linux (amd64) -curl -L -o gitcaddy https://git.marketally.com/gitcaddy/gitea/releases/latest/download/gitea-linux-amd64 +curl -L -o gitcaddy-server https://git.marketally.com/gitcaddy/gitea/releases/latest/download/gitcaddy-server-linux-amd64 chmod +x gitcaddy ./gitcaddy web ``` @@ -275,7 +275,7 @@ chmod +x gitcaddy git clone https://git.marketally.com/gitcaddy/gitea.git cd gitea TAGS="bindata sqlite sqlite_unlock_notify" make build -./gitea web +./gitcaddy-server web ``` ### Docker diff --git a/cmd/main.go b/cmd/main.go index 203799f02f..f4a04bc1c5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -86,9 +86,9 @@ type AppVersion struct { func NewMainApp(appVer AppVersion) *cli.Command { app := &cli.Command{} - app.Name = "gitea" // must be lower-cased because it appears in the "USAGE" section like "gitea doctor [command [command options]]" - app.Usage = "A painless self-hosted Git service" - app.Description = `Gitea program contains "web" and other subcommands. If no subcommand is given, it starts the web server by default. Use "web" subcommand for more web server arguments, use other subcommands for other purposes.` + app.Name = "gitcaddy-server" // must be lower-cased because it appears in the "USAGE" section like "gitea doctor [command [command options]]" + app.Usage = "GitCaddy Server - A painless self-hosted Git service" + app.Description = `GitCaddy Server contains "web" and other subcommands. If no subcommand is given, it starts the web server by default. Use "web" subcommand for more web server arguments, use other subcommands for other purposes. Based on Gitea - https://gitea.io` app.Version = appVer.Version + appVer.Extra app.EnableShellCompletion = true app.Flags = []cli.Flag{ diff --git a/modules/setting/config_env.go b/modules/setting/config_env.go index 4758eb72cb..72ab29df32 100644 --- a/modules/setting/config_env.go +++ b/modules/setting/config_env.go @@ -14,6 +14,9 @@ import ( ) const ( + // EnvConfigKeyPrefixGitCaddy is the primary prefix for GitCaddy environment variables + EnvConfigKeyPrefixGitCaddy = "GITCADDY__" + // EnvConfigKeyPrefixGitea is the legacy prefix for backward compatibility EnvConfigKeyPrefixGitea = "GITEA__" EnvConfigKeySuffixFile = "__FILE" ) @@ -24,7 +27,8 @@ var escapeRegex = regexp.MustCompile(escapeRegexpString) func CollectEnvConfigKeys() (keys []string) { for _, env := range os.Environ() { - if strings.HasPrefix(env, EnvConfigKeyPrefixGitea) { + // Support both GITCADDY__ and GITEA__ prefixes + if strings.HasPrefix(env, EnvConfigKeyPrefixGitCaddy) || strings.HasPrefix(env, EnvConfigKeyPrefixGitea) { k, _, _ := strings.Cut(env, "=") keys = append(keys, k) } @@ -41,7 +45,7 @@ func ClearEnvConfigKeys() { // decodeEnvSectionKey will decode a portable string encoded Section__Key pair // Portable strings are considered to be of the form [A-Z0-9_]* // We will encode a disallowed value as the UTF8 byte string preceded by _0X and -// followed by _. E.g. _0X2C_ for a '-' and _0X2E_ for '.' +// followed by _. E.g. _0X2C_ for a '-', and _0X2E_ for '.'. // Section and Key are separated by a plain '__'. // The entire section can be encoded as a UTF8 byte string func decodeEnvSectionKey(encoded string) (ok bool, section, key string) { @@ -96,16 +100,22 @@ 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) { +// The environment key is in the form of GITCADDY__SECTION__KEY or GITEA__SECTION__KEY (legacy) +// or GITCADDY__SECTION__KEY__FILE / GITEA__SECTION__KEY__FILE +func decodeEnvironmentKey(prefixGitCaddy, prefixGitea, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) { + var prefix string + if strings.HasPrefix(envKey, prefixGitCaddy) { + prefix = prefixGitCaddy + } else if strings.HasPrefix(envKey, prefixGitea) { + prefix = prefixGitea + } else { return false, "", "", false } if strings.HasSuffix(envKey, suffixFile) { useFileValue = true envKey = envKey[:len(envKey)-len(suffixFile)] } - ok, section, key = decodeEnvSectionKey(envKey[len(prefixGitea):]) + ok, section, key = decodeEnvSectionKey(envKey[len(prefix):]) return ok, section, key, useFileValue } @@ -119,7 +129,7 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) { // parse the environment variable to config section name and key name envKey := before envValue := after - ok, sectionName, keyName, useFileValue := decodeEnvironmentKey(EnvConfigKeyPrefixGitea, EnvConfigKeySuffixFile, envKey) + ok, sectionName, keyName, useFileValue := decodeEnvironmentKey(EnvConfigKeyPrefixGitCaddy, EnvConfigKeyPrefixGitea, EnvConfigKeySuffixFile, envKey) if !ok { continue } @@ -167,20 +177,25 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) { return changed } -// InitGiteaEnvVars initializes the environment variables for gitea -func InitGiteaEnvVars() { - // Ideally Gitea should only accept the environment variables which it clearly knows instead of unsetting the ones it doesn't want, +// InitGitCaddyEnvVars initializes the environment variables for GitCaddy Server +func InitGitCaddyEnvVars() { + // Ideally GitCaddy should only accept the environment variables which it clearly knows instead of unsetting the ones it doesn't want, // but the ideal behavior would be a breaking change, and it seems not bringing enough benefits to end users, // so at the moment we could still keep "unsetting the unnecessary environments" - // HOME is managed by Gitea, Gitea's git should use "HOME/.gitconfig". + // HOME is managed by GitCaddy, GitCaddy's git should use "HOME/.gitconfig". // But git would try "XDG_CONFIG_HOME/git/config" first if "HOME/.gitconfig" does not exist, // then our git.InitFull would still write to "XDG_CONFIG_HOME/git/config" if XDG_CONFIG_HOME is set. _ = os.Unsetenv("XDG_CONFIG_HOME") } +// InitGiteaEnvVars is an alias for InitGitCaddyEnvVars for backward compatibility +func InitGiteaEnvVars() { + InitGitCaddyEnvVars() +} + func InitGiteaEnvVarsForTesting() { - InitGiteaEnvVars() + InitGitCaddyEnvVars() _ = os.Unsetenv("GIT_AUTHOR_NAME") _ = os.Unsetenv("GIT_AUTHOR_EMAIL") _ = os.Unsetenv("GIT_AUTHOR_DATE") diff --git a/modules/setting/path.go b/modules/setting/path.go index f51457a620..908826f702 100644 --- a/modules/setting/path.go +++ b/modules/setting/path.go @@ -18,11 +18,11 @@ var ( // AppPath represents the path to the gitea binary AppPath string - // AppWorkPath is the "working directory" of Gitea. It maps to the: WORK_PATH in app.ini, "--work-path" flag, environment variable GITEA_WORK_DIR. + // AppWorkPath is the "working directory" of GitCaddy. It maps to the: WORK_PATH in app.ini, "--work-path" flag, environment variable GITCADDY_WORK_DIR (or GITEA_WORK_DIR for backward compatibility). // If that is not set it is the default set here by the linker or failing that the directory of AppPath. // It is used as the base path for several other paths. AppWorkPath string - CustomPath string // Custom directory path. Env: GITEA_CUSTOM + CustomPath string // Custom directory path. Env: GITCADDY_CUSTOM (or GITEA_CUSTOM for backward compatibility) CustomConf string appWorkPathBuiltin string diff --git a/modules/setting/setting.go b/modules/setting/setting.go index dc60d99bd6..8f6b1ffa58 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -96,7 +96,7 @@ func InitCfgProvider(file string) { func MustInstalled() { if !InstallLock { - log.Fatal(`Unable to load config file for a installed Gitea instance, you should either use "--config" to set your config file (app.ini), or run "gitea web" command to install Gitea.`) + log.Fatal(`Unable to load config file for a installed GitCaddy instance, you should either use "--config" to set your config file (app.ini), or run "gitcaddy-server web" command to install Gitea.`) } } @@ -176,9 +176,9 @@ func loadRunModeFrom(rootCfg ConfigProvider) { if os.Getuid() == 0 { if !unsafeAllowRunAsRoot { // Special thanks to VLC which inspired the wording of this messaging. - log.Fatal("Gitea is not supposed to be run as root. Sorry. If you need to use privileged TCP ports please instead use setcap and the `cap_net_bind_service` permission") + log.Fatal("GitCaddy Server is not supposed to be run as root. Sorry. If you need to use privileged TCP ports please instead use setcap and the `cap_net_bind_service` permission") } - log.Critical("You are running Gitea using the root user, and have purposely chosen to skip built-in protections around this. You have been warned against this.") + log.Critical("You are running GitCaddy Server using the root user, and have purposely chosen to skip built-in protections around this. You have been warned against this.") } } diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index c2600aedd0..915cc162c5 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -13,6 +13,7 @@ "register": "Register", "version": "Version", "powered_by": "Powered by %s", + "based_on": "Based on", "page": "Page", "template": "Template", "language": "Language", diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index df437badf6..d5f72e654b 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -1,7 +1,8 @@