Skip to content

Commit b2289c5

Browse files
committed
Merge remote-tracking branch 'forgejo/v1.19/forgejo-branding' into v1.19/forgejo
2 parents b4b586f + 82cd82d commit b2289c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+995
-221
lines changed

.woodpecker/testing-amd64.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ pipeline:
7575
commands:
7676
- ./build/test-env-prepare.sh
7777

78+
environment-to-ini:
79+
image: *golang_image
80+
environment:
81+
GOPROXY_OVERRIDE: *goproxy_override
82+
commands:
83+
- *goproxy_setup
84+
- go test contrib/environment-to-ini/environment-to-ini.go contrib/environment-to-ini/environment-to-ini_test.go
85+
7886
build:
7987
image: *test_image
8088
environment:

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ENTRYPOINT ["/usr/bin/entrypoint"]
6262
CMD ["/bin/s6-svscan", "/etc/s6"]
6363

6464
COPY docker/root /
65+
RUN cd /usr/local/bin ; ln -s gitea forgejo
6566
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
6667
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
6768
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh

Dockerfile.rootless

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ RUN mkdir -p /var/lib/gitea /etc/gitea
5252
RUN chown git:git /var/lib/gitea /etc/gitea
5353

5454
COPY docker/rootless /
55+
RUN cd /usr/local/bin ; ln -s gitea forgejo
5556
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
5657
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
5758
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEs
164164
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|"basePath": "/api/v1"|g
165165
SWAGGER_EXCLUDE := code.gitea.io/sdk
166166
SWAGGER_NEWLINE_COMMAND := -e '$$a\'
167+
SWAGGER_SPEC_BRANDING := s|Gitea API|Forgejo API|g
167168

