Skip to content

Commit 758cf64

Browse files
author
Loïc Dachary
committed
Merge remote-tracking branch 'forgejo/v1.18/forgejo-branding' into v1.18/forgejo
2 parents b63a871 + f1f7c11 commit 758cf64

Some content is hidden

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

60 files changed

+919
-152
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:

Makefile

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

161162
TEST_MYSQL_HOST ?= mysql:3306
162163
TEST_MYSQL_DBNAME ?= testgitea
@@ -331,6 +332,7 @@ $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
331332
$(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
332333
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
333334
$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
335+
$(SED_INPLACE) '$(SWAGGER_SPEC_BRANDING)' './$(SWAGGER_SPEC)'
334336

335337
.PHONY: swagger-check
336338
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/serv.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ func runServ(c *cli.Context) error {
149149
}
150150
switch key.Type {
151151
case asymkey_model.KeyTypeDeploy:
152-
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
152+
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Forgejo does not provide shell access.")
153153
case asymkey_model.KeyTypePrincipal:
154-
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Gitea does not provide shell access.")
154+
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Forgejo does not provide shell access.")
155155
default:
156-
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
156+
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Forgejo does not provide shell access.")
157157
}
158-
println("If this is unexpected, please log in with password and setup Gitea under another user.")
158+
println("If this is unexpected, please log in with password and setup Forgejo under another user.")
159159
return nil
160160
} else if c.Bool("debug") {
161161
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
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
@@ -19,17 +20,17 @@ import (
1920
)
2021

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

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

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

113126
changed := false
114127

115-
prefix := c.String("prefix") + "__"
128+
prefixRegexp := regexp.MustCompile(c.String("prefix") + "__")
116129

117130
for _, kv := range os.Environ() {
118-
idx := strings.IndexByte(kv, '=')
119-
if idx < 0 {
131+
eKey, value := splitEnvironmentVariable(prefixRegexp, kv)
132+
if eKey == "" {
120133
continue
121134
}
122-
eKey := kv[:idx]
123-
value := kv[idx+1:]
124-
if !strings.HasPrefix(eKey, prefix) {
125-
continue
126-
}
127-
eKey = eKey[len(prefix):]
128135
sectionName, keyName := DecodeSectionKey(eKey)
129136
if len(keyName) == 0 {
130137
continue
@@ -164,14 +171,11 @@ func runEnvironmentToIni(c *cli.Context) error {
164171
}
165172
if c.Bool("clear") {
166173
for _, kv := range os.Environ() {
167-
idx := strings.IndexByte(kv, '=')
168-
if idx < 0 {
174+
eKey, _ := splitEnvironmentVariable(prefixRegexp, kv)
175+
if eKey == "" {
169176
continue
170177
}
171-
eKey := kv[:idx]
172-
if strings.HasPrefix(eKey, prefix) {
173-
_ = os.Unsetenv(eKey)
174-
}
178+
_ = os.Unsetenv(eKey)
175179
}
176180
}
177181
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+
}

contrib/systemd/gitea.service renamed to contrib/systemd/forgejo.service

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=Gitea (Git with a cup of tea)
2+
Description=Forgejo (Beyond coding. We forge.)
33
After=syslog.target
44
After=network.target
55
###
@@ -25,21 +25,21 @@ After=network.target
2525
# If using socket activation for main http/s
2626
###
2727
#
28-
#After=gitea.main.socket
29-
#Requires=gitea.main.socket
28+
#After=forgejo.main.socket
29+
#Requires=forgejo.main.socket
3030
#
3131
###
32-
# (You can also provide gitea an http fallback and/or ssh socket too)
32+
# (You can also provide forgejo an http fallback and/or ssh socket too)
3333
#
34-
# An example of /etc/systemd/system/gitea.main.socket
34+
# An example of /etc/systemd/system/forgejo.main.socket
3535
###
3636
##
3737
## [Unit]
38-
## Description=Gitea Web Socket
39-
## PartOf=gitea.service
38+
## Description=Forgejo Web Socket
39+
## PartOf=forgejo.service
4040
##
4141
## [Socket]
42-
## Service=gitea.service
42+
## Service=forgejo.service
4343
## ListenStream=<some_port>
4444
## NoDelay=true
4545
##
@@ -55,28 +55,28 @@ RestartSec=2s
5555
Type=simple
5656
User=git
5757
Group=git
58-
WorkingDirectory=/var/lib/gitea/
59-
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
60-
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
61-
#RuntimeDirectory=gitea
62-
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
58+
WorkingDirectory=/var/lib/forgejo/
59+
# If using Unix socket: tells systemd to create the /run/forgejo folder, which will contain the forgejo.sock file
60+
# (manually creating /run/forgejo doesn't work, because it would not persist across reboots)
61+
#RuntimeDirectory=forgejo
62+
ExecStart=/usr/local/bin/forgejo web --config /etc/forgejo/app.ini
6363
Restart=always
64-
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
64+
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/forgejo
6565
# If you install Git to directory prefix other than default PATH (which happens
6666
# for example if you install other versions of Git side-to-side with
6767
# distribution version), uncomment below line and add that prefix to PATH
6868
# Don't forget to place git-lfs binary on the PATH below if you want to enable
6969
# Git LFS support
7070
#Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin
71-
# If you want to bind Gitea to a port below 1024, uncomment
72-
# the two values below, or use socket activation to pass Gitea its ports as above
71+
# If you want to bind Forgejo to a port below 1024, uncomment
72+
# the two values below, or use socket activation to pass Forgejo its ports as above
7373
###
7474
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
7575
#AmbientCapabilities=CAP_NET_BIND_SERVICE
7676
###
7777
# In some cases, when using CapabilityBoundingSet and AmbientCapabilities option, you may want to
78-
# set the following value to false to allow capabilities to be applied on gitea process. The following
79-
# value if set to true sandboxes gitea service and prevent any processes from running with privileges
78+
# set the following value to false to allow capabilities to be applied on Forgejo process. The following
79+
# value if set to true sandboxes Forgejo service and prevent any processes from running with privileges
8080
# in the host user namespace.
8181
###
8282
#PrivateUsers=false

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ USER = root
331331
;; SQLite Configuration
332332
;;
333333
;DB_TYPE = sqlite3
334-
;PATH= ; defaults to data/gitea.db
334+
;PATH= ; defaults to data/forgejo.db
335335
;SQLITE_TIMEOUT = ; Query timeout defaults to: 500
336336
;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
337337
;;

docker/root/etc/s6/gitea/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
2424
fi
2525

2626
# Substitute the environment variables in the template
27-
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
27+
APP_NAME=${APP_NAME:-"Forgejo: Beyond coding. We forge."} \
2828
RUN_MODE=${RUN_MODE:-"prod"} \
2929
DOMAIN=${DOMAIN:-"localhost"} \
3030
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \

0 commit comments

Comments
 (0)