168169
TEST_MYSQL_HOST ?= mysql:3306
169170
TEST_MYSQL_DBNAME ?= testgitea
@@ -338,6 +339,7 @@ $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
338339
$(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
339340
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
340341
$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
342+
$(SED_INPLACE) '$(SWAGGER_SPEC_BRANDING)' './$(SWAGGER_SPEC)'
341343

342344
.PHONY: swagger-check
343345
swagger-check: generate-swagger

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<img src="https://codeberg.org/forgejo/meta/raw/branch/readme/logo/forgejo.svg" alt="" width="192" align="center" />
2+
<img src="./assets/logo.svg" alt="" width="192" align="center" />
33
<h1 align="center">Welcome to Forgejo</h1>
44
</div>
55

assets/favicon.svg

Lines changed: 26 additions & 30 deletions
Loading

assets/logo.svg

Lines changed: 26 additions & 30 deletions
Loading

cmd/dump.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ var outputTypeEnum = &outputType{
9898
// CmdDump represents the available dump sub-command.
9999
var CmdDump = cli.Command{
100100
Name: "dump",
101-
Usage: "Dump Gitea files and database",
101+
Usage: "Dump Forgejo files and database",
102102
Description: `Dump compresses all related files and database into zip file.
103-
It can be used for backup and capture Gitea server image to send to maintainer`,
103+
It can be used for backup and capture Forgejo server image to send to maintainer`,
104104
Action: runDump,
105105
Flags: []cli.Flag{
106106
cli.StringFlag{
107107
Name: "file, f",
108-
Value: fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()),
108+
Value: fmt.Sprintf("forgejo-dump-%d.zip", time.Now().Unix()),
109109
Usage: "Name of the dump file which will be created. Supply '-' for stdout. See type for available types.",
110110
},
111111
cli.BoolFlag{
@@ -194,7 +194,7 @@ func runDump(ctx *cli.Context) error {
194194
}
195195
if !setting.InstallLock {
196196
log.Error("Is '%s' really the right config path?\n", setting.CustomConf)
197-
return fmt.Errorf("gitea is not initialized")
197+
return fmt.Errorf("forgejo is not initialized")
198198
}
199199
setting.LoadSettings() // cannot access session settings otherwise
200200

@@ -269,7 +269,7 @@ func runDump(ctx *cli.Context) error {
269269
fatal("Path does not exist: %s", tmpDir)
270270
}
271271

272-
dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql")
272+
dbDump, err := os.CreateTemp(tmpDir, "forgejo-db.sql")
273273
if err != nil {
274274
fatal("Failed to create tmp file: %v", err)
275275
}
@@ -291,8 +291,8 @@ func runDump(ctx *cli.Context) error {
291291
fatal("Failed to dump database: %v", err)
292292
}
293293

294-
if err := addFile(w, "gitea-db.sql", dbDump.Name(), verbose); err != nil {
295-
fatal("Failed to include gitea-db.sql: %v", err)
294+
if err := addFile(w, "forgejo-db.sql", dbDump.Name(), verbose); err != nil {
295+
fatal("Failed to include forgejo-db.sql: %v", err)
296296
}
297297

298298
if len(setting.CustomConf) > 0 {

cmd/serv.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ func runServ(c *cli.Context) error {
150150
}
151151
switch key.Type {
152152
case asymkey_model.KeyTypeDeploy:
153-
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
153+
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Forgejo does not provide shell access.")
154154
case asymkey_model.KeyTypePrincipal:
155-
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Gitea does not provide shell access.")
155+
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Forgejo does not provide shell access.")
156156
default:
157-
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
157+
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Forgejo does not provide shell access.")
158158
}
159-
println("If this is unexpected, please log in with password and setup Gitea under another user.")
159+
println("If this is unexpected, please log in with password and setup Forgejo under another user.")
160160
return nil
161161
} else if c.Bool("debug") {
162162
log.Debug("SSH_ORIGINAL_COMMAND: %s", os.Getenv("SSH_ORIGINAL_COMMAND"))

contrib/environment-to-ini/environment-to-ini.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2023 The Forgejo Authors. All rights reserved.
12
// Copyright 2019 The Gitea Authors. All rights reserved.
23
// SPDX-License-Identifier: MIT
34

@@ -18,17 +19,17 @@ import (
1819
)
1920

2021
// EnvironmentPrefix environment variables prefixed with this represent ini values to write
21-
const EnvironmentPrefix = "GITEA"
22+
const prefixRegexpString = "^(FORGEJO|GITEA)"
2223

2324
func main() {
2425
app := cli.NewApp()
2526
app.Name = "environment-to-ini"
2627
app.Usage = "Use provided environment to update configuration ini"
27-
app.Description = `As a helper to allow docker users to update the gitea configuration
28+
app.Description = `As a helper to allow docker users to update the forgejo configuration
2829
through the environment, this command allows environment variables to
2930
be mapped to values in the ini.
3031
31-
Environment variables of the form "GITEA__SECTION_NAME__KEY_NAME"
32+
Environment variables of the form "FORGEJO__SECTION_NAME__KEY_NAME"
3233
will be mapped to the ini section "[section_name]" and the key
3334
"KEY_NAME" with the value as provided.
3435
@@ -46,9 +47,8 @@ func main() {
4647
...
4748
"""
4849
49-
You would set the environment variables: "GITEA__LOG_0x2E_CONSOLE__COLORIZE=false"
50-
and "GITEA__LOG_0x2E_CONSOLE__STDERR=false". Other examples can be found
51-
on the configuration cheat sheet.`
50+
You would set the environment variables: "FORGEJO__LOG_0x2E_CONSOLE__COLORIZE=false"
51+
and "FORGEJO__LOG_0x2E_CONSOLE__STDERR=false".`
5252
app.Flags = []cli.Flag{
5353
cli.StringFlag{
5454
Name: "custom-path, C",
@@ -76,7 +76,7 @@ func main() {
7676
},
7777
cli.StringFlag{
7878
Name: "prefix, p",
79-
Value: EnvironmentPrefix,
79+
Value: prefixRegexpString,
8080
Usage: "Environment prefix to look for - will be suffixed by __ (2 underscores)",
8181
},
8282
}
@@ -89,6 +89,19 @@ func main() {
8989
}
9090
}
9191

92+
func splitEnvironmentVariable(prefixRegexp *regexp.Regexp, kv string) (string, string) {
93+
idx := strings.IndexByte(kv, '=')
94+
if idx < 0 {
95+
return "", ""
96+
}
97+
k := kv[:idx]
98+
loc := prefixRegexp.FindStringIndex(k)
99+
if loc == nil {
100+
return "", ""
101+
}
102+
return k[loc[1]:], kv[idx+1:]
103+
}
104+
92105
func runEnvironmentToIni(c *cli.Context) error {
93106
providedCustom := c.String("custom-path")
94107
providedConf := c.String("config")
@@ -111,19 +124,13 @@ func runEnvironmentToIni(c *cli.Context) error {
111124

112125
changed := false
113126

114-
prefix := c.String("prefix") + "__"
127+
prefixRegexp := regexp.MustCompile(c.String("prefix") + "__")
115128

116129
for _, kv := range os.Environ() {
117-
idx := strings.IndexByte(kv, '=')
118-
if idx < 0 {
130+
eKey, value := splitEnvironmentVariable(prefixRegexp, kv)
131+
if eKey == "" {
119132
continue
120133
}
121-
eKey := kv[:idx]
122-
value := kv[idx+1:]
123-
if !strings.HasPrefix(eKey, prefix) {
124-
continue
125-
}
126-
eKey = eKey[len(prefix):]
127134
sectionName, keyName := DecodeSectionKey(eKey)
128135
if len(keyName) == 0 {
129136
continue
@@ -163,14 +170,11 @@ func runEnvironmentToIni(c *cli.Context) error {
163170
}
164171
if c.Bool("clear") {
165172
for _, kv := range os.Environ() {
166-
idx := strings.IndexByte(kv, '=')
167-
if idx < 0 {
173+
eKey, _ := splitEnvironmentVariable(prefixRegexp, kv)
174+
if eKey == "" {
168175
continue
169176
}
170-
eKey := kv[:idx]
171-
if strings.HasPrefix(eKey, prefix) {
172-
_ = os.Unsetenv(eKey)
173-
}
177+
_ = os.Unsetenv(eKey)
174178
}
175179
}
176180
return nil
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2023 The Forgejo Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package main
5+
6+
import (
7+
"regexp"
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func Test_splitEnvironmentVariable(t *testing.T) {
14+
prefixRegexp := regexp.MustCompile(prefixRegexpString + "__")
15+
k, v := splitEnvironmentVariable(prefixRegexp, "FORGEJO__KEY=VALUE")
16+
assert.Equal(t, k, "KEY")
17+
assert.Equal(t, v, "VALUE")
18+
k, v = splitEnvironmentVariable(prefixRegexp, "nothing=interesting")
19+
assert.Equal(t, k, "")
20+
assert.Equal(t, v, "")
21+
}

0 commit comments

Comments
 (0)