Compare commits
568 commits
forgejo
...
bp-v7.0/fo
Author | SHA1 | Date | |
---|---|---|---|
|
f1301542b8 | ||
|
e17e330712 | ||
|
e04b490cf6 | ||
|
4e233dd190 | ||
|
4ad7c599e7 | ||
|
d462b6d495 | ||
|
4d0a5ea317 | ||
|
2df082393e | ||
|
baec3dc6b9 | ||
|
bad8e72bcd | ||
|
6827a4a669 | ||
|
e0cd813927 | ||
|
9b17f6fd24 | ||
|
9cd730a063 | ||
|
68d803aae4 | ||
|
b4d792d2a2 | ||
|
2f9be3e824 | ||
|
3b7ad8ef9e | ||
|
4cbfd383e9 | ||
|
d900842fd7 | ||
|
bcb473dd2a | ||
|
089afd4086 | ||
|
8da2acff43 | ||
|
35d5ef0649 | ||
|
8fc16691e0 | ||
|
e3dc128776 | ||
|
cb481411b7 | ||
|
af49331f38 | ||
|
42d4c16c37 | ||
|
7bd9597803 | ||
|
3bdf9eae01 | ||
|
ebf1ba683b | ||
|
4af90387d4 | ||
|
900381d6e9 | ||
|
6d9fe1db67 | ||
|
def21375b7 | ||
|
43303922a8 | ||
|
acbd44a186 | ||
|
9a7df535da | ||
|
215160ced6 | ||
|
3861a2c70c | ||
|
16debbc792 | ||
|
a215e9db30 | ||
|
60ee476b57 | ||
|
5a0059afd1 | ||
|
6bb1b001f9 | ||
|
4db698ce24 | ||
|
75554579a6 | ||
|
1890eda1b7 | ||
|
1fd1100ac9 | ||
|
50ef4ecefe | ||
|
6e17262567 | ||
|
37228ea080 | ||
|
8f99d82cf2 | ||
|
cef84d7abf | ||
|
9ac51ddeb7 | ||
|
d3b4f9d326 | ||
|
391e311bbe | ||
|
09b08bcf7c | ||
|
2459145150 | ||
|
1c99c289f6 | ||
|
287253ff7d | ||
|
855f95f7a2 | ||
|
269f7b76e0 | ||
|
b5c49a19d2 | ||
|
6771312133 | ||
|
07ad7dd8f6 | ||
|
6a472f90f8 | ||
|
f00123b893 | ||
|
0f61cb389a | ||
|
cbdef1792f | ||
|
ef4c6abbb9 | ||
|
0b01434aa3 | ||
|
487b2129aa | ||
|
b9674b3ee9 | ||
|
a5776cc883 | ||
|
972dd76eeb | ||
|
af32e3c09a | ||
|
ceb9d543b3 | ||
|
0d06f3c2dd | ||
|
b898370a04 | ||
|
7eb54dbfca | ||
|
055a403781 | ||
|
f7e9db75c4 | ||
|
4ecbb2ef1b | ||
|
7a8b2d8eb8 | ||
|
6bf1bcab57 | ||
|
4feb183d91 | ||
|
0f10d15dfa | ||
|
d877f18092 | ||
|
32a0e1e2b4 | ||
|
ab4570d0cb | ||
|
7c40672ddf | ||
|
aefe770255 | ||
|
40b639d2a0 | ||
|
3f9f6f1350 | ||
|
6de1f714f3 | ||
|
fa448e2293 | ||
|
161fca9007 | ||
|
08894a9335 | ||
|
56642554d1 | ||
|
10a9b6b806 | ||
|
6917b25ad3 | ||
|
37fc6cdaf6 | ||
|
65529bd334 | ||
|
d91839692f | ||
|
9934931f1f | ||
|
c6d2c18052 | ||
|
8f8d85da47 | ||
|
7e81775184 | ||
|
99bd29f02f | ||
|
e5f9482745 | ||
|
220594bacc | ||
|
1582b1e83a | ||
|
dbecdd2be2 | ||
|
98afc8fcdb | ||
|
679010f079 | ||
|
0dc681ed13 | ||
|
dc13eecc04 | ||
|
8a8718be4d | ||
|
50ac410e35 | ||
|
cbdf32126f | ||
|
1f08add260 | ||
|
8b86b6f1a0 | ||
|
564183bbbd | ||
|
9d6974d1f8 | ||
|
92867c76a7 | ||
|
186cb13b26 | ||
|
9673355bf3 | ||
|
0bba3e2158 | ||
|
6334a48043 | ||
|
ba1f73f550 | ||
|
00cfe9aef9 | ||
|
d8fda28dfc | ||
|
7afee47817 | ||
|
887c050ea3 | ||
|
9ba48419ba | ||
|
283b678146 | ||
|
b6be9fb901 | ||
|
767d292c83 | ||
|
8d3c6251a7 | ||
|
94ce24cf92 | ||
|
696ed328fb | ||
|
dd3487dbbf | ||
|
18249e58be | ||
|
f8a3482cdb | ||
|
da993b09ad | ||
|
6ae15bc15e | ||
|
f30c648037 | ||
|
248a5b8d7a | ||
|
5678e9ab20 | ||
|
a7124df0c5 | ||
|
abf40ee957 | ||
|
7be345f88e | ||
|
8b1d84797f | ||
|
ba0ed5823c | ||
|
e59f92dec8 | ||
|
10b919d3ca | ||
|
f45a6cb3b7 | ||
|
5b6a375d05 | ||
|
ac34a68a93 | ||
|
fcf85b12af | ||
|
2949bbcad1 | ||
|
b23d4ec4bb | ||
|
d758633c91 | ||
|
d449fcff0a | ||
|
a7400b1812 | ||
|
a6d31a30a2 | ||
|
4b79a98910 | ||
|
b917571d81 | ||
|
c91f7d3599 | ||
|
9d1ffeaf8d | ||
|
9db70035b1 | ||
|
ad0b97c7c2 | ||
|
61230e72b5 | ||
|
50b7009603 | ||
|
36b8e68eee | ||
|
f83ae0fad2 | ||
|
6f35a5ab90 | ||
|
0da02b9213 | ||
|
13892121e6 | ||
|
ad7bf760ac | ||
|
d6597b8f7a | ||
|
6069fcced6 | ||
|
4fa80332e9 | ||
|
2da615c37c | ||
|
78517f80bb | ||
|
16e7af48bd | ||
|
275f5326a1 | ||
|
dd8d3f5ebe | ||
|
04ce562f62 | ||
|
3178f1614a | ||
|
a64e000e42 | ||
|
86251afec6 | ||
|
cfbc52921e | ||
|
8915d65aa1 | ||
|
f874c5e978 | ||
|
75aa4c28f0 | ||
|
c3e5e9ffb8 | ||
|
e97ffdae6f | ||
|
67647d5f39 | ||
|
b15d2a6bc7 | ||
|
cd77a78a93 | ||
|
a1496ec0bc | ||
|
f69fc18980 | ||
|
1241ac9da5 | ||
|
023cd2ee90 | ||
|
54f875df46 | ||
|
b7efd1e1da | ||
|
0b7e2ba549 | ||
|
f4a61b3299 | ||
|
9df576d7b7 | ||
|
135764f244 | ||
|
0160acbc05 | ||
|
5f5d66624e | ||
|
6a3b0d1fc8 | ||
|
7857b80373 | ||
|
57cde25958 | ||
|
79a214668c | ||
|
35790985d2 | ||
|
554f3697fc | ||
|
5793e8687f | ||
|
5fc96c0356 | ||
|
af372ba127 | ||
|
4288238b1e | ||
|
fd59a255e6 | ||
|
a7570ce5ac | ||
|
8e304659c5 | ||
|
e072201830 | ||
|
d58b74d368 | ||
|
9860af7f39 | ||
|
966975a3e0 | ||
|
9cd8cd4874 | ||
|
1040683676 | ||
|
a37836f228 | ||
|
5083ea72fb | ||
|
f2628f91fe | ||
|
5f0ae00efc | ||
|
cbc9567f1d | ||
|
7e3ff68ba9 | ||
|
a1f29d9a0e | ||
|
21a853aac7 | ||
|
8b4ca4501a | ||
|
c932519946 | ||
|
b248181a99 | ||
|
87545c721b | ||
|
b47f7a80cf | ||
|
d01fc3e2f5 | ||
|
bdfca7c00d | ||
|
f341942feb | ||
|
85a73553c9 | ||
|
a134c0f172 | ||
|
f5d9d8cbd4 | ||
|
73c190af4c | ||
|
e947fa7acc | ||
|
bbd204c30c | ||
|
f58e0d8617 | ||
|
9eaabc077a | ||
|
196cef0221 | ||
|
8859a7f1a7 | ||
|
7316f23265 | ||
|
4eefb64b12 | ||
|
81cc944cda | ||
|
c7ba51518c | ||
|
4433cd9793 | ||
|
792764456c | ||
|
2072ff75e8 | ||
|
eefa820874 | ||
|
4777ba210f | ||
|
0a9bbdcfef | ||
|
d802a8c0cf | ||
|
0412657132 | ||
|
f31879069f | ||
|
6ad7758117 | ||
|
1d8316f278 | ||
|
cb4246ed57 | ||
|
f436cb86d4 | ||
|
d6689b88a8 | ||
|
141efd58df | ||
|
6724373288 | ||
|
9de4bebbf7 | ||
|
c044cb2de3 | ||
|
889469fb74 | ||
|
05523fc96f | ||
|
ce31e611e2 | ||
|
55447525f6 | ||
|
65ba5b924f | ||
|
b4ccfe1bc5 | ||
|
2c6fa1efd0 | ||
|
f569f4f5dc | ||
|
a1f56a159b | ||
|
b349f82a62 | ||
|
9641273b2b | ||
|
ae0615561a | ||
|
9c81060eb9 | ||
|
25ddcd4b40 | ||
|
aacc13fca8 | ||
|
67232bd44e | ||
|
129e91956e | ||
|
bc1f64e3bf | ||
|
2f54b76c5c | ||
|
59cfbf2070 | ||
|
ae128c617b | ||
|
99effab1eb | ||
|
4b0e8f227d | ||
|
7784a6c331 | ||
|
405162178b | ||
|
4db1b2fb96 | ||
|
c8017a2853 | ||
|
d81a814fe5 | ||
|
8956825bac | ||
|
261fc87673 | ||
|
989d35d748 | ||
|
145cac0865 | ||
|
ee500dacd0 | ||
|
515d71bffa | ||
|
0f72cd8508 | ||
|
430083ba46 | ||
|
a1bba9c547 | ||
|
1173663f17 | ||
|
335abbbc9d | ||
|
3fb1036156 | ||
|
9f192dc2e5 | ||
|
f83e55b1ca | ||
|
8f06a99c2c | ||
|
ec6b255c2c | ||
|
dd474b72df | ||
|
569b73e495 | ||
|
a1716fcdfc | ||
|
ef0ce374a5 | ||
|
757b7bd462 | ||
|
2879c15858 | ||
|
a0a6eb6c5c | ||
|
ee749c7916 | ||
|
74bc9e666f | ||
|
487242e043 | ||
|
e982f5f63b | ||
|
f49402273f | ||
|
fe09c8860a | ||
|
46f77eaf2b | ||
|
fb91390b48 | ||
|
4fe72284fc | ||
|
fa1b0d46c7 | ||
|
70b0c30def | ||
|
b25f2cf859 | ||
|
31ebee203b | ||
|
eeaf51ab1d | ||
|
8b54d38cbe | ||
|
01129b593f | ||
|
d4d3e89f18 | ||
|
952f4befa9 | ||
|
6ad8ed5da1 | ||
|
fb028c37b5 | ||
|
7dfe3fe2cb | ||
|
3f6f134260 | ||
|
deeb268e5d | ||
|
c5d6cb5b52 | ||
|
78944bb709 | ||
|
35b129e984 | ||
|
1b8fd7b17b | ||
|
ef0ab3cdaf | ||
|
5420b630f5 | ||
|
f075579c95 | ||
|
88b6164f84 | ||
|
dbf1d06ff6 | ||
|
bb7b211c0c | ||
|
aad193c4a6 | ||
|
caa6b4a34d | ||
|
9656408102 | ||
|
0c71afea31 | ||
|
fd5abfd244 | ||
|
89d751ef1b | ||
|
ce2b1643f9 | ||
|
e4f160eed2 | ||
|
50822f361e | ||
|
ce8bfa25fb | ||
|
5ab76ec570 | ||
|
62a925b758 | ||
|
fa06bf5e81 | ||
|
b203e535e5 | ||
|
fbaba7ed54 | ||
|
db56ccf993 | ||
|
d60152587c | ||
|
b519ae39d7 | ||
|
3344ef3511 | ||
|
60e28c9dda | ||
|
71efe9b8fc | ||
|
f1016e8ddd | ||
|
711838a4df | ||
|
666432d15b | ||
|
c63b347a0b | ||
|
01dc275a19 | ||
|
660e450e6d | ||
|
457370bfce | ||
|
373200e986 | ||
|
f3a4134049 | ||
|
a752d000ff | ||
|
4732cc82be | ||
|
9811e363bd | ||
|
82b2b9790e | ||
|
8a9b57500c | ||
|
294cb4f19b | ||
|
e83b6c7cd2 | ||
|
39bc868092 | ||
|
d9442b09b5 | ||
|
e40ab6d0bd | ||
|
b310027e55 | ||
|
94fc99c217 | ||
|
704df1ff28 | ||
|
89a748b368 | ||
|
d573c22a98 | ||
|
f4a2f439a9 | ||
|
b912e26e5f | ||
|
7ac46f1151 | ||
|
c98d61710e | ||
|
033f2a4a17 | ||
|
f7cc76598d | ||
|
0af1418e6e | ||
|
730c667122 | ||
|
7c23dfba46 | ||
|
de440f8b93 | ||
|
7bbb93b3b1 | ||
|
572019129e | ||
|
da1810b12c | ||
|
d4a4b4b4e3 | ||
|
328f694a33 | ||
|
52d217ec50 | ||
|
706a7ad41e | ||
|
5bde9555b1 | ||
|
8d8dce747a | ||
|
a070f28c81 | ||
|
1065ee4a60 | ||
|
3da5ad9a00 | ||
|
d2a7905d9d | ||
|
8e27c91df2 | ||
|
7aa0999c9f | ||
|
8ddfd26d97 | ||
|
12c28641ab | ||
|
3eab81fdea | ||
|
091400b656 | ||
|
aa7346c007 | ||
|
a2a833c5ac | ||
|
4a8eb1caa1 | ||
|
2236574d50 | ||
|
7e5fed7e29 | ||
|
1db55b1754 | ||
|
7df46a9b34 | ||
|
82b92c3f2c | ||
|
4ad42a4e3f | ||
|
be41258d5c | ||
|
fe8b34b8fc | ||
|
f5cd6339a8 | ||
|
68476e2494 | ||
|
04ea1aedc5 | ||
|
2ed0a56dd4 | ||
|
1f0e36f7ae | ||
|
af797534f8 | ||
|
5374cb6608 | ||
|
84d8c8b777 | ||
|
c65b9e0112 | ||
|
2024519bb4 | ||
|
279d1a85f0 | ||
|
2c263b2732 | ||
|
2bf3723939 | ||
|
cb0c6b52be | ||
|
bf275ac92f | ||
|
aefdf17a75 | ||
|
5b7d454dd8 | ||
|
fbaebbd644 | ||
|
139979f25d | ||
|
86d018dffc | ||
|
06e72e22d5 | ||
|
bc873f2e83 | ||
|
0f2e315b02 | ||
|
594c9c4570 | ||
|
f97a1ed948 | ||
|
11d50ab72e | ||
|
b74c8015f1 | ||
|
149efabe07 | ||
|
ccc51051c5 | ||
|
f3ea363dd2 | ||
|
41d87998d7 | ||
|
64bbd545a2 | ||
|
db1a36673e | ||
|
b068d193d0 | ||
|
4ef8b139f2 | ||
|
e3c46541bd | ||
|
0d4daa9455 | ||
|
5c3dff26d6 | ||
|
3a46a37586 | ||
|
0a086dffc0 | ||
|
648da47046 | ||
|
5fdadbfe08 | ||
|
858fbbaafd | ||
|
4d2cd6c806 | ||
|
713ac6f5d5 | ||
|
0e2e21b584 | ||
|
585e6137f7 | ||
|
71e63f541d | ||
|
c0fb79b436 | ||
|
6051722460 | ||
|
f3ce65a3fc | ||
|
96b2ec888a | ||
|
f3b6759ab7 | ||
|
2b8d95c8c2 | ||
|
470886bf52 | ||
|
d2cd1342bf | ||
|
e5212c8c96 | ||
|
24552ee9ee | ||
|
7b24b669ed | ||
|
482658a4d0 | ||
|
a89e146cb0 | ||
|
7befc34e68 | ||
|
69d9d66dda | ||
|
11feddc21d | ||
|
b4f566fdf5 | ||
|
5a23ce083d | ||
|
ba4f17b1d9 | ||
|
f25d2ce223 | ||
|
57b19874b8 | ||
|
46eeb884b4 | ||
|
0abf358c94 | ||
|
2937333e2d | ||
|
7b97ea7154 | ||
|
59e42fee1c | ||
|
e13854c305 | ||
|
71153ef8b4 | ||
|
7db4e374ca | ||
|
2e5aa42f20 | ||
|
7a783c3132 | ||
|
029bcd361a | ||
|
1a0c9df87f | ||
|
ce74e66b95 | ||
|
cf460b8b5f | ||
|
4706b644f8 | ||
|
b6dccc0fd4 | ||
|
966faddee4 | ||
|
c01935e9d0 | ||
|
22aedc6c96 | ||
|
4dd475dfe5 | ||
|
923035e418 | ||
|
9ecd041975 | ||
|
9f80081795 | ||
|
4cb3f331a2 | ||
|
fd8f51f2b6 | ||
|
e628d0e54b | ||
|
ece5c97931 | ||
|
b9dbd93ebc | ||
|
66d1cd89d1 | ||
|
45f39ce839 | ||
|
f0a2da40ff | ||
|
60a82b0890 | ||
|
6b560544fb | ||
|
4a4bd75989 | ||
|
84eeab59af | ||
|
7f03fdf9f9 | ||
|
6b2d02528f | ||
|
92acbb0a8e | ||
|
5503db386e | ||
|
005a9c7850 | ||
|
d0dccaec66 | ||
|
ea0e8caa6f | ||
|
9b4d32446c | ||
|
ce5f1b942f | ||
|
e428231b38 | ||
|
03df59ec95 | ||
|
a1bce73f5c | ||
|
19f7eb657b |
858 changed files with 20499 additions and 44519 deletions
|
@ -66,6 +66,7 @@ package "code.gitea.io/gitea/models/migrations/base"
|
||||||
func MainTest
|
func MainTest
|
||||||
|
|
||||||
package "code.gitea.io/gitea/models/organization"
|
package "code.gitea.io/gitea/models/organization"
|
||||||
|
func GetTeamNamesByID
|
||||||
func UpdateTeamUnits
|
func UpdateTeamUnits
|
||||||
func (SearchMembersOptions).ToConds
|
func (SearchMembersOptions).ToConds
|
||||||
func UsersInTeamsCount
|
func UsersInTeamsCount
|
||||||
|
@ -131,6 +132,7 @@ package "code.gitea.io/gitea/models/user"
|
||||||
func GetUserAllSettings
|
func GetUserAllSettings
|
||||||
func DeleteUserSetting
|
func DeleteUserSetting
|
||||||
func GetUserEmailsByNames
|
func GetUserEmailsByNames
|
||||||
|
func GetUserNamesByIDs
|
||||||
|
|
||||||
package "code.gitea.io/gitea/modules/activitypub"
|
package "code.gitea.io/gitea/modules/activitypub"
|
||||||
func CurrentTime
|
func CurrentTime
|
||||||
|
@ -177,7 +179,6 @@ package "code.gitea.io/gitea/modules/git"
|
||||||
func (ErrExecTimeout).Error
|
func (ErrExecTimeout).Error
|
||||||
func (ErrUnsupportedVersion).Error
|
func (ErrUnsupportedVersion).Error
|
||||||
func SetUpdateHook
|
func SetUpdateHook
|
||||||
func GetObjectFormatOfRepo
|
|
||||||
func openRepositoryWithDefaultContext
|
func openRepositoryWithDefaultContext
|
||||||
func IsTagExist
|
func IsTagExist
|
||||||
func ToEntryMode
|
func ToEntryMode
|
||||||
|
@ -295,6 +296,7 @@ package "code.gitea.io/gitea/modules/translation"
|
||||||
func (MockLocale).TrString
|
func (MockLocale).TrString
|
||||||
func (MockLocale).Tr
|
func (MockLocale).Tr
|
||||||
func (MockLocale).TrN
|
func (MockLocale).TrN
|
||||||
|
func (MockLocale).TrSize
|
||||||
func (MockLocale).PrettyNumber
|
func (MockLocale).PrettyNumber
|
||||||
|
|
||||||
package "code.gitea.io/gitea/modules/util/filebuffer"
|
package "code.gitea.io/gitea/modules/util/filebuffer"
|
||||||
|
@ -312,8 +314,6 @@ package "code.gitea.io/gitea/routers/web"
|
||||||
|
|
||||||
package "code.gitea.io/gitea/routers/web/org"
|
package "code.gitea.io/gitea/routers/web/org"
|
||||||
func MustEnableProjects
|
func MustEnableProjects
|
||||||
func getActionIssues
|
|
||||||
func UpdateIssueProject
|
|
||||||
|
|
||||||
package "code.gitea.io/gitea/services/context"
|
package "code.gitea.io/gitea/services/context"
|
||||||
func GetPrivateContext
|
func GetPrivateContext
|
||||||
|
@ -341,5 +341,4 @@ package "code.gitea.io/gitea/services/repository/files"
|
||||||
|
|
||||||
package "code.gitea.io/gitea/services/webhook"
|
package "code.gitea.io/gitea/services/webhook"
|
||||||
func NewNotifier
|
func NewNotifier
|
||||||
func List
|
|
||||||
|
|
||||||
|
|
|
@ -26,3 +26,6 @@ indent_style = tab
|
||||||
|
|
||||||
[*.svg]
|
[*.svg]
|
||||||
insert_final_newline = false
|
insert_final_newline = false
|
||||||
|
|
||||||
|
[options/locale/locale_*.ini]
|
||||||
|
insert_final_newline = false
|
||||||
|
|
2
.forgejo/testdata/build-release/Dockerfile
vendored
2
.forgejo/testdata/build-release/Dockerfile
vendored
|
@ -1,4 +1,6 @@
|
||||||
FROM code.forgejo.org/oci/alpine:3.19
|
FROM code.forgejo.org/oci/alpine:3.19
|
||||||
ARG RELEASE_VERSION=unkown
|
ARG RELEASE_VERSION=unkown
|
||||||
|
LABEL maintainer="contact@forgejo.org" \
|
||||||
|
org.opencontainers.image.version="${RELEASE_VERSION}"
|
||||||
RUN mkdir -p /app/gitea
|
RUN mkdir -p /app/gitea
|
||||||
RUN ( echo '#!/bin/sh' ; echo "echo forgejo v$RELEASE_VERSION" ) > /app/gitea/gitea ; chmod +x /app/gitea/gitea
|
RUN ( echo '#!/bin/sh' ; echo "echo forgejo v$RELEASE_VERSION" ) > /app/gitea/gitea ; chmod +x /app/gitea/gitea
|
||||||
|
|
|
@ -33,22 +33,18 @@ jobs:
|
||||||
if: >
|
if: >
|
||||||
!startsWith(vars.ROLE, 'forgejo-') && (
|
!startsWith(vars.ROLE, 'forgejo-') && (
|
||||||
github.event.pull_request.merged
|
github.event.pull_request.merged
|
||||||
&& (
|
&&
|
||||||
(
|
|
||||||
github.event.action == 'closed' &&
|
|
||||||
contains(toJSON(github.event.pull_request.labels), 'backport/v')
|
contains(toJSON(github.event.pull_request.labels), 'backport/v')
|
||||||
)
|
)
|
||||||
||
|
|
||||||
(
|
|
||||||
github.event.action == 'labeled' &&
|
|
||||||
contains(github.event.label.name, 'backport/v')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: 'docker.io/node:20-bookworm'
|
image: 'docker.io/node:20-bookworm'
|
||||||
steps:
|
steps:
|
||||||
|
- name: event info
|
||||||
|
run: |
|
||||||
|
cat <<'EOF'
|
||||||
|
${{ toJSON(github) }}
|
||||||
|
EOF
|
||||||
- name: Fetch labels
|
- name: Fetch labels
|
||||||
id: fetch-labels
|
id: fetch-labels
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -159,7 +159,7 @@ jobs:
|
||||||
|
|
||||||
- name: build container & release
|
- name: build container & release
|
||||||
if: ${{ secrets.TOKEN != '' }}
|
if: ${{ secrets.TOKEN != '' }}
|
||||||
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v3
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1.1
|
||||||
with:
|
with:
|
||||||
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
||||||
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
||||||
|
@ -173,11 +173,12 @@ jobs:
|
||||||
binary-name: forgejo
|
binary-name: forgejo
|
||||||
binary-path: /app/gitea/gitea
|
binary-path: /app/gitea/gitea
|
||||||
override: "${{ steps.release-info.outputs.override }}"
|
override: "${{ steps.release-info.outputs.override }}"
|
||||||
|
verify-labels: "maintainer=contact@forgejo.org,org.opencontainers.image.version=${{ steps.release-info.outputs.version }}"
|
||||||
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
|
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
|
||||||
|
|
||||||
- name: build rootless container
|
- name: build rootless container
|
||||||
if: ${{ secrets.TOKEN != '' }}
|
if: ${{ secrets.TOKEN != '' }}
|
||||||
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v3
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1.1
|
||||||
with:
|
with:
|
||||||
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
||||||
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
||||||
|
@ -190,6 +191,7 @@ jobs:
|
||||||
suffix: -rootless
|
suffix: -rootless
|
||||||
dockerfile: Dockerfile.rootless
|
dockerfile: Dockerfile.rootless
|
||||||
override: "${{ steps.release-info.outputs.override }}"
|
override: "${{ steps.release-info.outputs.override }}"
|
||||||
|
verify-labels: "maintainer=contact@forgejo.org,org.opencontainers.image.version=${{ steps.release-info.outputs.version }}"
|
||||||
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
|
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
|
||||||
|
|
||||||
- name: end-to-end tests
|
- name: end-to-end tests
|
||||||
|
|
|
@ -42,7 +42,7 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: copy & sign
|
- name: copy & sign
|
||||||
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/publish@v4
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/publish@v5
|
||||||
with:
|
with:
|
||||||
from-forgejo: ${{ vars.FORGEJO }}
|
from-forgejo: ${{ vars.FORGEJO }}
|
||||||
to-forgejo: ${{ vars.FORGEJO }}
|
to-forgejo: ${{ vars.FORGEJO }}
|
||||||
|
|
|
@ -14,6 +14,11 @@ jobs:
|
||||||
container:
|
container:
|
||||||
image: 'docker.io/node:20-bookworm'
|
image: 'docker.io/node:20-bookworm'
|
||||||
steps:
|
steps:
|
||||||
|
- name: event info
|
||||||
|
run: |
|
||||||
|
cat <<'EOF'
|
||||||
|
${{ toJSON(github) }}
|
||||||
|
EOF
|
||||||
- uses: https://code.forgejo.org/actions/checkout@v3
|
- uses: https://code.forgejo.org/actions/checkout@v3
|
||||||
- uses: https://code.forgejo.org/actions/setup-go@v4
|
- uses: https://code.forgejo.org/actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
||||||
[submodule "manual-testing"]
|
|
||||||
path = manual-testing
|
|
||||||
url = https://codeberg.org/forgejo/forgejo-manual-testing
|
|
8355
CHANGELOG.md
8355
CHANGELOG.md
File diff suppressed because it is too large
Load diff
|
@ -4,21 +4,4 @@ The Forgejo project is run by a community of people who are expected to follow t
|
||||||
|
|
||||||
Sensitive security-related issues should be reported to [security@forgejo.org](mailto:security@forgejo.org) using [encryption](https://keyoxide.org/security@forgejo.org).
|
Sensitive security-related issues should be reported to [security@forgejo.org](mailto:security@forgejo.org) using [encryption](https://keyoxide.org/security@forgejo.org).
|
||||||
|
|
||||||
## For everyone involved
|
You can find links to the different aspects of Developer documentation on this page: [Forgejo developer guide](https://forgejo.org/docs/next/developer/).
|
||||||
|
|
||||||
- [Documentation](https://forgejo.org/docs/next/)
|
|
||||||
- [Code of Conduct](https://forgejo.org/docs/latest/developer/coc/)
|
|
||||||
- [Bugs, features, security and others discussions](https://forgejo.org/docs/latest/developer/discussions/)
|
|
||||||
- [Governance](https://forgejo.org/docs/latest/developer/governance/)
|
|
||||||
- [Sustainability and funding](https://codeberg.org/forgejo/sustainability/src/branch/main/README.md)
|
|
||||||
|
|
||||||
## For contributors
|
|
||||||
|
|
||||||
- [Developer Certificate of Origin (DCO)](https://forgejo.org/docs/latest/developer/dco/)
|
|
||||||
- [Development workflow](https://forgejo.org/docs/latest/developer/workflow/)
|
|
||||||
- [Compiling from source](https://forgejo.org/docs/latest/developer/from-source/)
|
|
||||||
|
|
||||||
## For maintainers
|
|
||||||
|
|
||||||
- [Release management](https://forgejo.org/docs/latest/developer/release/)
|
|
||||||
- [Secrets](https://forgejo.org/docs/latest/developer/secrets/)
|
|
||||||
|
|
12
Dockerfile
12
Dockerfile
|
@ -52,7 +52,17 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
|
||||||
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
|
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
|
||||||
|
|
||||||
FROM docker.io/library/alpine:3.19
|
FROM docker.io/library/alpine:3.19
|
||||||
LABEL maintainer="contact@forgejo.org"
|
ARG RELEASE_VERSION
|
||||||
|
LABEL maintainer="contact@forgejo.org" \
|
||||||
|
org.opencontainers.image.authors="Forgejo" \
|
||||||
|
org.opencontainers.image.url="https://forgejo.org" \
|
||||||
|
org.opencontainers.image.documentation="https://forgejo.org/download/#container-image" \
|
||||||
|
org.opencontainers.image.source="https://codeberg.org/forgejo/forgejo" \
|
||||||
|
org.opencontainers.image.version="${RELEASE_VERSION}" \
|
||||||
|
org.opencontainers.image.vendor="Forgejo" \
|
||||||
|
org.opencontainers.image.licenses="MIT" \
|
||||||
|
org.opencontainers.image.title="Forgejo. Beyond coding. We forge." \
|
||||||
|
org.opencontainers.image.description="Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job."
|
||||||
|
|
||||||
EXPOSE 22 3000
|
EXPOSE 22 3000
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,16 @@ RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
|
||||||
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
|
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
|
||||||
|
|
||||||
FROM docker.io/library/alpine:3.19
|
FROM docker.io/library/alpine:3.19
|
||||||
LABEL maintainer="contact@forgejo.org"
|
LABEL maintainer="contact@forgejo.org" \
|
||||||
|
org.opencontainers.image.authors="Forgejo" \
|
||||||
|
org.opencontainers.image.url="https://forgejo.org" \
|
||||||
|
org.opencontainers.image.documentation="https://forgejo.org/download/#container-image" \
|
||||||
|
org.opencontainers.image.source="https://codeberg.org/forgejo/forgejo" \
|
||||||
|
org.opencontainers.image.version="${RELEASE_VERSION}" \
|
||||||
|
org.opencontainers.image.vendor="Forgejo" \
|
||||||
|
org.opencontainers.image.licenses="MIT" \
|
||||||
|
org.opencontainers.image.title="Forgejo. Beyond coding. We forge." \
|
||||||
|
org.opencontainers.image.description="Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job."
|
||||||
|
|
||||||
EXPOSE 2222 3000
|
EXPOSE 2222 3000
|
||||||
|
|
||||||
|
|
21
Makefile
21
Makefile
|
@ -27,7 +27,7 @@ DIFF ?= diff --unified
|
||||||
XGO_VERSION := go-1.21.x
|
XGO_VERSION := go-1.21.x
|
||||||
|
|
||||||
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0
|
AIR_PACKAGE ?= github.com/cosmtrek/air@v1.49.0
|
||||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
|
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@2.8.0
|
||||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
|
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
|
||||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
|
||||||
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
||||||
|
@ -82,15 +82,20 @@ endif
|
||||||
STORED_VERSION_FILE := VERSION
|
STORED_VERSION_FILE := VERSION
|
||||||
HUGO_VERSION ?= 0.111.3
|
HUGO_VERSION ?= 0.111.3
|
||||||
|
|
||||||
GITEA_COMPATIBILITY ?= gitea-1.22.0
|
GITEA_COMPATIBILITY ?= gitea-1.21.11
|
||||||
|
|
||||||
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
|
||||||
ifneq ($(STORED_VERSION),)
|
ifneq ($(STORED_VERSION),)
|
||||||
FORGEJO_VERSION ?= $(STORED_VERSION)
|
FORGEJO_VERSION ?= $(STORED_VERSION)
|
||||||
|
else
|
||||||
|
ifneq ($(GITEA_VERSION),)
|
||||||
|
FORGEJO_VERSION ?= $(GITEA_VERSION)
|
||||||
|
FORGEJO_VERSION_API ?= $(GITEA_VERSION)+${GITEA_COMPATIBILITY}
|
||||||
else
|
else
|
||||||
# drop the "g" prefix prepended by git describe to the commit hash
|
# drop the "g" prefix prepended by git describe to the commit hash
|
||||||
FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//' | sed 's/\-g/-/')+${GITEA_COMPATIBILITY}
|
FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//' | sed 's/\-g/-/')+${GITEA_COMPATIBILITY}
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
FORGEJO_VERSION_MAJOR=$(shell echo $(FORGEJO_VERSION) | sed -e 's/\..*//')
|
FORGEJO_VERSION_MAJOR=$(shell echo $(FORGEJO_VERSION) | sed -e 's/\..*//')
|
||||||
FORGEJO_VERSION_MINOR=$(shell echo $(FORGEJO_VERSION) | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/')
|
FORGEJO_VERSION_MINOR=$(shell echo $(FORGEJO_VERSION) | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||||
|
|
||||||
|
@ -106,12 +111,16 @@ show-version-minor:
|
||||||
RELEASE_VERSION ?= ${FORGEJO_VERSION}
|
RELEASE_VERSION ?= ${FORGEJO_VERSION}
|
||||||
VERSION ?= ${RELEASE_VERSION}
|
VERSION ?= ${RELEASE_VERSION}
|
||||||
|
|
||||||
LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(FORGEJO_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION)"
|
FORGEJO_VERSION_API ?= ${FORGEJO_VERSION}
|
||||||
|
|
||||||
|
show-version-api:
|
||||||
|
@echo ${FORGEJO_VERSION_API}
|
||||||
|
|
||||||
|
LDFLAGS := $(LDFLAGS) -X "main.ReleaseVersion=$(RELEASE_VERSION)" -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(FORGEJO_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION_API)"
|
||||||
|
|
||||||
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
|
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
|
||||||
|
|
||||||
ifeq ($(HAS_GO), yes)
|
ifeq ($(HAS_GO), yes)
|
||||||
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
|
|
||||||
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) $(shell $(GO) list code.gitea.io/gitea/models/forgejo_migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
|
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) $(shell $(GO) list code.gitea.io/gitea/models/forgejo_migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -447,7 +456,7 @@ lint-go-windows:
|
||||||
.PHONY: lint-go-vet
|
.PHONY: lint-go-vet
|
||||||
lint-go-vet:
|
lint-go-vet:
|
||||||
@echo "Running go vet..."
|
@echo "Running go vet..."
|
||||||
@$(GO) vet $(GO_PACKAGES)
|
@$(GO) vet ./...
|
||||||
|
|
||||||
.PHONY: lint-editorconfig
|
.PHONY: lint-editorconfig
|
||||||
lint-editorconfig:
|
lint-editorconfig:
|
||||||
|
@ -813,7 +822,7 @@ generate-backend: $(TAGS_PREREQ) generate-go
|
||||||
.PHONY: generate-go
|
.PHONY: generate-go
|
||||||
generate-go: $(TAGS_PREREQ)
|
generate-go: $(TAGS_PREREQ)
|
||||||
@echo "Running go generate..."
|
@echo "Running go generate..."
|
||||||
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
|
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' ./...
|
||||||
|
|
||||||
.PHONY: merge-locales
|
.PHONY: merge-locales
|
||||||
merge-locales:
|
merge-locales:
|
||||||
|
|
628
RELEASE-NOTES.md
628
RELEASE-NOTES.md
|
@ -1,8 +1,632 @@
|
||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
A Forgejo release is published shortly after a Gitea release is published and they have [matching release numbers](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/CONTRIBUTING/RELEASE.md#release-numbering). Additional Forgejo releases may be published to address urgent security issues or bug fixes.
|
A minor or major Forgejo release is published every [three months](https://forgejo.org/docs/latest/user/versions/), with more patch releases in between depending on the severity of the bug and security fixes it contains.
|
||||||
|
|
||||||
The Forgejo admin should carefully read the required manual actions before upgrading. A point release (e.g. v1.21.1-0 or v1.21.2-0) does not require manual actions but others might (e.g. v1.20, v1.21).
|
A [patch or minor release](https://semver.org/spec/v2.0.0.html) (e.g. upgrading from v7.0.0 to v7.0.1 or v7.1.0) does not require manual intervention. But [major releases](https://semver.org/spec/v2.0.0.html#spec-item-8) where the first version number changes (e.g. upgrading from v1.21 to v7.0) contain breaking changes and the release notes explain how to deal with them.
|
||||||
|
|
||||||
|
## 7.0.3
|
||||||
|
|
||||||
|
This is a security release. See the documentation for more information on the [upgrade procedure](https://forgejo.org/docs/v7.0/admin/upgrade/).
|
||||||
|
|
||||||
|
In addition to the following notable bug fixes, you can browse the [full list of commits](https://codeberg.org/forgejo/forgejo/compare/v7.0.2...v7.0.3) included in this release.
|
||||||
|
|
||||||
|
* Container image upgrades
|
||||||
|
|
||||||
|
In the Forgejo v7.0.3 container images, the Git version was upgraded to [2.43.4](https://pkgs.alpinelinux.org/packages?name=git&branch=v3.19) which includes fixes for [multiple vulnerabilities](https://github.blog/2024-05-14-securing-git-addressing-5-new-vulnerabilities/). However, the vulnerabilities with a high impact can be exploited when Git is used in an environment (or Operating Systems) which is different from the Forgejo OCI image.
|
||||||
|
|
||||||
|
* **Security:**
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3673). Fixed: [CVE-2024-24788](https://pkg.go.dev/vuln/GO-2024-2824): a malformed DNS message in response to a query can cause the lookup functions to get stuck in an infinite loop.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3802). Fixed: backticks in [mermaid](https://mermaid.js.org/) block diagram labels [are not sanitized properly](https://github.com/mermaid-js/mermaid/commit/c7fe9a646574597adefe3e6fb2b3707112a151aa).
|
||||||
|
|
||||||
|
* **Bug fixes:**
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3588). Fixed: migration of a repository from gogs fails when it is hosted at a subpath.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3591). Fixed: when creating an OAuth2 application the redirect URLs are not enforced to be mandatory.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3659). Fixed: the API incorrectly excludes repositories where code is not enabled.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3677). Fixed: "Allow edits from maintainers" cannot be modified via the pull request web UI.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3687). Fixed: repository activity feeds (including RSS and Atom feeds) contain repeated activities.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3705). Fixed: uploading maven packages with metadata being uploaded separately will fail.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3751). Fixed: the mail notification sent about commits pushed to pull requests are empty.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3753). Fixed: inline emails attachments are not properly handled when commenting on an issue via email.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3760). Fixed: the links to .zip and tar.gz on the tag list web UI fail.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3767). Fixed: expanding code diff while previewing a pull request before it is created fails.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3772). Fixed: the CLI is not able to migrate Forgejo Actions artifacts.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3772). Fixed: when adopting a repository, the default branch is not taken into account.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3772). Fixed: when using reverse proxy authentication, logout will not be taken into account when immediately trying to login afterwards.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3788). Fixed: pushing to the master branch of a sha256 repository fails.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3827). Fixed: a very long project column name will make the action menu inaccessible.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3842). Fixed: a useless error is displayed when the title of a merged pull request is modified.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3846). Fixed: workflow badges are not working for workflows that are not running on push (such as scheduled workflows, and ones that run on tags and pull requests).
|
||||||
|
|
||||||
|
* **Localization:**
|
||||||
|
* Improvements to English locale: [[1]](https://codeberg.org/forgejo/forgejo/pulls/3825), [[2]](https://codeberg.org/forgejo/forgejo/pulls/3750), [[3]](https://codeberg.org/forgejo/forgejo/pulls/3742), [[4]](https://codeberg.org/forgejo/forgejo/pulls/3674), [[5]](https://codeberg.org/forgejo/forgejo/pulls/3641).
|
||||||
|
* Translation updates: [[1]](https://codeberg.org/forgejo/forgejo/pulls/3852), [[2]](https://codeberg.org/forgejo/forgejo/pulls/3749), [[3]](https://codeberg.org/forgejo/forgejo/pulls/3740), [[4]](https://codeberg.org/forgejo/forgejo/pulls/3631).
|
||||||
|
|
||||||
|
* Gitea v1.21 compatibility
|
||||||
|
|
||||||
|
This section is for information only and does not require any action.
|
||||||
|
|
||||||
|
The semantic version of the Forgejo 7.0 releases are:
|
||||||
|
|
||||||
|
* `v7.0.0+gitea-1.22.0`
|
||||||
|
* `v7.0.1+gitea-1.22.0`
|
||||||
|
* `v7.0.2+gitea-1.22.0`
|
||||||
|
* `v7.0.3+gitea-1.21.11`
|
||||||
|
|
||||||
|
Gitea v1.22 is [not published yet](https://github.com/go-gitea/gitea/issues/30731) as of 21 May 2024 and in reality all Forgejo v7.0 releases are compatible with Gitea v1.21.11. Advertising they will be compatible with an unpublished Gitea version was incorrect. The Gitea v1.22 release was anticipated to happen shortly after [Forgejo v7.0 was published on 23 April 2024](https://forgejo.org/2024-04-release-v7-0/) because it was already in the late stages of its release candidate lifecycle. However, around 27 April, [the Gitea release candidates were dropped](https://github.com/go-gitea/gitea/issues/30501) and the release candidates restarted from the Gitea development branch.
|
||||||
|
|
||||||
|
## 7.0.2
|
||||||
|
|
||||||
|
This is a bug fix release. See the documentation for more information on the [upgrade procedure](https://forgejo.org/docs/v7.0/admin/upgrade/).
|
||||||
|
|
||||||
|
In addition to the following notable bug fixes, you can browse the [full list of commits](https://codeberg.org/forgejo/forgejo/compare/v7.0.1...v7.0.2) included in this release.
|
||||||
|
|
||||||
|
* **Bug fixes:**
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3562): a v7.0.0 regression where subscribing to or unsubscribing from an issue in a repository with no code produced an internal server error.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/issues/3559): a v7.0.0 regression makes all the refs sent in Gitea webhooks to be full refs and might break Woodpecker CI pipelines triggered on tag (`CI_COMMIT_TAG` contained the full ref). This issue [has been fixed](https://github.com/woodpecker-ci/woodpecker/pull/3664) in the `main` branch of Woodpecker CI as well.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3555): the webhook branch filter wrongly applied the match on the full ref for branch creation and deletion (wrongly skipping events).
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3537): toggling the WIP state of a pull request is possible from the sidebar, but not from the footer.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3565): when mentioning a user, the markup post-processor does not handle the case where the mentioned user does not exist: it tries to skip to the next node, which in turn, ended up skipping the rest of the line.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3570): excessive and unnecessary database queries when a user with no repositories is viewing their dashboard.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3580): duplicate status check contexts show in the branch protection settings.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3497): profile info fails to render german singular translation.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3504): inline attachments of [incoming emails](https://forgejo.org/docs/v7.0/user/incoming/) (as they occur for example with Apple Mail) are not attached to comments.
|
||||||
|
|
||||||
|
## 7.0.1
|
||||||
|
|
||||||
|
This is a bug fix release. See the documentation for more information on the [upgrade procedure](https://forgejo.org/docs/v7.0/admin/upgrade/).
|
||||||
|
|
||||||
|
In addition to the following notable bug fixes, you can browse the [full list of commits](https://codeberg.org/forgejo/forgejo/compare/v7.0.0...v7.0.1) included in this release.
|
||||||
|
|
||||||
|
* **Bug fixes:**
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3466): LFS data corruption when running the [`forgejo doctor check --fix`](https://forgejo.org/docs/v7.0/admin/command-line/#doctor-check) CLI command or setting [`[cron.gc_lfs].ENABLED=true`](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#cron---garbage-collect-lfs-pointers-in-repositories-crongc_lfs) (the default is `false`).
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3412): [non backward compatible change](https://codeberg.org/forgejo/forgejo/issues/3399) in the [`forgejo admin user create`](https://forgejo.org/docs/v7.0/admin/command-line/#admin-user-create) CLI command.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3448): error 500 because of an incorrect evaluation of the template when visiting the LFS settings of a repository.
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3464): `GET /repos/{owner}/{name}` API endpoint [always returns an empty string for the `object_format_name` field](https://codeberg.org/forgejo/forgejo/issues/3458).
|
||||||
|
* [PR](https://codeberg.org/forgejo/forgejo/pulls/3444): fuzzy search [may fail with bleve](https://codeberg.org/forgejo/forgejo/issues/3443).
|
||||||
|
|
||||||
|
## 7.0.0
|
||||||
|
|
||||||
|
The [complete list of commits](https://codeberg.org/forgejo/forgejo/commits/branch/v7.0/forgejo) included in the `Forgejo v7.0.0` release can be reviewed from the command line with:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ git clone https://codeberg.org/forgejo/forgejo/
|
||||||
|
$ git -C forgejo log --oneline --no-merges origin/v1.21/forgejo..origin/v7.0/forgejo
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Regressions and workarounds:**
|
||||||
|
* Running the [`forgejo doctor check --fix`](https://forgejo.org/docs/v7.0/admin/command-line/#doctor-check) CLI command or setting [`[cron.gc_lfs].ENABLED=true`](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#cron---garbage-collect-lfs-pointers-in-repositories-crongc_lfs) (the default is `false`) will corrupt the LFS storage. The workaround is to not run the doctor CLI command and disable the `cron.gc_lfs`. This regression will be [fixed in 7.0.1](https://codeberg.org/forgejo/forgejo/issues/3438).
|
||||||
|
* The [`forgejo admin user create`](https://forgejo.org/docs/v7.0/admin/command-line/#admin-user-create) CLI command [requires a password](https://codeberg.org/forgejo/forgejo/commit/b122c6ef8b9254120432aed373cbe075331132ac) change by default when creating the first user and the `--admin` flag is not specified. The `--must-change-password=false` argument must be given to not require a password change. This regression will be [fixed in 7.0.1](https://codeberg.org/forgejo/forgejo/issues/3399).
|
||||||
|
* **Breaking changes requiring manual intervention:**
|
||||||
|
* [Forgejo webhooks](https://codeberg.org/forgejo/forgejo/issues/3055) now always send full refs (starting with `refs/`) instead of sending short refs in some cases. This new behavior may require changes when the receiving end assumes a short ref will be received (for instance some versions of Woodpecker CI when receiving webhook payloads when a tag is set).
|
||||||
|
* [MySQL 8.0 or PostgreSQL 12](https://codeberg.org/forgejo/forgejo/commit/e94f9fcafdcf284561e7fb33f60156a69c4ad6a5) are the minimum supported versions. The database must be migrated before upgrading. The requirements regarding SQLite did not change.
|
||||||
|
* The `per_page` parameter is [no longer a synonym for `limit`](https://codeberg.org/forgejo/forgejo/commit/0aab2d38a7d91bc8caff332e452364468ce52d9a) in the [/repos/{owner}/{repo}/releases](https://code.forgejo.org/api/swagger/#/repository/repoListReleases) API endpoint.
|
||||||
|
* The date format of the `created` and `last_update` fields of the [`/repos/{owner}/{repo}/push_mirrors`](https://code.forgejo.org/api/swagger/#/repository/repoListPushMirrors) and [/repos/{owner}/{repo}/push_mirrors](https://code.forgejo.org/api/swagger/#/repository/repoAddPushMirror) API endpoint changed [to be timestamps instead of numbers](https://codeberg.org/forgejo/forgejo/commit/0ee7cbf725f45650136be45f8e0f74d395f73b5c).
|
||||||
|
* Labels used [by pprof endpoint](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#server-server) have been changed:
|
||||||
|
* `graceful-lifecycle` to `gracefulLifecycle`
|
||||||
|
* `process-type` to `processType`
|
||||||
|
* `process-description` to `processDescription`
|
||||||
|
This allows for those endpoints to be scraped by services requiring prometheus style labels such as [grafana-agent](https://grafana.com/docs/agent/latest/).
|
||||||
|
* The repository description [imposes additional restrictions on what it contains](https://codeberg.org/forgejo/forgejo/commit/1075ff74b5050f671c5f9824ae39390230b3c85d) to prevent abuse. You may use [the v7.0 test instance](https://v7.next.forgejo.org/) to check how it will be modified.
|
||||||
|
* The [Gitea themes were renamed](https://codeberg.org/forgejo/forgejo/commit/023e937141dd891bce3370c869d4db2c60f971ed) and the `[ui].THEMES` setting must be changed as follows:
|
||||||
|
* `gitea` is replaced by `gitea-light`
|
||||||
|
* `arc-green` is replaced by `gitea-dark`
|
||||||
|
* `auto` is replaced by `gitea-auto`
|
||||||
|
* **Breaking changes in the user interface:**
|
||||||
|
Note that the modifications related to CSS, templates or assets (images, fonts, etc.) are not documented here.
|
||||||
|
Although they can be extracted and modified, Forgejo does not provide any guarantee that such changes
|
||||||
|
will be portable from one version to another (even a patch version). See also
|
||||||
|
[the developer documentation about interface customization](https://forgejo.org/docs/v7.0/developer/customization/).
|
||||||
|
* [Update checker setting might change](https://codeberg.org/forgejo/forgejo/pulls/2925). The documentation was listing it as enabled by default, however, for a while it was disabled unless it was explicitly specified in the config or on the installation page. Instances migrated from Gitea also had it disabled due to different default value. Since then Forgejo got a privacy-friendly DNS-based update checking mechanism which is now being enabled by default unless explicitly specified [in the config](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#cron---check-for-new-forgejo-versions-cronupdate_checker).
|
||||||
|
* Language statistics for repositories that use `linguist` attributes in `.gitattributes` *may* show different statistics than previously, because Forgejo recognizes more [linguist attributes](https://forgejo.org/docs/v7.0/user/language-detection/) now.
|
||||||
|
* It is [no longer possible to replace the default web editor](https://codeberg.org/forgejo/forgejo/pulls/2916) used to write comments or issues and pull requests with the EasyMDE editor. It is however still available as an alternative to edit releases and wiki pages.
|
||||||
|
* [The list of all repositories and the `New Issue` button are no longer available in the user dashboard](https://codeberg.org/forgejo/forgejo/commit/beb71f5ef6e8074dc744ac995c15f7b5947a3f2e) for issues and pull requests.
|
||||||
|
* **Migration warning**
|
||||||
|
* If the logs show a line like the following, [run doctor convert](https://forgejo.org/docs/v7.0/admin/command-line/#doctor-convert) to fix it.
|
||||||
|
```
|
||||||
|
[W] Current database is using a case-insensitive collation "utf8mb4_general_ci"
|
||||||
|
```
|
||||||
|
* Large instances may experience slow migrations when the database is upgraded to support SHA-256 git repositories. For instance, here are the logs from a test migration of the https://codeberg.org production database:
|
||||||
|
```
|
||||||
|
[I] Migration[286]: Add support for SHA256 git repositories
|
||||||
|
[W] [Slow SQL Query] ALTER TABLE `commit_status` MODIFY COLUMN `context_hash` VARCHAR(64) [] - 3m41.647738396s
|
||||||
|
[W] [Slow SQL Query] ALTER TABLE `comment` MODIFY COLUMN `commit_sha` VARCHAR(64) [] - 1m5.500234133s
|
||||||
|
[W] [Slow SQL Query] ALTER TABLE `release` MODIFY COLUMN `sha1` VARCHAR(64) [] - 22.06241145s
|
||||||
|
```
|
||||||
|
* **Features and enhancements**
|
||||||
|
* Repository settings have been refactored, lifting out the repository unit-related settings to their own page. ([#2221](https://codeberg.org/forgejo/forgejo/pulls/2221))
|
||||||
|
- When additional units can be enabled, an "Add more..." link will be displayed for repository admins. This can be turned off. ([#2533](https://codeberg.org/forgejo/forgejo/pulls/2533))
|
||||||
|
* Repository administrators can [allow anyone to edit the wiki](https://forgejo.org/docs/v7.0/user/wiki/#activation-and-permissions) in the repository Settings. ([#2001](https://codeberg.org/forgejo/forgejo/pulls/2001))
|
||||||
|
* Instance administrators can enable [repository badges](https://forgejo.org/docs/v7.0/user/readme-badges/) in the [configuration file](https://forgejo.org/docs/v7.0/admin/config-cheat-sheet/#badges-badges). This feature depends on a shield generator service such as shields.io, and is disabled by default. ([#2070](https://codeberg.org/forgejo/forgejo/pulls/2070))
|
||||||
|
* Instance administrators can configure the additional clone methods displayed on the repository home view. ([gitea#29320](https://github.com/go-gitea/gitea/pull/29320))
|
||||||
|
* Instance administrators can [assign custom flags to repositories](https://codeberg.org/forgejo/forgejo/pulls/2079). This is disabled by default, and currently requires custom templates to do anything useful with the flags. ([#2079](https://codeberg.org/forgejo/forgejo/pulls/2079) & [#2097](https://codeberg.org/forgejo/forgejo/pulls/2097))
|
||||||
|
* Fallback for [basic repo search using git-grep](https://forgejo.org/docs/v7.0/user/code-search/) when code indexer is disabled ([gitea#29998](https://github.com/go-gitea/gitea/pull/29998))
|
||||||
|
* Repository administrators can disable forking instance-wide by setting the new `[repository].DISABLE_FORKS` setting. ([#2445](https://codeberg.org/forgejo/forgejo/pulls/2445))
|
||||||
|
* Render permalinks to files with a line range by an inline preview in all places where markup is allowed ([#2669](https://codeberg.org/forgejo/forgejo/pulls/2669))
|
||||||
|
* A user can now optionally set their preferred pronouns ([#1518](https://codeberg.org/forgejo/forgejo/pulls/1518)).
|
||||||
|
* [Always enable caches](https://codeberg.org/forgejo/forgejo/commit/e7cb8da2a8310ac167b6f613b283caa3316a7154).
|
||||||
|
* Forgejo now recognizes more [linguist attributes](https://forgejo.org/docs/v7.0/user/language-detection/), making it possible to include documentation in the repository language statistics, for example. ([#2088](https://codeberg.org/forgejo/forgejo/pulls/2088))
|
||||||
|
* When displaying the message to open a pull request from a recently pushed branch, the recently pushed branch now links to the appropriate branch. ([#2141](https://codeberg.org/forgejo/forgejo/pulls/2141))
|
||||||
|
* Users who signed up, but have not activated their accounts yet, are now able to [change their email before activation](https://codeberg.org/forgejo/forgejo/pulls/1891). ([#1891](https://codeberg.org/forgejo/forgejo/pulls/1891))
|
||||||
|
* The "You pushed on branch ...." banner is now displayed for repositories you have a fork of with recently pushed branches too ([#2195](https://codeberg.org/forgejo/forgejo/pulls/2195)), and it will no longer consider branches that share no history with the default branch. ([#2196](https://codeberg.org/forgejo/forgejo/pulls/2196))
|
||||||
|
* Forgejo will now highlight signed tags in a similar way it highlights signed commits. ([#2534](https://codeberg.org/forgejo/forgejo/pulls/2534))
|
||||||
|
* Forgejo gained support for the more recent GitHub-style alert blocks. ([#2348](https://codeberg.org/forgejo/forgejo/pulls/2348))
|
||||||
|
- The older style remains supported too.
|
||||||
|
* [[ACTIONS] Add vars context to cron jobs](https://codeberg.org/forgejo/forgejo/pulls/3059)
|
||||||
|
* [[ACTIONS] Allow viewing the latest Action Run on the web](https://codeberg.org/forgejo/forgejo/pulls/1900)
|
||||||
|
* [[AGIT] Automatically fill in the description](https://codeberg.org/forgejo/forgejo/pulls/2344)
|
||||||
|
* [[API] Add API to get PR by base/head](https://codeberg.org/forgejo/forgejo/pulls/2481)
|
||||||
|
* [[API] commentAssignment() to verify the id belongs](https://codeberg.org/forgejo/forgejo/pulls/2126)
|
||||||
|
* [[API] DELETE /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}](https://codeberg.org/forgejo/forgejo/pulls/2157)
|
||||||
|
* [[API] endpoint for adding comments to reviews](https://codeberg.org/forgejo/forgejo/pulls/2122)
|
||||||
|
* [[API] GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}](https://codeberg.org/forgejo/forgejo/pulls/2127)
|
||||||
|
* [[API] support for repository flags](https://codeberg.org/forgejo/forgejo/pulls/2097)
|
||||||
|
* [[I18N] Clarify description in deletion modal](https://codeberg.org/forgejo/forgejo/pulls/2488)
|
||||||
|
* [[I18N] Clarify the description of SSH Keys](https://codeberg.org/forgejo/forgejo/pulls/2393)
|
||||||
|
* [[I18N] Data size unit localization](https://codeberg.org/forgejo/forgejo/pulls/2528)
|
||||||
|
* [[I18N] Improve branch select list ui in go templates (gitea#29729)](https://codeberg.org/forgejo/forgejo/pulls/2744)
|
||||||
|
* [[I18N] Improve localization of repo summary](https://codeberg.org/forgejo/forgejo/pulls/2756)
|
||||||
|
* [[I18N] Improve registration / password reset emails](https://codeberg.org/forgejo/forgejo/pulls/2529)
|
||||||
|
* [[I18N] Use correct translations for pull request](https://codeberg.org/forgejo/forgejo/pulls/2260)
|
||||||
|
* [[I18N] Improve translatability of activity heatmap](https://codeberg.org/forgejo/forgejo/pulls/2612)
|
||||||
|
* [[I18N] Improve English locale for admin settings](https://codeberg.org/forgejo/forgejo/pulls/2583)
|
||||||
|
* [I18N] Add plural support: [1](https://codeberg.org/forgejo/forgejo/pulls/2614), [2](https://codeberg.org/forgejo/forgejo/pulls/2695), [3](https://codeberg.org/forgejo/forgejo/pulls/2954), [4](https://codeberg.org/forgejo/forgejo/pulls/3031)
|
||||||
|
* [I18N] General improvements to English locale: [1](https://codeberg.org/forgejo/forgejo/pulls/2307), [2](https://codeberg.org/forgejo/forgejo/pulls/2437), [3](https://codeberg.org/forgejo/forgejo/pulls/2492), [4](https://codeberg.org/forgejo/forgejo/pulls/2610), [5](https://codeberg.org/forgejo/forgejo/pulls/2703), [6](https://codeberg.org/forgejo/forgejo/pulls/2941).
|
||||||
|
* [[I18N] Allow custom repo size format](https://codeberg.org/forgejo/forgejo/pulls/2974)
|
||||||
|
* [[PACKAGES] nuget basic manifest download](https://codeberg.org/forgejo/forgejo/pulls/2222)
|
||||||
|
* [[UI] Add label filters in organization issues dashboard](https://codeberg.org/forgejo/forgejo/pulls/2944)
|
||||||
|
* [[UI] Allow users to hide all "Add more units..." hints](https://codeberg.org/forgejo/forgejo/pulls/2533)
|
||||||
|
* [[UI] Display tag name as title for a tag with no release [gitea]](https://codeberg.org/forgejo/forgejo/pulls/2547)
|
||||||
|
* [[UI] Enable ambiguous character detection in configured contexts](https://codeberg.org/forgejo/forgejo/pulls/2427)
|
||||||
|
* [[UI] Improve display of 404/500 error pages](https://codeberg.org/forgejo/forgejo/pulls/2466)
|
||||||
|
* [[UI] Improve look of user profiles](https://codeberg.org/forgejo/forgejo/pulls/2875)
|
||||||
|
* [[UI] Include a branch link in the recently pushed banner](https://codeberg.org/forgejo/forgejo/pulls/2141)
|
||||||
|
* [[UI] Offer to remove WIP: prefix in sidebar](https://codeberg.org/forgejo/forgejo/pulls/2660)
|
||||||
|
* [[UI] Port console colors](https://codeberg.org/forgejo/forgejo/pulls/2419)
|
||||||
|
* [[UI] pulls "Edit File" button in "Files Changed" tab](https://codeberg.org/forgejo/forgejo/pulls/1992)
|
||||||
|
* [[UI] Remove add organization on dashboard switcher](https://codeberg.org/forgejo/forgejo/pulls/2895)
|
||||||
|
* [[UI] Restrict file size of blame operation](https://codeberg.org/forgejo/forgejo/pulls/2395)
|
||||||
|
* [[UI] Show follow symlink button](https://codeberg.org/forgejo/forgejo/pulls/2530)
|
||||||
|
* [[UI] split code conversations in diff tab](https://codeberg.org/forgejo/forgejo/pulls/2306)
|
||||||
|
* [[UI] Update look of repo/org tabs on homepage](https://codeberg.org/forgejo/forgejo/pulls/2593)
|
||||||
|
* [[UI] Visual separation between types of attachments](https://codeberg.org/forgejo/forgejo/pulls/2899)
|
||||||
|
* [[UI] [AGIT] Add AGit label to AGit-created PRs](https://codeberg.org/forgejo/forgejo/pulls/2444)
|
||||||
|
* [[UI] [AGIT] Add link to docs and tooltip to label](https://codeberg.org/forgejo/forgejo/pulls/2499)
|
||||||
|
* [Implement commit mail selection for other Git operations](https://codeberg.org/forgejo/forgejo/pulls/2383)
|
||||||
|
* [Improved Linguist compatibility](https://codeberg.org/forgejo/forgejo/pulls/2088)
|
||||||
|
* [improve nuget nuspec api](https://codeberg.org/forgejo/forgejo/pulls/2996)
|
||||||
|
* [Log SQL queries when the database return error](https://codeberg.org/forgejo/forgejo/pulls/2140)
|
||||||
|
* [New doctor check: fix-push-mirrors-without-git-remote](https://codeberg.org/forgejo/forgejo/pulls/1853)
|
||||||
|
* [New route to view latest run of specific workflows](https://codeberg.org/forgejo/forgejo/pulls/2304)
|
||||||
|
* [Check for Commit in opengraph](https://codeberg.org/forgejo/forgejo/pulls/2094)
|
||||||
|
* [Check if commit is already present in target branch](https://codeberg.org/forgejo/forgejo/pulls/2450)
|
||||||
|
* [Configure if protected branch rule should apply to admins](https://codeberg.org/forgejo/forgejo/pulls/2867)
|
||||||
|
* [Count downloads for tag archives](https://codeberg.org/forgejo/forgejo/pulls/2976)
|
||||||
|
* [depguard sha256-simd](https://codeberg.org/forgejo/forgejo/pulls/2234)
|
||||||
|
* [Don't consider orphan branches as recently pushed](https://codeberg.org/forgejo/forgejo/pulls/2196)
|
||||||
|
* [extend webfinger to respond to profile page URIs](https://codeberg.org/forgejo/forgejo/pulls/2883)
|
||||||
|
* [Highlight signed tags like signed commits](https://codeberg.org/forgejo/forgejo/pulls/2534)
|
||||||
|
* [Allow changing the email address before activation](https://codeberg.org/forgejo/forgejo/pulls/1891)
|
||||||
|
* [Allow changing the repo Wiki branch to main](https://codeberg.org/forgejo/forgejo/pulls/2264)
|
||||||
|
* [Allow forking without a repo ID](https://codeberg.org/forgejo/forgejo/pulls/2310)
|
||||||
|
* [Allow instance-wide disabling of forking](https://codeberg.org/forgejo/forgejo/pulls/2445)
|
||||||
|
* [Allow non-explicit push options](https://codeberg.org/forgejo/forgejo/pulls/2984)
|
||||||
|
* [Allow to exclude files in dump](https://codeberg.org/forgejo/forgejo/pulls/2876)
|
||||||
|
* [add bucket lookup type](https://codeberg.org/forgejo/forgejo/pulls/2482)
|
||||||
|
* [Add download URL for executable files](https://codeberg.org/forgejo/forgejo/pulls/1839)
|
||||||
|
* [Add gitignore template for Janet projects](https://codeberg.org/forgejo/forgejo/pulls/2557)
|
||||||
|
* [add optional storage init to doctor commands](https://codeberg.org/forgejo/forgejo/pulls/3034)
|
||||||
|
* [Add rel="nofollow" to issue filter links](https://codeberg.org/forgejo/forgejo/pulls/2367)
|
||||||
|
* [Add support for shields.io-based badges](https://codeberg.org/forgejo/forgejo/pulls/2070)
|
||||||
|
* [Add Zig gitignore](https://codeberg.org/forgejo/forgejo/pulls/2352)
|
||||||
|
* [Recognize SSH signed tags too](https://codeberg.org/forgejo/forgejo/pulls/2520)
|
||||||
|
* [Repository flags](https://codeberg.org/forgejo/forgejo/pulls/2079)
|
||||||
|
* [support `.forgejo` dir for issue and PR templates](https://codeberg.org/forgejo/forgejo/pulls/2290)
|
||||||
|
* [Support Include/Exclude Filters for Grep](https://codeberg.org/forgejo/forgejo/pulls/3058)
|
||||||
|
* [Use 'Text' instead of 'Plaintext'](https://codeberg.org/forgejo/forgejo/pulls/2833)
|
||||||
|
* [Render code tags in commit messages](https://codeberg.org/forgejo/forgejo/commit/3ccb0c2512cb551943945aaa3f2bd0b1e2abd3b8).
|
||||||
|
* [Refactor markdown attention render](https://codeberg.org/forgejo/forgejo/commit/ec2201a3da5f18e55bfc0a54114ac935804f4ef8).
|
||||||
|
* [Add default board to new projects, remove uncategorized pseudo-board](https://codeberg.org/forgejo/forgejo/commit/8ffb9c6fb1571a1221978440f108911057df25db).
|
||||||
|
* [Add more stats tables](https://codeberg.org/forgejo/forgejo/commit/926367fe1d778fe7c9f5bc6b8e8c514b619ef038).
|
||||||
|
* [Improve branch select list ui in go templates](https://codeberg.org/forgejo/forgejo/commit/729849a2fd026adbb91e3ff3259290f61bd919f0).
|
||||||
|
* [Update allowed attachment types](https://codeberg.org/forgejo/forgejo/commit/04b79bb48b490644c46e58da46af4b62a40e5e03).
|
||||||
|
* [Completely style the webkit autofill](https://codeberg.org/forgejo/forgejo/commit/9916f3ed64a715fb9a31a0fcad6452276e275615).
|
||||||
|
* [Set user's 24h preference from their current OS locale](https://codeberg.org/forgejo/forgejo/commit/427ab550a6a35e7369bc1b33a188bb3030c32ec0).
|
||||||
|
* [Make wiki default branch name changeable](https://codeberg.org/forgejo/forgejo/commit/7ea8993a0e342e7a30cb2da03216697b4819935a).
|
||||||
|
* [Make admin pages wider because of left sidebar added and some tables become too narrow](https://codeberg.org/forgejo/forgejo/commit/145bebc829c03cbb078e518d7364d27bcf60d96c).
|
||||||
|
* [Make PR form use toast to show error message](https://codeberg.org/forgejo/forgejo/commit/221a28436a080447f429fa2089d264e56f4980e2).
|
||||||
|
* [Rename Action.GetDisplayName to GetActDisplayName](https://codeberg.org/forgejo/forgejo/commit/be9189eddc84e942710b16b1c8c54c10aad01b63).
|
||||||
|
* [Unify search boxes](https://codeberg.org/forgejo/forgejo/commit/847f03b6a65ee251bf764f54f6114737346a43b6).
|
||||||
|
* [Detect broken git hooks](https://codeberg.org/forgejo/forgejo/commit/963df8290784d82385f7e8ad9f5c9abfd2fa2860).
|
||||||
|
* [Filter for default-branch selection](https://codeberg.org/forgejo/forgejo/commit/1090734255d70deb9886de2c1a8bb971096223ee).
|
||||||
|
* [Include resource state events in Gitlab downloads](https://codeberg.org/forgejo/forgejo/commit/bc7a247b9ea68643e3c59d4b4376dea097ffcc68).
|
||||||
|
* [Properly migrate target branch change GitLab comment](https://codeberg.org/forgejo/forgejo/commit/f0acc71ba13713f07602294b4a33028125343d47).
|
||||||
|
* [Recolor dark theme to blue shade](https://codeberg.org/forgejo/forgejo/commit/ff581d5a2415f7a3321fa6ba656ae0e972674d6c).
|
||||||
|
* [Unify organizations header](https://codeberg.org/forgejo/forgejo/commit/4b494d341f3142c066bc5b2b3cfd50f924d64fd3).
|
||||||
|
* [Auto-update the system status in admin dashboard](https://codeberg.org/forgejo/forgejo/commit/4f050f358a15dd51903e01b330a5419b2ac06693).
|
||||||
|
* [Show more settings for empty repositories](https://codeberg.org/forgejo/forgejo/commit/b03af9efb275f935bb265c7f031225caaafefaff).
|
||||||
|
* [Downscale pasted PNG images based on metadata](https://codeberg.org/forgejo/forgejo/commit/b3f2447bc4b6a7220da748cc6eb24bd5568bee7c).
|
||||||
|
* [Show `View at this point in history` for every commit](https://codeberg.org/forgejo/forgejo/commit/27bc2b9d9597de89d2c6b68581c6729bb16a4572).
|
||||||
|
* [Drop "@" from email sender to avoid spam filters](https://codeberg.org/forgejo/forgejo/commit/9a1d5c549cb6d32219647ea1a771b8a82d5ac89f).
|
||||||
|
* [Allow non-admin users to delete review requests](https://codeberg.org/forgejo/forgejo/commit/77c56e29ded5665bdc09d0a568159aa7127b44b1).
|
||||||
|
* [Some performance optimization on dashboard and issues page](https://codeberg.org/forgejo/forgejo/commit/d996c5d5179c99855e69156a034eca055e9329a4).
|
||||||
|
* [Improve user search display name](https://codeberg.org/forgejo/forgejo/commit/c3e462921ee31536e59b37e654ed20e92a37ffe6).
|
||||||
|
* [Fix UI Spacing Errors in mirror settings](https://codeberg.org/forgejo/forgejo/commit/64faecefe10613840709a68c1b8b708115d69d6e).
|
||||||
|
* [Include username in email headers](https://codeberg.org/forgejo/forgejo/commit/360b3fd17c3315ad9ad9c4e6ac02eda73f48d8ae).
|
||||||
|
* [Also match weakly validated ETags](https://codeberg.org/forgejo/forgejo/commit/28fe3db1fb0f89bcb55829ced33c1282f85f6e97).
|
||||||
|
* [Propagate install_if and provider_priority to APKINDEX](https://codeberg.org/forgejo/forgejo/commit/2da233ad8be107de29190720f1c30199410fe0cd).
|
||||||
|
* [Fix display latest sync time for pull mirrors on the repo page](https://codeberg.org/forgejo/forgejo/commit/4674aea25b54baf08594c54f061dee9e44190f02).
|
||||||
|
* [Remove trust model selection from repository creation on web page because it can be changed in settings later](https://codeberg.org/forgejo/forgejo/commit/c08d263a1900aa5ee92f56af8ad1c7a2697d02e1).
|
||||||
|
* [Add ability to see open and closed issues at the same time](https://codeberg.org/forgejo/forgejo/commit/2c3da59e275b69ebf984bb70954f42a7bcb0b49d).
|
||||||
|
* [Move sign in labels to be above inputs](https://codeberg.org/forgejo/forgejo/commit/4af0944b2604dd2b2e413864492135faea097298).
|
||||||
|
* [Move the captcha script loader to the template which really needs it](https://codeberg.org/forgejo/forgejo/commit/a04f8c0f81f55a8b927ce0fad8127db39396f892).
|
||||||
|
* [Display latest sync time for pull mirrors on the repo page](https://codeberg.org/forgejo/forgejo/commit/2d343f8987025015f5b61e328cc9e45082e6d3f2).
|
||||||
|
* [Show in Web UI if file is vendored and generated](https://codeberg.org/forgejo/forgejo/commit/7ed18566e10b298309dcc99d97447cb1932ae09a).
|
||||||
|
* [Add orphaned topic consistency check](https://codeberg.org/forgejo/forgejo/commit/e02095c5b6e04f70ae6562f5aee169f7ee93cf7a).
|
||||||
|
* [Convert to url auth to header auth in tests](https://codeberg.org/forgejo/forgejo/commit/838db2f8911690fa2115c6827ed73687db71bef1).
|
||||||
|
* [Add option to set language in admin user view](https://codeberg.org/forgejo/forgejo/commit/318634ef74dc0a9c285991692e72d3df90b8583c).
|
||||||
|
* [Fix incorrect run order of action jobs](https://codeberg.org/forgejo/forgejo/commit/f4561c44b1cad700bf41537eb4db487fff34f6c9).
|
||||||
|
* [Add missing exclusive in advanced label options](https://codeberg.org/forgejo/forgejo/commit/77506c6f6cbfa5c15d8373743415f47b2adb404d).
|
||||||
|
* [Add combined index for issue_user.uid and issue_id](https://codeberg.org/forgejo/forgejo/commit/e08f1a9cbd582c73918e401eeba36261627f44a7).
|
||||||
|
* [Add edit option for README.md](https://codeberg.org/forgejo/forgejo/commit/08552f0076204b99258f9135c77a962c302521dc).
|
||||||
|
* [Fix link to `Code` tab on wiki commits](https://codeberg.org/forgejo/forgejo/commit/709a376c518d0cfde10bb911b32fd0ea82c67b52).
|
||||||
|
* [Remove autofocus in search box](https://codeberg.org/forgejo/forgejo/commit/eae555ff2395cc1ad178f3a977d83742ae73e1d9).
|
||||||
|
* [Allow to set explore page default sort](https://codeberg.org/forgejo/forgejo/commit/16ba16dbe951763cfc026b7351e26009d1a25fdc).
|
||||||
|
* [Improve PR diff view on mobile](https://codeberg.org/forgejo/forgejo/commit/49dddd87b19aebe83e1c54a455e62529a19f61b4).
|
||||||
|
* [Properly migrate automatic merge GitLab comments](https://codeberg.org/forgejo/forgejo/commit/542badbb76408c17ce6692e99fff680bee69face).
|
||||||
|
* [Display issue task list on project cards](https://codeberg.org/forgejo/forgejo/commit/4776fde9e1caa7cee5671715144a668e19a0323c).
|
||||||
|
* [Add Index to pull_auto_merge.doer_id](https://codeberg.org/forgejo/forgejo/commit/c8602a8dfa05f653e7de8ed2e677c8967b8688f5).
|
||||||
|
* [Fix display member unit in the menu bar if there are no hidden members in public org](https://codeberg.org/forgejo/forgejo/commit/0e021cd33ee3eb3d8f204bd075e2597b7ec8b391).
|
||||||
|
* [List all Debian package versions in `Packages`](https://codeberg.org/forgejo/forgejo/commit/b36e2ca4195298d2e4516e3022b953543f62f470).
|
||||||
|
* [Allow pull requests Manually Merged option to be used by non-admins](https://codeberg.org/forgejo/forgejo/commit/1756e30e102d079f8425aa2061ef80fd36c2e57d).
|
||||||
|
* [Only show diff file tree when more than one file changed](https://codeberg.org/forgejo/forgejo/commit/572f0963edc71239634ee782a3c69213479f34ba).
|
||||||
|
* [Show placeholder email in privacy popup](https://codeberg.org/forgejo/forgejo/commit/31f8880bc252a25075f8752e2722b316c6e46ec7).
|
||||||
|
* [Revamp repo header](https://codeberg.org/forgejo/forgejo/commit/7d62615513b8985360de497e9a051b51ca0faaf2).
|
||||||
|
* [Add link to members and repositories at teams page](https://codeberg.org/forgejo/forgejo/commit/4f4ddcf3c593b474846d40e47b4351d3deb39202).
|
||||||
|
* [Add link for repositories README file](https://codeberg.org/forgejo/forgejo/commit/7210f23fa0f11da093b307029d7ab91ed40807fb).
|
||||||
|
* [Add `must-change-password` cli parameter](https://codeberg.org/forgejo/forgejo/commit/9bea276055edc9527e3d6d66df3bbf0d20326f8b).
|
||||||
|
* [Unify password changing and invalidate auth tokens](https://codeberg.org/forgejo/forgejo/commit/688d4a1f719d2df4d2626453f4bc042c1874a375).
|
||||||
|
* [Add slow SQL query warning](https://codeberg.org/forgejo/forgejo/commit/664192767c41b9d0759bcc3915c7bd6ccecc52ae).
|
||||||
|
* [Pre-register OAuth application for tea](https://codeberg.org/forgejo/forgejo/commit/a825cc0f3423f0a5c8157c436a0c7b489ef536c1).
|
||||||
|
* [Differentiate between `push` and `pull` `mirror sync in progress`](https://codeberg.org/forgejo/forgejo/commit/e709bc199fe33456c4ecd1cd28029bd31b529832).
|
||||||
|
* [Cargo package - Fix missing domain in cargo sparse url](https://codeberg.org/forgejo/forgejo/commit/a112cf34d391cc04770021f9ffaa29e383cb9d51).
|
||||||
|
* [Link to file from its history](https://codeberg.org/forgejo/forgejo/commit/33de64cb21505259338e393ef0d15ccb0f757475).
|
||||||
|
* [Add a shortcut to user's profile page to admin user details](https://codeberg.org/forgejo/forgejo/commit/e96e440b8bde5516ffc7bba42691e26084a96588).
|
||||||
|
* [Doctor: delete action entries without existing user](https://codeberg.org/forgejo/forgejo/commit/15fa0383fb5dd9ad1702dbc34ba7100c0cdbcc8c).
|
||||||
|
* [Add anchor to review types](https://codeberg.org/forgejo/forgejo/commit/89c9a498fdd6184df8afda8b5b488462e65b9e71).
|
||||||
|
* [Show total TrackedTime on issue/pull/milestone lists](https://codeberg.org/forgejo/forgejo/commit/adbc995c347e158a56264f2488997d7d59a4dd8b).
|
||||||
|
* [Improve commit record's ui in comment list](https://codeberg.org/forgejo/forgejo/commit/ed1798f66d30e3755f01e24f8cb4aa5e8b6628a0).
|
||||||
|
* [Don't show new pr button when page is not compare pull](https://codeberg.org/forgejo/forgejo/commit/b693611b35c5ae17cfc820bc3e731608a5251464).
|
||||||
|
* [Add `Hide/Show all checks` button to commit status check](https://codeberg.org/forgejo/forgejo/commit/dcb648ee71853073d54e8a6e107b764212ede58e).
|
||||||
|
* [Improvements of releases list and tags list](https://codeberg.org/forgejo/forgejo/commit/3fcad582c9b9bfe66f4a346652f82b1aaf18430d).
|
||||||
|
* [Support pasting URLs over markdown text](https://codeberg.org/forgejo/forgejo/commit/45112876766cb81ed7edd2b72a3ab93e6deab8bb).
|
||||||
|
* [Customizable "Open with" applications for repository clone](https://codeberg.org/forgejo/forgejo/commit/44221a3cd747a01d55093b15a12bf053b534da35).
|
||||||
|
* [Allow options to disable user deletion from the interface on app.ini](https://codeberg.org/forgejo/forgejo/commit/767e9634d3d02acab27f05e1783391c9c7f6292e).
|
||||||
|
* [Extend issue template yaml engine](https://codeberg.org/forgejo/forgejo/commit/ff8f7a7a0d1d0f57113a6ad8b499f7c1094288f5).
|
||||||
|
* [Filter Repositories by type](https://codeberg.org/forgejo/forgejo/commit/83e04328dfff3b09e5d28dd972ebee0865f96b0e).
|
||||||
|
* [Implement code frequency graph](https://codeberg.org/forgejo/forgejo/commit/f097799953c5f510b7e3314f1e3e115761f207d0).
|
||||||
|
* [Implement recent commits graph](https://codeberg.org/forgejo/forgejo/commit/428008ac19185125b7cb1e3d379254d7b1932529).
|
||||||
|
* [Show commit status for releases](https://codeberg.org/forgejo/forgejo/commit/369fe5696697cef33a188d9b985ac4b9824a4bdf).
|
||||||
|
* [Actions Artifacts v4 backend](https://codeberg.org/forgejo/forgejo/commit/66632c4958041abdffe6adafc278d34ef515c44f).
|
||||||
|
* [Add merge style `fast-forward-only`](https://codeberg.org/forgejo/forgejo/commit/83123b493f3ae25d07d81c86b1a78afe1c17db53).
|
||||||
|
* [Retarget depending pulls when the parent branch is deleted](https://codeberg.org/forgejo/forgejo/commit/49eb16867728913d1eb2ced96e0b0b0a358f6ebe).
|
||||||
|
* [Add global setting how timestamps should be rendered](https://codeberg.org/forgejo/forgejo/commit/cdc33b29a012e61b42f192d79f9486fa8e21b2ed).
|
||||||
|
* [Add skip ci functionality](https://codeberg.org/forgejo/forgejo/commit/816e46ee7ce4b2649479554a940ecbe1cc505a3d)
|
||||||
|
* [Show latest commit for file](https://codeberg.org/forgejo/forgejo/commit/885cc32b14584ee2d01009768895b7a776441504).
|
||||||
|
* [Allow to sync tags from admin dashboard](https://codeberg.org/forgejo/forgejo/commit/4567a3a1ad0490d9077102e0e7b5de35790e5803).
|
||||||
|
* [Add Profile Readme for Organisations](https://codeberg.org/forgejo/forgejo/commit/603573366a203efae06f818a0b220be964cdac21).
|
||||||
|
* [Implement contributors graph](https://codeberg.org/forgejo/forgejo/commit/e9be8b25ae57189c4b29eaa393a397cf634d21d7).
|
||||||
|
* [Artifact deletion in actions ui](https://codeberg.org/forgejo/forgejo/commit/c551d3f3ab13379b0740fc45bc4dfc8f2fb84e16).
|
||||||
|
* [Add API routes to get runner registration token](https://codeberg.org/forgejo/forgejo/commit/baf0d402d9cb47849394202fcfc7c2e23b0faac3).
|
||||||
|
* [Add support for forking single branch](https://codeberg.org/forgejo/forgejo/commit/5e02e3b7ee8294e2ec94968ece9af56bf1aa1534).
|
||||||
|
* [Add support for sha256 repositories](https://codeberg.org/forgejo/forgejo/commit/d68a613ba8fd860863a3465b5b5945b191b87b25).
|
||||||
|
* [Add admin API route for managing user's badges](https://codeberg.org/forgejo/forgejo/commit/82b7de1360870db7a8b368a3f80ede887e32e128).
|
||||||
|
* **Bug fixes:**
|
||||||
|
* The repository home view will no longer redirect to external units. ([#2064](https://codeberg.org/forgejo/forgejo/pulls/2064))
|
||||||
|
* User and Organization `.profile` repositories now search for a `README.md` file case insensitively. ([#2090](https://codeberg.org/forgejo/forgejo/pulls/2090))
|
||||||
|
* When viewing a file, the RSS feed link is only displayed when there is an RSS feed provided for the context: when viewing a file on a branch. ([#2103](https://codeberg.org/forgejo/forgejo/pulls/2103))
|
||||||
|
* Repository topic searches are now correctly paged, which should make topic management on larger instances orders of magnitudes faster. ([#2060](https://codeberg.org/forgejo/forgejo/pulls/2060))
|
||||||
|
* Mentioning a user in a comment or similar place ignores apostrophes now. ([#2485](https://codeberg.org/forgejo/forgejo/pulls/2485))
|
||||||
|
* Setting the `[repository].DISABLE_STARS` setting to `true` disables the functionality completely, rather than just hiding it from the user interface.
|
||||||
|
* Forking a repository is now available at a predictable URL, and does not require knowing the repository id. ([#2310](https://codeberg.org/forgejo/forgejo/pulls/2310))
|
||||||
|
* Issue and pull request templates can now be placed in a `.forgejo` directory, like workflows. ([#2290](https://codeberg.org/forgejo/forgejo/pulls/2290))
|
||||||
|
* [[A11Y] Fix accessibility and translatability of repo explore counters](https://codeberg.org/forgejo/forgejo/pulls/2862)
|
||||||
|
* [[A11Y] Focus styling and fix Watch/Unwatch buttons](https://codeberg.org/forgejo/forgejo/pulls/2379)
|
||||||
|
* [[A11Y] Label Stars/Forks links in repo explore](https://codeberg.org/forgejo/forgejo/pulls/2634)
|
||||||
|
* [[A11Y] Taborder in repo explore](https://codeberg.org/forgejo/forgejo/pulls/2636)
|
||||||
|
* [[ACTIONS] add proper payload to scheduled events](https://codeberg.org/forgejo/forgejo/pulls/2015)
|
||||||
|
* [[ACTIONS] Do not update PRs based on events that happened before they existed](https://codeberg.org/forgejo/forgejo/pulls/2932)
|
||||||
|
* [[ACTIONS] GetScheduledMergeByPullID may involve a system user](https://codeberg.org/forgejo/forgejo/pulls/1908)
|
||||||
|
* [[ACTIONS] Link to Workflow in View](https://codeberg.org/forgejo/forgejo/pulls/1866)
|
||||||
|
* [[ACTIONS] the ref of a scheduled action is always the default branch](https://codeberg.org/forgejo/forgejo/pulls/1941)
|
||||||
|
* [[API] Adjust name of operation](https://codeberg.org/forgejo/forgejo/pulls/2189)
|
||||||
|
* [[API] `/api/v1/{owner}/{repo}/issue_templates`](https://codeberg.org/forgejo/forgejo/pulls/2292)
|
||||||
|
* [[API] Document correct status code for creating a tag](https://codeberg.org/forgejo/forgejo/pulls/2201)
|
||||||
|
* [[API] /api/forgejo/v1/version auth check](https://codeberg.org/forgejo/forgejo/pulls/2582)
|
||||||
|
* [[API] inconsistencies](https://codeberg.org/forgejo/forgejo/pulls/2182)
|
||||||
|
* [[API] /issues/search endpoint](https://codeberg.org/forgejo/forgejo/pulls/2020)
|
||||||
|
* [[API] Make HTTPS schema default for Swagger](https://codeberg.org/forgejo/forgejo/pulls/1896)
|
||||||
|
* [[I18N] Add missing translation for more_items](https://codeberg.org/forgejo/forgejo/pulls/2828)
|
||||||
|
* [[I18N] Eliminate wrapping quotes in English locale](https://codeberg.org/forgejo/forgejo/pulls/2467)
|
||||||
|
* [[I18N] English fixes and improvements](https://codeberg.org/forgejo/forgejo/pulls/2631)
|
||||||
|
* [[I18N] Fix milestone sorting translation keys](https://codeberg.org/forgejo/forgejo/pulls/2644)
|
||||||
|
* [[I18N] Use correct translation on closed milestones](https://codeberg.org/forgejo/forgejo/pulls/2957)
|
||||||
|
* [[I18N] Use new translation key](https://codeberg.org/forgejo/forgejo/pulls/2760)
|
||||||
|
* [[PACKAGES] Delete redundant snap packaging recipe](https://codeberg.org/forgejo/forgejo/pulls/2693)
|
||||||
|
* [[PACKAGES] Fix Alpine Registry packages with noarch not being found](https://codeberg.org/forgejo/forgejo/pulls/2285)
|
||||||
|
* [[PACKAGES] Generate install if condition for Alpine](https://codeberg.org/forgejo/forgejo/pulls/2176)
|
||||||
|
* [[PACKAGES] Packagist webhook: support all events](https://codeberg.org/forgejo/forgejo/pulls/2646)
|
||||||
|
* [[PACKAGES] Fix for PyPi Registry PEP 503 Compliance](https://codeberg.org/forgejo/forgejo/pulls/3197)
|
||||||
|
* [[UI] Adjust the signed tag verification line](https://codeberg.org/forgejo/forgejo/pulls/2966)
|
||||||
|
* [[UI] Better color for labels/counters](https://codeberg.org/forgejo/forgejo/pulls/2935)
|
||||||
|
* [[UI] Better number for UserCards pagination](https://codeberg.org/forgejo/forgejo/pulls/2584)
|
||||||
|
* [[UI] Center icon and callout text](https://codeberg.org/forgejo/forgejo/pulls/3010)
|
||||||
|
* [[UI] Consistent styling for Sort filter](https://codeberg.org/forgejo/forgejo/pulls/2920)
|
||||||
|
* [[UI] Disable the RSS feed in file view for non-branches](https://codeberg.org/forgejo/forgejo/pulls/2103)
|
||||||
|
* [[UI] Disable 'View at this point in history' for wikis](https://codeberg.org/forgejo/forgejo/pulls/2999)
|
||||||
|
* [[UI] Display error message if doer is unable to fork](https://codeberg.org/forgejo/forgejo/pulls/2649)
|
||||||
|
* [[UI] Don't use `<br />` in alert block](https://codeberg.org/forgejo/forgejo/pulls/2741)
|
||||||
|
* [[UI] Fix admin layout](https://codeberg.org/forgejo/forgejo/pulls/3087)
|
||||||
|
* [[UI] Fix crash in issue forms](https://codeberg.org/forgejo/forgejo/pulls/3012)
|
||||||
|
* [[UI] Fix Ctrl+Enter on submitting review comment](https://codeberg.org/forgejo/forgejo/pulls/2370)
|
||||||
|
* [[UI] Fix diff patch operation in web UI](https://codeberg.org/forgejo/forgejo/pulls/2449)
|
||||||
|
* [[UI] Fixes for project selector in sidebar](https://codeberg.org/forgejo/forgejo/pulls/2608)
|
||||||
|
* [[UI] Fix must-change-password help dialog](https://codeberg.org/forgejo/forgejo/pulls/2676)
|
||||||
|
* [[UI] Fix relative links on orgmode](https://codeberg.org/forgejo/forgejo/pulls/2385)
|
||||||
|
* [[UI] Fix selector inner radius](https://codeberg.org/forgejo/forgejo/pulls/2860)
|
||||||
|
* [[UI] Fix tone of callout boxes for Forgejo dark](https://codeberg.org/forgejo/forgejo/pulls/3085)
|
||||||
|
* [[UI] Fix tooltip for 1000+ stars/forks](https://codeberg.org/forgejo/forgejo/pulls/3147)
|
||||||
|
* [[UI] include hostname in admin panel URL in new user emails](https://codeberg.org/forgejo/forgejo/pulls/1940)
|
||||||
|
* [[UI] Increase contrast of code block](https://codeberg.org/forgejo/forgejo/pulls/2874)
|
||||||
|
* [[UI] Limit amount of javascript errors being shown](https://codeberg.org/forgejo/forgejo/pulls/2175)
|
||||||
|
* [[UI] Make settings tab not active when on repository "Add units" tab](https://codeberg.org/forgejo/forgejo/pulls/2524)
|
||||||
|
* [[UI] Make write and preview tabs interactive](https://codeberg.org/forgejo/forgejo/pulls/2681)
|
||||||
|
* [[UI] New issue button position consistency](https://codeberg.org/forgejo/forgejo/pulls/2845)
|
||||||
|
* [[UI] Fix orgmode link resolver for text descriptions](https://codeberg.org/forgejo/forgejo/pulls/2276)
|
||||||
|
* [[UI] Preview: set font-size on preview content](https://codeberg.org/forgejo/forgejo/pulls/2349)
|
||||||
|
* [[UI] Fix primary button background inconsistency](https://codeberg.org/forgejo/forgejo/pulls/3002)
|
||||||
|
* [[UI] Fix regression of issue edit not working](https://codeberg.org/forgejo/forgejo/pulls/3043)
|
||||||
|
* [[UI] Fix relative links rendering](https://codeberg.org/forgejo/forgejo/pulls/2166)
|
||||||
|
* [[UI] Remember topic only in repo search](https://codeberg.org/forgejo/forgejo/pulls/2575)
|
||||||
|
* [[UI] Remove min-height from wiki elements](https://codeberg.org/forgejo/forgejo/pulls/2080)
|
||||||
|
* [[UI] Render emojis in labels in issue info popup](https://codeberg.org/forgejo/forgejo/pulls/2888)
|
||||||
|
* [[UI] Render correct label link](https://codeberg.org/forgejo/forgejo/pulls/3187)
|
||||||
|
* [[UI] Render inline file permalinks](https://codeberg.org/forgejo/forgejo/pulls/2669)
|
||||||
|
* [[UI] Fix repo badges when the label or text contains dashes](https://codeberg.org/forgejo/forgejo/pulls/2711)
|
||||||
|
* [[UI] Fix repo unarchivation button](https://codeberg.org/forgejo/forgejo/pulls/2550)
|
||||||
|
* [[UI] Restrict when to make link absolute in markdown](https://codeberg.org/forgejo/forgejo/pulls/2403)
|
||||||
|
* [[UI] Revert darker tone on labels](https://codeberg.org/forgejo/forgejo/pulls/2881)
|
||||||
|
* [[UI] Simplify converting struct to map in admin stats](https://codeberg.org/forgejo/forgejo/pulls/2442)
|
||||||
|
* [[UI] Fix the Fork button in repo headers](https://codeberg.org/forgejo/forgejo/pulls/2495)
|
||||||
|
* [[UI] Use correct logout URL](https://codeberg.org/forgejo/forgejo/pulls/2475)
|
||||||
|
* [[UI] Use separate keys for tabs on login screen](https://codeberg.org/forgejo/forgejo/pulls/2630)
|
||||||
|
* [[UI] "view file" button in diff compare view](https://codeberg.org/forgejo/forgejo/pulls/3046)
|
||||||
|
* [add Cache-Control header for health-check](https://codeberg.org/forgejo/forgejo/pulls/3060)
|
||||||
|
* [add max idle time setting for db connections](https://codeberg.org/forgejo/forgejo/pulls/2418)
|
||||||
|
* [Allow `'s` in mentions](https://codeberg.org/forgejo/forgejo/pulls/2485)
|
||||||
|
* [Avoid `WHERE IN` for comment migration query](https://codeberg.org/forgejo/forgejo/pulls/1961)
|
||||||
|
* [Cleanup characters forbidden on Windows from test fixture filenames](https://codeberg.org/forgejo/forgejo/pulls/2178)
|
||||||
|
* [Correct changed files for CODEOWNERS](https://codeberg.org/forgejo/forgejo/pulls/2507)
|
||||||
|
* [Correct default licenses to work as desired](https://codeberg.org/forgejo/forgejo/pulls/1888)
|
||||||
|
* [Detect protected branch on branch rename](https://codeberg.org/forgejo/forgejo/pulls/2811)
|
||||||
|
* [Disabling Stars should disable the routes too](https://codeberg.org/forgejo/forgejo/pulls/2471)
|
||||||
|
* [doctor: Don't say All done when no checks were run](https://codeberg.org/forgejo/forgejo/pulls/1907)
|
||||||
|
* [Do not allow deletion of internal references](https://codeberg.org/forgejo/forgejo/pulls/2834)
|
||||||
|
* [Don't color dot literal color names](https://codeberg.org/forgejo/forgejo/pulls/2905)
|
||||||
|
* [Don't delete inactive emails explicitly](https://codeberg.org/forgejo/forgejo/pulls/2880)
|
||||||
|
* [Don't overwrite protected branch accidentally](https://codeberg.org/forgejo/forgejo/pulls/2473)
|
||||||
|
* [Don't redirect the repo to external units](https://codeberg.org/forgejo/forgejo/pulls/2064)
|
||||||
|
* [Don't remove builtin OAuth2 applications](https://codeberg.org/forgejo/forgejo/pulls/3067)
|
||||||
|
* [Ensure `HasIssueContentHistory` takes into account `comment_id`](https://codeberg.org/forgejo/forgejo/pulls/2518)
|
||||||
|
* [Find README.md for user profiles case insensitively](https://codeberg.org/forgejo/forgejo/pulls/2090)
|
||||||
|
* [Fix header name in swagger response](https://codeberg.org/forgejo/forgejo/pulls/2526)
|
||||||
|
* [Fix pull request reopen conditions](https://codeberg.org/forgejo/forgejo/pulls/2373)
|
||||||
|
* [Fix unblock action](https://codeberg.org/forgejo/forgejo/pulls/3086)
|
||||||
|
* [Fix VSCode settings](https://codeberg.org/forgejo/forgejo/pulls/1881)
|
||||||
|
* [Gracefully handle missing branches on a repos branches page](https://codeberg.org/forgejo/forgejo/pulls/2139)
|
||||||
|
* [Initialize Git for hook regeneration](https://codeberg.org/forgejo/forgejo/pulls/2416)
|
||||||
|
* [Internal Server Error when resolving comments](https://codeberg.org/forgejo/forgejo/pulls/2282)
|
||||||
|
* [Load `AllUnitsEnabled` when necessary](https://codeberg.org/forgejo/forgejo/pulls/2420)
|
||||||
|
* [Makefile: check git diff exitCode](https://codeberg.org/forgejo/forgejo/pulls/2651)
|
||||||
|
* [Make pprof labels conformant with prometheus spec](https://codeberg.org/forgejo/forgejo/pulls/2933)
|
||||||
|
* [Make reference URL absolute](https://codeberg.org/forgejo/forgejo/pulls/2100)
|
||||||
|
* [misleading comparisons when comparing branches](https://codeberg.org/forgejo/forgejo/pulls/2194)
|
||||||
|
* [Block issue creation when blocked by repo owner](https://codeberg.org/forgejo/forgejo/pulls/2052)
|
||||||
|
* [NPE in `ToPullReviewList`](https://codeberg.org/forgejo/forgejo/pulls/2057)
|
||||||
|
* [NPE in `UsernameSubRoute`](https://codeberg.org/forgejo/forgejo/pulls/1981)
|
||||||
|
* [Only pass selected repository IDs to pagination](https://codeberg.org/forgejo/forgejo/pulls/1848)
|
||||||
|
* [panic in `canSoftDeleteContentHistory`](https://codeberg.org/forgejo/forgejo/pulls/2134)
|
||||||
|
* [prevent removing session cookie when redirect_uri query contains ://](https://codeberg.org/forgejo/forgejo/pulls/2590)
|
||||||
|
* [pull_request_template branch link](https://codeberg.org/forgejo/forgejo/pulls/2232)
|
||||||
|
* [Rate limit pre-activation email change separately](https://codeberg.org/forgejo/forgejo/pulls/2043)
|
||||||
|
* [Refactor LFS GC functions](https://codeberg.org/forgejo/forgejo/pulls/3056)
|
||||||
|
* [Reflect Cargo index state in settings](https://codeberg.org/forgejo/forgejo/pulls/2698)
|
||||||
|
* [Remember topic only in repo search](https://codeberg.org/forgejo/forgejo/pulls/2489)
|
||||||
|
* [Require Latex code to have a end sequence](https://codeberg.org/forgejo/forgejo/pulls/1822)
|
||||||
|
* [Respond with JSON Resource Descriptor Content-Type per RFC7033](https://codeberg.org/forgejo/forgejo/pulls/2882)
|
||||||
|
* [Fix session generation for database](https://codeberg.org/forgejo/forgejo/pulls/2045)
|
||||||
|
* [Sort file list case insensitively](https://codeberg.org/forgejo/forgejo/pulls/2522)
|
||||||
|
* [Fix the topic search paging](https://codeberg.org/forgejo/forgejo/pulls/2060)
|
||||||
|
* [Typo fix & clarify RegistrationToken](https://codeberg.org/forgejo/forgejo/pulls/2191)
|
||||||
|
* [Update checker setting updates](https://codeberg.org/forgejo/forgejo/pulls/2925)
|
||||||
|
* [Use correct format for attr-check error log](https://codeberg.org/forgejo/forgejo/pulls/2866)
|
||||||
|
* [Use correct head commit for CODEOWNER](https://codeberg.org/forgejo/forgejo/pulls/2658)
|
||||||
|
* [Use correct template for commitmail error](https://codeberg.org/forgejo/forgejo/pulls/2973)
|
||||||
|
* [Workaround borked Git version](https://codeberg.org/forgejo/forgejo/pulls/2335)
|
||||||
|
* [Remove scheduled action tasks if the repo is archived](https://codeberg.org/forgejo/forgejo/commit/87870ade49eb76ff57a8593ba35df10e0d617aa5).
|
||||||
|
* [Relax generic package filename restrictions](https://codeberg.org/forgejo/forgejo/commit/ea4755be6dfc8fc1f3c794eeaa2e2322b97d192e).
|
||||||
|
* [Prevent re-review and dismiss review actions on closed and merged PRs](https://codeberg.org/forgejo/forgejo/commit/23676bfea7ccbbe166a554115ea1f5f02800e379).
|
||||||
|
* [Add a warning for disallowed email domains](https://codeberg.org/forgejo/forgejo/commit/2559c80bec27a41967b355d214253a83b9ee5dad).
|
||||||
|
* [Skip email domain check when admins edit user emails](https://codeberg.org/forgejo/forgejo/commit/e7afba21ce2b02eb4230ba03752bd8b937f3e6ef).
|
||||||
|
* [Skip email domain check when admin users adds user manually](https://codeberg.org/forgejo/forgejo/commit/b6057a34db38e563473db00543a1e39fd743ca34).
|
||||||
|
* [Add support for API blob upload of release attachments](https://codeberg.org/forgejo/forgejo/commit/47a913d40d3417858f2ee51a7dbed64ca84eff60).
|
||||||
|
* [Allow options to disable user gpg keys configuration from the interface on app.ini](https://codeberg.org/forgejo/forgejo/commit/ee6ff937c0782b9cdc7ae1bc62b7eda83982d40f).
|
||||||
|
* [Allow options to disable user ssh keys configuration from the interface on app.ini](https://codeberg.org/forgejo/forgejo/commit/bb09ad2b63570c80418b4b9a10f7dbbb349448ab).
|
||||||
|
* [Fix content size does not match error when uploading lfs file](https://codeberg.org/forgejo/forgejo/commit/fb137d1e49c0436f1db093e2dc0a2350d63e1e29).
|
||||||
|
* [Add API to get merged PR of a commit](https://codeberg.org/forgejo/forgejo/commit/1608ef0ce9ce2ea1c87aef715d111cf441637d01).
|
||||||
|
* [Add API to get PR by base/head](https://codeberg.org/forgejo/forgejo/commit/feb189554e758ed27d1e309e5ec309d663e8f338).
|
||||||
|
* [Add attachment support for code review comments](https://codeberg.org/forgejo/forgejo/commit/f95fb8cc44d790e0ae71d3f879124a6ee9b07f66).
|
||||||
|
* [Add support for action artifact serve direct](https://codeberg.org/forgejo/forgejo/commit/1f8ad34e4391673a2eda434ea5e48ea084cdc814).
|
||||||
|
* [Show whether a PR is WIP inside popups](https://codeberg.org/forgejo/forgejo/commit/50f55f11c4f785b72a39e59b0fc12ae70ab8d8b5).
|
||||||
|
* [Add artifacts v4 jwt to job message and accept it](https://codeberg.org/forgejo/forgejo/commit/a9bc590d5d10b97bd8aa050ffb720e141a600064).
|
||||||
|
* [Fix some RPM registry flaws](https://codeberg.org/forgejo/forgejo/commit/461d8b53c2e51a8a6a1715ba40ac61d7e9f93971).
|
||||||
|
* [Add branch protection setting for ignoring stale approvals](https://codeberg.org/forgejo/forgejo/commit/5d3fdd121279c758f247a76e020799aa5e548feb).
|
||||||
|
* [Added instance-level variables](https://codeberg.org/forgejo/forgejo/commit/d0f24ff4cad05c1145afeca791e7d02fe146d46a).
|
||||||
|
* [Fix the wrong HTTP response status code for duplicate packages](https://codeberg.org/forgejo/forgejo/commit/5b6258a0b94737ec3db1ce418d0c933512a71f78).
|
||||||
|
* [Don't run push mirrors for archived repos](https://codeberg.org/forgejo/forgejo/commit/f3ba3e922dde7d12999a90d6cee15805a56cc7ff).
|
||||||
|
* [Support for grouping RPMs using paths](https://codeberg.org/forgejo/forgejo/commit/ba4d0b8ffbd78473273800f586ae8bde55cda6c5).
|
||||||
|
* [Fixes #27605: inline math blocks can't be preceded/followed by alphanumerical characters](https://codeberg.org/forgejo/forgejo/commit/2adc3a45fbd60126c0eab66b9cdd177a63bd4704).
|
||||||
|
* [Fix GPG subkey verify](https://codeberg.org/forgejo/forgejo/commit/5a674dd02ed3ea2853afa02dc15dcdadba069a6e).
|
||||||
|
* [Include encoding in signature payload](https://codeberg.org/forgejo/forgejo/commit/6925c0eee43980133896f9e4ee7e48e5751e9417).
|
||||||
|
* [Fix milestoneID filter bug in issue list](https://codeberg.org/forgejo/forgejo/commit/0da787f23737d252e6c80aa1a1f665e09dba0ea9).
|
||||||
|
* [Fix Citation modal responsiveness and clipboard copy](https://codeberg.org/forgejo/forgejo/commit/ca39d743636c9732f4422e130bac974555fb43c2).
|
||||||
|
* [Fix incorrect locale Tr for gpg command](https://codeberg.org/forgejo/forgejo/commit/071d871dcf8dd8097dc0af6d4baf304a2fbbe4e2).
|
||||||
|
* [Improve a11y document and dropdown item](https://codeberg.org/forgejo/forgejo/commit/1d4bf7e211db0866774fa3f6f563e15ffadac1f6).
|
||||||
|
* [Determine fuzziness of bleve indexer by keyword length](https://codeberg.org/forgejo/forgejo/commit/ab5f0b7558229b3ab5c3946a51e58b4caae775b0).
|
||||||
|
* [Fix ellipsis button not working if the last commit loading is deferred](https://codeberg.org/forgejo/forgejo/commit/1e29bccddbeb29eec3ceb507612851021ab4d60d).
|
||||||
|
* [Fix incorrect diff expander for deletion of last lines in a file](https://codeberg.org/forgejo/forgejo/commit/85bf170ff0d54471fe88903009a3fec4ef3e6e8c).
|
||||||
|
* [Do not exceed display for the PR page buttons on smaller screens](https://codeberg.org/forgejo/forgejo/commit/e7297d423f566a383c8861c4aaee028606591038).
|
||||||
|
* [Move citation button to proper place](https://codeberg.org/forgejo/forgejo/commit/eb4061babacfee2b72f4a33412530eb9f0de3b25).
|
||||||
|
* [Expire artifacts before deleting them physically](https://codeberg.org/forgejo/forgejo/commit/7f64e4d2a3f20b7d7de6542de5e0856c643e821f).
|
||||||
|
* [Fix can not select team reviewers when reviewers is empty](https://codeberg.org/forgejo/forgejo/commit/df439b6a983865ba559e517e5e93f5f1a53a97a0).
|
||||||
|
* [Fix default avatar image size in PR diff page](https://codeberg.org/forgejo/forgejo/commit/3aed8ae03475a430c0dc8e33f42fa9269a4844bd).
|
||||||
|
* [Fix branch list bug which displayed default branch twice](https://codeberg.org/forgejo/forgejo/commit/0e6fd0d1c1e31d22707e6f06124d5bf76361eaab).
|
||||||
|
* [Set the `isPermaLink` attribute to `false` in the `guid` sub-element](https://codeberg.org/forgejo/forgejo/commit/5574968ecbc34908dfa17b28bfc79c3490eaa685).
|
||||||
|
* [Fix long package version names overflowing](https://codeberg.org/forgejo/forgejo/commit/3d474110c181df7854576d78e46209908f7e1b52).
|
||||||
|
* [Fix wrong link in user and organization profile when using relative url](https://codeberg.org/forgejo/forgejo/commit/42149ff1a816501643ec2407ed61a83bf5b65059).
|
||||||
|
* [Fix session key conflict with database keyword](https://codeberg.org/forgejo/forgejo/commit/4c29c75968f520123f125e8305b2c29198664251).
|
||||||
|
* [Fix commit status in repo list](https://codeberg.org/forgejo/forgejo/commit/0abb5633e34fd14c2d49de0b4c98f7ba7d98a37e).
|
||||||
|
* [Fix incorrect action duration time when rerun the job before executed once](https://codeberg.org/forgejo/forgejo/commit/07ba4d9f87cf21b7ce87158ae5651cae3bb35604).
|
||||||
|
* [Fix missing mail reply address](https://codeberg.org/forgejo/forgejo/commit/3081e7e1536356346f73fb4a0d00101863b2cf05).
|
||||||
|
* [Filter inactive auth sources](https://codeberg.org/forgejo/forgejo/commit/e378545f3083990eb36ff5d72477662d9787280d).
|
||||||
|
* [Refactor Find Sources and fix bug when view a user who belongs to an inactive auth source](https://codeberg.org/forgejo/forgejo/commit/1bf5527eac6b947010c8faf408f6747de2a2384f).
|
||||||
|
* [Fix issue not showing on default board and add test](https://codeberg.org/forgejo/forgejo/commit/1eae2aadae0583ab092d6ed857bb727829aa52b7).
|
||||||
|
* [Improve file history UI and fix URL escaping bug](https://codeberg.org/forgejo/forgejo/commit/d1527dac3d1e68caf5a6f54c08144e28256e5c47).
|
||||||
|
* [Fix ldap admin privileges update bug](https://codeberg.org/forgejo/forgejo/commit/7ad31567cdc8206e0080b851a9b880729266b084).
|
||||||
|
* **other**
|
||||||
|
* [[PERFORMANCE] git check-attr on bare repo if supported](https://codeberg.org/forgejo/forgejo/pulls/2763)
|
||||||
|
* [[REFACTOR] [AGIT] Refactor the AGit code](https://codeberg.org/forgejo/forgejo/pulls/2386)
|
||||||
|
* [[REFACTOR] generation of JWT secret](https://codeberg.org/forgejo/forgejo/pulls/2227)
|
||||||
|
* [[REFACTOR] PKT protocol](https://codeberg.org/forgejo/forgejo/pulls/2868)
|
||||||
|
* [Remove .exe suffix when cross-compiling on Windows](https://codeberg.org/forgejo/forgejo/commit/6acce16ee3a03df1cc06c46398f594009a0e31b9).
|
||||||
|
* [Refactor repo header/list](https://codeberg.org/forgejo/forgejo/commit/65e190ae8bd6c72d8701a58d67b256c87b92c189).
|
||||||
|
* [Update register application URL for GitLab](https://codeberg.org/forgejo/forgejo/commit/64fcf0cb64d455d5ca1420aa832aa057cf61e6dd).
|
||||||
|
* [Update golang links to use https](https://codeberg.org/forgejo/forgejo/commit/8ef53c871bcb5c007b3640a347c7868585c9e4de).
|
||||||
|
* [Teams: new View button](https://codeberg.org/forgejo/forgejo/commit/e3afe4a248ac3a961f332e2ba221bedafa3dfb7e).
|
||||||
|
* [Commit-Dropdown: Show Author of commit if available](https://codeberg.org/forgejo/forgejo/commit/300c8dedfd01ba0ea63486b644e93aa2be6785b2).
|
||||||
|
* [Refactor dropzone](https://codeberg.org/forgejo/forgejo/commit/c1ac3e5891a49bedc5e54ed5811cb2c0e058c43c).
|
||||||
|
* [When the title in the issue has a value, set the text cursor at the end of the text.](https://codeberg.org/forgejo/forgejo/commit/8c2559a72603e07fe682efddd698e1fc190b2728).
|
||||||
|
* [Load citation JS only when needed](https://codeberg.org/forgejo/forgejo/commit/f2fc2dcfc9305a42242421c718ee3673bd1c851c).
|
||||||
|
* [Refactor markdown attention render](https://codeberg.org/forgejo/forgejo/commit/ec2201a3da5f18e55bfc0a54114ac935804f4ef8).
|
||||||
|
* [Light theme color enhancements](https://codeberg.org/forgejo/forgejo/commit/23e2ace77d1612cda09bc0d08690314e7321cca3).
|
||||||
|
* [Dark theme color enhancements](https://codeberg.org/forgejo/forgejo/commit/704a59e59584041f95939e3d90260173906f946a).
|
||||||
|
* [Refactor markup/csv: don't read all to memory](https://codeberg.org/forgejo/forgejo/commit/d413a8fcacc81b6f7039371408034c9c2fc6c15f).
|
||||||
|
* [Move all login and account creation page labels to be above inputs](https://codeberg.org/forgejo/forgejo/commit/3acea02eb66ea09248ff29eb6b9cefce29fcea37).
|
||||||
|
* [Fix Gitpod logic of setting ROOT_URL](https://codeberg.org/forgejo/forgejo/commit/e52d87758272c417bb9b30e944f9b0bd33d28cb7).
|
||||||
|
* [Fix broken following organization](https://codeberg.org/forgejo/forgejo/commit/fd3b4afa2b3621ece2d7d1587fd4b017142d75a0).
|
||||||
|
* [Don't do a full page load when clicking `Watch` or `Star`](https://codeberg.org/forgejo/forgejo/commit/6992ef98fc227a60cf06e0a06b9ae2492b3d61be).
|
||||||
|
* [Fix non-alphabetic sorting of repo topics](https://codeberg.org/forgejo/forgejo/commit/a240d5dfa7e261f2fb703cf24b1ba4dc6aa47bfd).
|
||||||
|
* [Make cross-reference issue links work in markdown documents again](https://codeberg.org/forgejo/forgejo/commit/12c0487e01d3fd9fe289345c53e8a220be55e864).
|
||||||
|
* [Fix tooltip of variable edit button](https://codeberg.org/forgejo/forgejo/commit/361839fb1c8bdfb8291bbcf9bd650b21a605bbd7).
|
||||||
|
* [Disable query token param in integration tests](https://codeberg.org/forgejo/forgejo/commit/33439b733a4f69640350b9cda370963ebe9d1e0a).
|
||||||
|
* [Add merge arrow direction and update styling](https://codeberg.org/forgejo/forgejo/commit/e522e774cae2240279fc48c349fc513c9d3353ee).
|
||||||
|
* [Add links to owner home page in explore](https://codeberg.org/forgejo/forgejo/commit/dd5693387e0642e1aba05b01eeb18139ce90ef5e).
|
||||||
|
* [Render PyPi long description as document](https://codeberg.org/forgejo/forgejo/commit/876a0cb3d652f42545abdb33dc4fd71a7c3343bf).
|
||||||
|
* [Ignore temporary files for directory size](https://codeberg.org/forgejo/forgejo/commit/cb8298b7178f5dde302604bfe34c658b725f16f8).
|
||||||
|
* [Make pushUpdate error verbose](https://codeberg.org/forgejo/forgejo/commit/1bfcdeef4cca0f5509476358e5931c13d37ed1ca).
|
||||||
|
* [Add download URL for executable files](https://codeberg.org/forgejo/forgejo/commit/9341b37520e5626352bf2df52e8dbace2985c0d7).
|
||||||
|
* [Improve profile for Organizations](https://codeberg.org/forgejo/forgejo/commit/089ac06969030b0886d4e20bf8f7a757f785f158).
|
||||||
|
* [Fix Show/hide filetree button on small displays](https://codeberg.org/forgejo/forgejo/commit/e31c6cfe6e30341c502302d1c0a03138f8bf5c9f).
|
||||||
|
* [Fix merge base commit for fast-forwarded GitLab PRs](https://codeberg.org/forgejo/forgejo/commit/02dae3f84b80047bef391960eea1350d551e4d72).
|
||||||
|
* [Align ISSUE_TEMPLATE with the new label system](https://codeberg.org/forgejo/forgejo/commit/248b7ee850ecdb538b22ddcfbe80b6f91be32b70).
|
||||||
|
* [Improve the list header in milestone page](https://codeberg.org/forgejo/forgejo/commit/8abc1aae4ab5b03be0bcbdd390bb903b54ccd21a).
|
||||||
|
|
||||||
|
## 1.21.11-1
|
||||||
|
|
||||||
|
This stable release contains a single bug fix for a regression introduced in v1.21.11-0 by which creating a tag via the API would fail with error 500 on a repository a where Forgejo Actions workflow triggered by tags exists.
|
||||||
|
|
||||||
|
* Recommended Action
|
||||||
|
|
||||||
|
We recommend that all Forgejo installations are [upgraded](https://forgejo.org/docs/v1.21/admin/upgrade/) to the latest version as soon as possible.
|
||||||
|
|
||||||
|
* [Forgejo Semantic Version](https://forgejo.org/docs/v1.21/user/semver/)
|
||||||
|
|
||||||
|
The semantic version was updated to `6.0.12+0-gitea-1.21.10`
|
||||||
|
|
||||||
|
* Bug fix
|
||||||
|
|
||||||
|
* [error 500 on tag creation when a workflow exists](https://codeberg.org/forgejo/forgejo/issues/3327)
|
||||||
|
|
||||||
|
## 1.21.11-0
|
||||||
|
|
||||||
|
[The complete list of new commits included in the Forgejo v1.21.11-0 release can be reviewed here](https://codeberg.org/forgejo/forgejo/compare/v1.21.10-0...v1.21.11-0), or from the comand line with:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ git clone https://codeberg.org/forgejo/forgejo
|
||||||
|
$ git -C forgejo log --oneline --no-merges v1.21.10-0..v1.21.11-0
|
||||||
|
```
|
||||||
|
|
||||||
|
This stable release contains bug fixes and **security fixes**.
|
||||||
|
|
||||||
|
* Recommended Action
|
||||||
|
|
||||||
|
We strongly recommend that all Forgejo installations are [upgraded](https://forgejo.org/docs/v1.21/admin/upgrade/) to the latest version as soon as possible.
|
||||||
|
|
||||||
|
* [Forgejo Semantic Version](https://forgejo.org/docs/v1.21/user/semver/)
|
||||||
|
|
||||||
|
The semantic version was updated to `6.0.11+0-gitea-1.21.10`
|
||||||
|
|
||||||
|
* Security fix
|
||||||
|
|
||||||
|
* [Fixed a privilege escalation through git push options](https://codeberg.org/forgejo/forgejo/commit/cc80e661531794fff7f8a336eaaefdb7e3bd3956) that allows any user to change the visibility of any repository they can see, regardless of their level of access.
|
||||||
|
* [Fixed a bug that allows user-supplied, non-sandboxed JavaScript to be run from the same domain as the forge](https://codeberg.org/forgejo/forgejo/commit/8dcc7d9e8ce36d94bae1a1becddc4735f51add3c), via `/{owner}/{repo}/render/branch/{branch}/{filename}` URLs.
|
||||||
|
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
* [Use system action user to trigger scheduled action workflows](https://codeberg.org/forgejo/forgejo/commit/387aea4434488555838e55e067242509bc1510a6)
|
||||||
|
* [Close file in upload function](https://codeberg.org/forgejo/forgejo/commit/fd47240545ab1c4f10d07434c2ba00fff044236a)
|
||||||
|
* [Prevent registering runners for deleted repositories](https://codeberg.org/forgejo/forgejo/commit/fd47240545ab1c4f10d07434c2ba00fff044236a). Prevents 500 Internal Server Error in admin interface.
|
||||||
|
* [More reliable pagination support when migrating from gitbucket](https://codeberg.org/forgejo/forgejo/commit/e702e79625980b08ec060a1690b76502455acad9)
|
||||||
|
* [Fix automerge when used with actions](https://codeberg.org/forgejo/forgejo/commit/4889a3a1713d91a5ae95af4edf1bb3352d1871fd)
|
||||||
|
|
||||||
|
## 1.21.10-0
|
||||||
|
|
||||||
|
The [complete list of commits](https://codeberg.org/forgejo/forgejo/commits/branch/v1.21/forgejo) included in the `Forgejo v1.21.10-0` release can be reviewed from the command line with:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ git clone https://codeberg.org/forgejo/forgejo/
|
||||||
|
$ git -C forgejo log --oneline --no-merges v1.21.8-0..v1.21.10-0
|
||||||
|
```
|
||||||
|
|
||||||
|
This stable release contains bug fixes and a **security fix**.
|
||||||
|
|
||||||
|
Note that there is no `Forgejo v1.21.9-0` release. The release numbering of the `Forgejo v1.21` patch series follows the Gitea release numbering. However, the publication of `Gitea v1.21.9` and `Gitea v1.21.10` were a few days apart because of a regression that is not present on Forgejo and there was no need to publish `Forgejo v1.21.9-0`.
|
||||||
|
|
||||||
|
* Recommended Action
|
||||||
|
|
||||||
|
We recommend that all Forgejo installations are [upgraded](https://forgejo.org/docs/v1.21/admin/upgrade/) to the latest version as soon as possible.
|
||||||
|
|
||||||
|
* [Forgejo Semantic Version](https://forgejo.org/docs/v1.21/user/semver/)
|
||||||
|
|
||||||
|
The semantic version was updated to `6.0.10+0-gitea-1.21.10`
|
||||||
|
|
||||||
|
* Built with Go 1.21.9 and `golang.org/x/net` v0.23.0
|
||||||
|
|
||||||
|
It [includes vulnerability fixes](https://groups.google.com/g/golang-announce/c/YgW0sx8mN3M/m/khALNYGdAAAJ).
|
||||||
|
|
||||||
|
* [CVE-2023-45288](https://pkg.go.dev/vuln/GO-2024-2687) which permits an attacker to cause an HTTP/2 endpoint to read arbitrary amounts of header data, all associated with a request which is going to be rejected. These headers can include Huffman-encoded data which is significantly more expensive for the receiver to decode than for an attacker to send. A Forgejo instance is affected if it is configured to listen to HTTPS instead of doing this via a reverse proxy.
|
||||||
|
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
The most prominent ones are described here, others can be found in the list of commits included in the release as described above.
|
||||||
|
|
||||||
|
* [Fix to not remove repository avatars when the doctor runs with --fix on the repository archives](https://codeberg.org/forgejo/forgejo/commit/e9932a404d4bb5b22a87797094dff615eb38171a).
|
||||||
|
* [Detect protected branch on branch rename](https://codeberg.org/forgejo/forgejo/commit/611610c3c4cba12f2a835b41438a7ed54da9bc23). If a branch cannot be renamed due to a protected branch rule, show this error in the UI instead of throwing an internal server error.
|
||||||
|
* [Don't delete inactive emails explicitly](https://codeberg.org/forgejo/forgejo/commit/fb4c42deb23a67379afb29870e430e47687ccc6c). This can cause issues as the associated user might not have been deleted. It would lead to a database inconsistency and internal server errors if the user tries to activate their account.
|
||||||
|
* [Fix user interface when a review is deleted without refreshing](https://codeberg.org/forgejo/forgejo/commit/456a33e8bb770a86341dc883edc6b62264b950a1).
|
||||||
|
* [Fix paths when finding files via the web interface that were not escaped](https://codeberg.org/forgejo/forgejo/commit/b22be0c03fa4814c1b8b892346de5d4547782ce7).
|
||||||
|
* [Respect `DEFAULT_ORG_MEMBER_VISIBLE` setting when adding creator to org](https://codeberg.org/forgejo/forgejo/commit/5e5574c7b328e2c500d497517047b8d1fd0ca478).
|
||||||
|
* [Fix duplicate migrated milestones](https://codeberg.org/forgejo/forgejo/commit/706ff7aa9fcfe4c43893dc12e27d064064e80635).
|
||||||
|
* [Fix inline math blocks can't be preceeded/followed by alphanumerical characters](https://codeberg.org/forgejo/forgejo/commit/0d3f446460b22a29c259e7d42ed89f90fd216ca7).
|
||||||
|
|
||||||
## 1.21.8-0
|
## 1.21.8-0
|
||||||
|
|
||||||
|
|
10
assets/go-licenses.json
generated
10
assets/go-licenses.json
generated
File diff suppressed because one or more lines are too long
|
@ -142,7 +142,7 @@ func generate() ([]byte, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// gitea customizations
|
// Forgejo customizations
|
||||||
i, ok := aliasMap["tada"]
|
i, ok := aliasMap["tada"]
|
||||||
if ok {
|
if ok {
|
||||||
data[i].Aliases = append(data[i].Aliases, "hooray")
|
data[i].Aliases = append(data[i].Aliases, "hooray")
|
||||||
|
|
|
@ -36,6 +36,7 @@ var microcmdUserChangePassword = &cli.Command{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "must-change-password",
|
Name: "must-change-password",
|
||||||
Usage: "User must change password",
|
Usage: "User must change password",
|
||||||
|
Value: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -57,23 +58,18 @@ func runChangePassword(c *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var mustChangePassword optional.Option[bool]
|
|
||||||
if c.IsSet("must-change-password") {
|
|
||||||
mustChangePassword = optional.Some(c.Bool("must-change-password"))
|
|
||||||
}
|
|
||||||
|
|
||||||
opts := &user_service.UpdateAuthOptions{
|
opts := &user_service.UpdateAuthOptions{
|
||||||
Password: optional.Some(c.String("password")),
|
Password: optional.Some(c.String("password")),
|
||||||
MustChangePassword: mustChangePassword,
|
MustChangePassword: optional.Some(c.Bool("must-change-password")),
|
||||||
}
|
}
|
||||||
if err := user_service.UpdateAuth(ctx, user, opts); err != nil {
|
if err := user_service.UpdateAuth(ctx, user, opts); err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, password.ErrMinLength):
|
case errors.Is(err, password.ErrMinLength):
|
||||||
return fmt.Errorf("Password is not long enough. Needs to be at least %d", setting.MinPasswordLength)
|
return fmt.Errorf("password is not long enough, needs to be at least %d characters", setting.MinPasswordLength)
|
||||||
case errors.Is(err, password.ErrComplexity):
|
case errors.Is(err, password.ErrComplexity):
|
||||||
return errors.New("Password does not meet complexity requirements")
|
return errors.New("password does not meet complexity requirements")
|
||||||
case errors.Is(err, password.ErrIsPwned):
|
case errors.Is(err, password.ErrIsPwned):
|
||||||
return errors.New("The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password.\nFor more details, see https://haveibeenpwned.com/Passwords")
|
return errors.New("the password is in a list of stolen passwords previously exposed in public data breaches, please try again with a different password, to see more details: https://haveibeenpwned.com/Passwords")
|
||||||
default:
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
auth_model "code.gitea.io/gitea/models/auth"
|
auth_model "code.gitea.io/gitea/models/auth"
|
||||||
|
"code.gitea.io/gitea/models/db"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
pwd "code.gitea.io/gitea/modules/auth/password"
|
pwd "code.gitea.io/gitea/modules/auth/password"
|
||||||
"code.gitea.io/gitea/modules/optional"
|
"code.gitea.io/gitea/modules/optional"
|
||||||
|
@ -49,6 +50,7 @@ var microcmdUserCreate = &cli.Command{
|
||||||
Name: "must-change-password",
|
Name: "must-change-password",
|
||||||
Usage: "Set this option to false to prevent forcing the user to change their password after initial login",
|
Usage: "Set this option to false to prevent forcing the user to change their password after initial login",
|
||||||
Value: true,
|
Value: true,
|
||||||
|
DisableDefaultText: true,
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
Name: "random-password-length",
|
Name: "random-password-length",
|
||||||
|
@ -72,10 +74,10 @@ func runCreateUser(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsSet("name") && c.IsSet("username") {
|
if c.IsSet("name") && c.IsSet("username") {
|
||||||
return errors.New("Cannot set both --name and --username flags")
|
return errors.New("cannot set both --name and --username flags")
|
||||||
}
|
}
|
||||||
if !c.IsSet("name") && !c.IsSet("username") {
|
if !c.IsSet("name") && !c.IsSet("username") {
|
||||||
return errors.New("One of --name or --username flags must be set")
|
return errors.New("one of --name or --username flags must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsSet("password") && c.IsSet("random-password") {
|
if c.IsSet("password") && c.IsSet("random-password") {
|
||||||
|
@ -111,12 +113,21 @@ func runCreateUser(c *cli.Context) error {
|
||||||
return errors.New("must set either password or random-password flag")
|
return errors.New("must set either password or random-password flag")
|
||||||
}
|
}
|
||||||
|
|
||||||
changePassword := c.Bool("must-change-password")
|
isAdmin := c.Bool("admin")
|
||||||
|
mustChangePassword := true // always default to true
|
||||||
// If this is the first user being created.
|
if c.IsSet("must-change-password") {
|
||||||
// Take it as the admin and don't force a password update.
|
// if the flag is set, use the value provided by the user
|
||||||
if n := user_model.CountUsers(ctx, nil); n == 0 {
|
mustChangePassword = c.Bool("must-change-password")
|
||||||
changePassword = false
|
} else {
|
||||||
|
// check whether there are users in the database
|
||||||
|
hasUserRecord, err := db.IsTableNotEmpty(&user_model.User{})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("IsTableNotEmpty: %w", err)
|
||||||
|
}
|
||||||
|
if !hasUserRecord {
|
||||||
|
// if this is the first admin being created, don't force to change password (keep the old behavior)
|
||||||
|
mustChangePassword = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
restricted := optional.None[bool]()
|
restricted := optional.None[bool]()
|
||||||
|
@ -132,8 +143,8 @@ func runCreateUser(c *cli.Context) error {
|
||||||
Name: username,
|
Name: username,
|
||||||
Email: c.String("email"),
|
Email: c.String("email"),
|
||||||
Passwd: password,
|
Passwd: password,
|
||||||
IsAdmin: c.Bool("admin"),
|
IsAdmin: isAdmin,
|
||||||
MustChangePassword: changePassword,
|
MustChangePassword: mustChangePassword,
|
||||||
Visibility: visibility,
|
Visibility: visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
55
cmd/hook.go
55
cmd/hook.go
|
@ -139,11 +139,10 @@ func (d *delayWriter) WriteString(s string) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *delayWriter) Close() error {
|
func (d *delayWriter) Close() error {
|
||||||
if d == nil {
|
if d.timer.Stop() {
|
||||||
return nil
|
d.buf = nil
|
||||||
}
|
}
|
||||||
stopped := d.timer.Stop()
|
if d.buf == nil {
|
||||||
if stopped || d.buf == nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, err := d.internal.Write(d.buf.Bytes())
|
_, err := d.internal.Write(d.buf.Bytes())
|
||||||
|
@ -303,8 +302,12 @@ func runHookUpdate(c *cli.Context) error {
|
||||||
ctx, cancel := installSignals()
|
ctx, cancel := installSignals()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// The last three arguments given to the hook are in order: reference name, old commit ID and new commit ID.
|
if c.NArg() != 3 {
|
||||||
args := os.Args[len(os.Args)-3:]
|
return nil
|
||||||
|
}
|
||||||
|
args := c.Args().Slice()
|
||||||
|
|
||||||
|
// The arguments given to the hook are in order: reference name, old commit ID and new commit ID.
|
||||||
refFullName := git.RefName(args[0])
|
refFullName := git.RefName(args[0])
|
||||||
newCommitID := args[2]
|
newCommitID := args[2]
|
||||||
|
|
||||||
|
@ -313,12 +316,12 @@ func runHookUpdate(c *cli.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deletion of the ref means that the new commit ID is only composed of '0'.
|
// Empty new commit ID means deletion.
|
||||||
if strings.ContainsFunc(newCommitID, func(e rune) bool { return e != '0' }) {
|
if git.IsEmptyCommitID(newCommitID, nil) {
|
||||||
return nil
|
return fail(ctx, fmt.Sprintf("The deletion of %s is skipped as it's an internal reference.", refFullName), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
return fail(ctx, fmt.Sprintf("The deletion of %s is skipped as it's an internal reference.", refFullName), "")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runHookPostReceive(c *cli.Context) error {
|
func runHookPostReceive(c *cli.Context) error {
|
||||||
|
@ -347,11 +350,10 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
var out io.Writer
|
var out io.Writer
|
||||||
var dWriter *delayWriter
|
|
||||||
out = &nilWriter{}
|
out = &nilWriter{}
|
||||||
if setting.Git.VerbosePush {
|
if setting.Git.VerbosePush {
|
||||||
if setting.Git.VerbosePushDelay > 0 {
|
if setting.Git.VerbosePushDelay > 0 {
|
||||||
dWriter = newDelayWriter(os.Stdout, setting.Git.VerbosePushDelay)
|
dWriter := newDelayWriter(os.Stdout, setting.Git.VerbosePushDelay)
|
||||||
defer dWriter.Close()
|
defer dWriter.Close()
|
||||||
out = dWriter
|
out = dWriter
|
||||||
} else {
|
} else {
|
||||||
|
@ -364,6 +366,7 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
isWiki, _ := strconv.ParseBool(os.Getenv(repo_module.EnvRepoIsWiki))
|
isWiki, _ := strconv.ParseBool(os.Getenv(repo_module.EnvRepoIsWiki))
|
||||||
repoName := os.Getenv(repo_module.EnvRepoName)
|
repoName := os.Getenv(repo_module.EnvRepoName)
|
||||||
pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
|
pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
|
||||||
|
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
|
||||||
pusherName := os.Getenv(repo_module.EnvPusherName)
|
pusherName := os.Getenv(repo_module.EnvPusherName)
|
||||||
|
|
||||||
hookOptions := private.HookOptions{
|
hookOptions := private.HookOptions{
|
||||||
|
@ -373,6 +376,8 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
|
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
|
||||||
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
|
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
|
||||||
GitPushOptions: pushOptions(),
|
GitPushOptions: pushOptions(),
|
||||||
|
PullRequestID: prID,
|
||||||
|
PushTrigger: repo_module.PushTrigger(os.Getenv(repo_module.EnvPushTrigger)),
|
||||||
}
|
}
|
||||||
oldCommitIDs := make([]string, hookBatchSize)
|
oldCommitIDs := make([]string, hookBatchSize)
|
||||||
newCommitIDs := make([]string, hookBatchSize)
|
newCommitIDs := make([]string, hookBatchSize)
|
||||||
|
@ -400,8 +405,7 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
newCommitIDs[count] = string(fields[1])
|
newCommitIDs[count] = string(fields[1])
|
||||||
refFullNames[count] = git.RefName(fields[2])
|
refFullNames[count] = git.RefName(fields[2])
|
||||||
|
|
||||||
commitID, _ := git.NewIDFromString(newCommitIDs[count])
|
if refFullNames[count] == git.BranchPrefix+"master" && !git.IsEmptyCommitID(newCommitIDs[count], nil) && count == total {
|
||||||
if refFullNames[count] == git.BranchPrefix+"master" && !commitID.IsZero() && count == total {
|
|
||||||
masterPushed = true
|
masterPushed = true
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
|
@ -414,7 +418,6 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
hookOptions.RefFullNames = refFullNames
|
hookOptions.RefFullNames = refFullNames
|
||||||
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
|
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
|
||||||
if extra.HasError() {
|
if extra.HasError() {
|
||||||
_ = dWriter.Close()
|
|
||||||
hookPrintResults(results)
|
hookPrintResults(results)
|
||||||
return fail(ctx, extra.UserMsg, "HookPostReceive failed: %v", extra.Error)
|
return fail(ctx, extra.UserMsg, "HookPostReceive failed: %v", extra.Error)
|
||||||
}
|
}
|
||||||
|
@ -434,7 +437,6 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "Processed %d references in total\n", total)
|
fmt.Fprintf(out, "Processed %d references in total\n", total)
|
||||||
|
|
||||||
_ = dWriter.Close()
|
|
||||||
hookPrintResults(results)
|
hookPrintResults(results)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -447,7 +449,6 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
|
|
||||||
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
|
resp, extra := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
_ = dWriter.Close()
|
|
||||||
hookPrintResults(results)
|
hookPrintResults(results)
|
||||||
return fail(ctx, extra.UserMsg, "HookPostReceive failed: %v", extra.Error)
|
return fail(ctx, extra.UserMsg, "HookPostReceive failed: %v", extra.Error)
|
||||||
}
|
}
|
||||||
|
@ -463,9 +464,8 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
return fail(ctx, extra.UserMsg, "SetDefaultBranch failed: %v", extra.Error)
|
return fail(ctx, extra.UserMsg, "SetDefaultBranch failed: %v", extra.Error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = dWriter.Close()
|
|
||||||
hookPrintResults(results)
|
|
||||||
|
|
||||||
|
hookPrintResults(results)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,10 +493,11 @@ func pushOptions() map[string]string {
|
||||||
if pushCount, err := strconv.Atoi(os.Getenv(private.GitPushOptionCount)); err == nil {
|
if pushCount, err := strconv.Atoi(os.Getenv(private.GitPushOptionCount)); err == nil {
|
||||||
for idx := 0; idx < pushCount; idx++ {
|
for idx := 0; idx < pushCount; idx++ {
|
||||||
opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx))
|
opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx))
|
||||||
kv := strings.SplitN(opt, "=", 2)
|
key, value, found := strings.Cut(opt, "=")
|
||||||
if len(kv) == 2 {
|
if !found {
|
||||||
opts[kv[0]] = kv[1]
|
value = "true"
|
||||||
}
|
}
|
||||||
|
opts[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return opts
|
return opts
|
||||||
|
@ -636,10 +637,11 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
kv := strings.SplitN(string(rs.Data), "=", 2)
|
key, value, found := strings.Cut(string(rs.Data), "=")
|
||||||
if len(kv) == 2 {
|
if !found {
|
||||||
hookOptions.GitPushOptions[kv[0]] = kv[1]
|
value = "true"
|
||||||
}
|
}
|
||||||
|
hookOptions.GitPushOptions[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,8 +696,7 @@ Forgejo or set your environment appropriately.`, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
commitID, _ := git.NewIDFromString(rs.OldOID)
|
if !git.IsEmptyCommitID(rs.OldOID, nil) {
|
||||||
if !commitID.IsZero() {
|
|
||||||
err = writeDataPktLine(ctx, os.Stdout, []byte("option old-oid "+rs.OldOID))
|
err = writeDataPktLine(ctx, os.Stdout, []byte("option old-oid "+rs.OldOID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
126
cmd/hook_test.go
126
cmd/hook_test.go
|
@ -7,12 +7,41 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/private"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Capture what's being written into a standard file descriptor.
|
||||||
|
func captureOutput(t *testing.T, stdFD *os.File) (finish func() (output string)) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
r, w, err := os.Pipe()
|
||||||
|
require.NoError(t, err)
|
||||||
|
resetStdout := test.MockVariableValue(stdFD, *w)
|
||||||
|
|
||||||
|
return func() (output string) {
|
||||||
|
w.Close()
|
||||||
|
resetStdout()
|
||||||
|
|
||||||
|
out, err := io.ReadAll(r)
|
||||||
|
require.NoError(t, err)
|
||||||
|
return string(out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPktLine(t *testing.T) {
|
func TestPktLine(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
@ -83,3 +112,100 @@ func TestPktLine(t *testing.T) {
|
||||||
assert.Empty(t, w.Bytes())
|
assert.Empty(t, w.Bytes())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDelayWriter(t *testing.T) {
|
||||||
|
// Setup the environment.
|
||||||
|
defer test.MockVariableValue(&setting.InternalToken, "Random")()
|
||||||
|
defer test.MockVariableValue(&setting.InstallLock, true)()
|
||||||
|
defer test.MockVariableValue(&setting.Git.VerbosePush, true)()
|
||||||
|
require.NoError(t, os.Setenv("SSH_ORIGINAL_COMMAND", "true"))
|
||||||
|
|
||||||
|
// Setup the Stdin.
|
||||||
|
f, err := os.OpenFile(t.TempDir()+"/stdin", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o666)
|
||||||
|
require.NoError(t, err)
|
||||||
|
_, err = f.Write([]byte("00000000000000000000 00000000000000000001 refs/head/main\n"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
_, err = f.Seek(0, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer test.MockVariableValue(os.Stdin, *f)()
|
||||||
|
|
||||||
|
// Setup the server that processes the hooks.
|
||||||
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
time.Sleep(time.Millisecond * 600)
|
||||||
|
}))
|
||||||
|
defer ts.Close()
|
||||||
|
defer test.MockVariableValue(&setting.LocalURL, ts.URL+"/")()
|
||||||
|
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Commands = []*cli.Command{subcmdHookPreReceive}
|
||||||
|
|
||||||
|
t.Run("Should delay", func(t *testing.T) {
|
||||||
|
defer test.MockVariableValue(&setting.Git.VerbosePushDelay, time.Millisecond*500)()
|
||||||
|
finish := captureOutput(t, os.Stdout)
|
||||||
|
|
||||||
|
err = app.Run([]string{"./forgejo", "pre-receive"})
|
||||||
|
require.NoError(t, err)
|
||||||
|
out := finish()
|
||||||
|
|
||||||
|
require.Contains(t, out, "* Checking 1 references")
|
||||||
|
require.Contains(t, out, "Checked 1 references in total")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Shouldn't delay", func(t *testing.T) {
|
||||||
|
defer test.MockVariableValue(&setting.Git.VerbosePushDelay, time.Second*5)()
|
||||||
|
finish := captureOutput(t, os.Stdout)
|
||||||
|
|
||||||
|
err = app.Run([]string{"./forgejo", "pre-receive"})
|
||||||
|
require.NoError(t, err)
|
||||||
|
out := finish()
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, out)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPushOptions(t *testing.T) {
|
||||||
|
require.NoError(t, os.Setenv(private.GitPushOptionCount, "3"))
|
||||||
|
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_0", "force-push"))
|
||||||
|
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_1", "option=value"))
|
||||||
|
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_2", "option-double=another=value"))
|
||||||
|
require.NoError(t, os.Setenv("GIT_PUSH_OPTION_3", "not=valid"))
|
||||||
|
|
||||||
|
assert.Equal(t, map[string]string{
|
||||||
|
"force-push": "true",
|
||||||
|
"option": "value",
|
||||||
|
"option-double": "another=value",
|
||||||
|
}, pushOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRunHookUpdate(t *testing.T) {
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Commands = []*cli.Command{subcmdHookUpdate}
|
||||||
|
|
||||||
|
t.Run("Removal of internal reference", func(t *testing.T) {
|
||||||
|
defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
|
||||||
|
defer test.MockVariableValue(&setting.IsProd, false)()
|
||||||
|
finish := captureOutput(t, os.Stderr)
|
||||||
|
|
||||||
|
err := app.Run([]string{"./forgejo", "update", "refs/pull/1/head", "0a51ae26bc73c47e2f754560c40904cf14ed51a9", "0000000000000000000000000000000000000000"})
|
||||||
|
out := finish()
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
assert.Contains(t, out, "The deletion of refs/pull/1/head is skipped as it's an internal reference.")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Update of internal reference", func(t *testing.T) {
|
||||||
|
err := app.Run([]string{"./forgejo", "update", "refs/pull/1/head", "0a51ae26bc73c47e2f754560c40904cf14ed51a9", "0000000000000000000000000000000000000001"})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Removal of branch", func(t *testing.T) {
|
||||||
|
err := app.Run([]string{"./forgejo", "update", "refs/head/main", "0a51ae26bc73c47e2f754560c40904cf14ed51a9", "0000000000000000000000000000000000000000"})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Not enough arguments", func(t *testing.T) {
|
||||||
|
err := app.Run([]string{"./forgejo", "update"})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ var CmdMigrateStorage = &cli.Command{
|
||||||
Name: "type",
|
Name: "type",
|
||||||
Aliases: []string{"t"},
|
Aliases: []string{"t"},
|
||||||
Value: "",
|
Value: "",
|
||||||
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log'",
|
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages', 'actions-log', 'actions-artifacts'",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "storage",
|
Name: "storage",
|
||||||
|
@ -160,6 +160,13 @@ func migrateActionsLog(ctx context.Context, dstStorage storage.ObjectStorage) er
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func migrateActionsArtifacts(ctx context.Context, dstStorage storage.ObjectStorage) error {
|
||||||
|
return db.Iterate(ctx, nil, func(ctx context.Context, artifact *actions_model.ActionArtifact) error {
|
||||||
|
_, err := storage.Copy(dstStorage, artifact.ArtifactPath, storage.ActionsArtifacts, artifact.ArtifactPath)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func runMigrateStorage(ctx *cli.Context) error {
|
func runMigrateStorage(ctx *cli.Context) error {
|
||||||
stdCtx, cancel := installSignals()
|
stdCtx, cancel := installSignals()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
@ -230,6 +237,7 @@ func runMigrateStorage(ctx *cli.Context) error {
|
||||||
"repo-archivers": migrateRepoArchivers,
|
"repo-archivers": migrateRepoArchivers,
|
||||||
"packages": migratePackages,
|
"packages": migratePackages,
|
||||||
"actions-log": migrateActionsLog,
|
"actions-log": migrateActionsLog,
|
||||||
|
"actions-artifacts": migrateActionsArtifacts,
|
||||||
}
|
}
|
||||||
|
|
||||||
tp := strings.ToLower(ctx.String("type"))
|
tp := strings.ToLower(ctx.String("type"))
|
||||||
|
|
|
@ -114,7 +114,7 @@ func showWebStartupMessage(msg string) {
|
||||||
log.Info("* WorkPath: %s", setting.AppWorkPath)
|
log.Info("* WorkPath: %s", setting.AppWorkPath)
|
||||||
log.Info("* CustomPath: %s", setting.CustomPath)
|
log.Info("* CustomPath: %s", setting.CustomPath)
|
||||||
log.Info("* ConfigFile: %s", setting.CustomConf)
|
log.Info("* ConfigFile: %s", setting.CustomConf)
|
||||||
log.Info("%s", msg)
|
log.Info("%s", msg) // show startup message
|
||||||
}
|
}
|
||||||
|
|
||||||
func serveInstall(ctx *cli.Context) error {
|
func serveInstall(ctx *cli.Context) error {
|
||||||
|
|
|
@ -222,6 +222,9 @@ RUN_USER = ; git
|
||||||
;; Enable exposure of SSH clone URL to anonymous visitors, default is false
|
;; Enable exposure of SSH clone URL to anonymous visitors, default is false
|
||||||
;SSH_EXPOSE_ANONYMOUS = false
|
;SSH_EXPOSE_ANONYMOUS = false
|
||||||
;;
|
;;
|
||||||
|
;; Command template for authorized keys entries
|
||||||
|
;SSH_AUTHORIZED_KEYS_COMMAND_TEMPLATE = {{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}
|
||||||
|
;;
|
||||||
;; Timeout for any write to ssh connections. (Set to -1 to disable all timeouts.)
|
;; Timeout for any write to ssh connections. (Set to -1 to disable all timeouts.)
|
||||||
;; Will default to the PER_WRITE_TIMEOUT.
|
;; Will default to the PER_WRITE_TIMEOUT.
|
||||||
;SSH_PER_WRITE_TIMEOUT = 30s
|
;SSH_PER_WRITE_TIMEOUT = 30s
|
||||||
|
@ -407,6 +410,9 @@ USER = root
|
||||||
;; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
|
;; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
|
||||||
;CONN_MAX_LIFETIME = 3s
|
;CONN_MAX_LIFETIME = 3s
|
||||||
;;
|
;;
|
||||||
|
;; Database connection max idle time, 0 prevents closing due to idle time.
|
||||||
|
;CONN_MAX_IDLETIME = 0
|
||||||
|
;;
|
||||||
;; Database maximum number of open connections, default is 0 meaning no maximum
|
;; Database maximum number of open connections, default is 0 meaning no maximum
|
||||||
;MAX_OPEN_CONNS = 0
|
;MAX_OPEN_CONNS = 0
|
||||||
;;
|
;;
|
||||||
|
@ -443,9 +449,6 @@ INTERNAL_TOKEN =
|
||||||
;; How long to remember that a user is logged in before requiring relogin (in days)
|
;; How long to remember that a user is logged in before requiring relogin (in days)
|
||||||
;LOGIN_REMEMBER_DAYS = 31
|
;LOGIN_REMEMBER_DAYS = 31
|
||||||
;;
|
;;
|
||||||
;; Name of the cookie used to store the current username.
|
|
||||||
;COOKIE_USERNAME = gitea_awesome
|
|
||||||
;;
|
|
||||||
;; Name of cookie used to store authentication information.
|
;; Name of cookie used to store authentication information.
|
||||||
;COOKIE_REMEMBER_NAME = gitea_incredible
|
;COOKIE_REMEMBER_NAME = gitea_incredible
|
||||||
;;
|
;;
|
||||||
|
@ -689,6 +692,12 @@ LEVEL = Info
|
||||||
;; Set the default branches range size
|
;; Set the default branches range size
|
||||||
;BRANCHES_RANGE_SIZE = 20
|
;BRANCHES_RANGE_SIZE = 20
|
||||||
;;
|
;;
|
||||||
|
;; Print out verbose infos on push to stdout
|
||||||
|
;VERBOSE_PUSH = true
|
||||||
|
;;
|
||||||
|
;; Delay before verbose push infos are printed to stdout
|
||||||
|
;VERBOSE_PUSH_DELAY = 5s
|
||||||
|
;;
|
||||||
;; Arguments for command 'git gc', e.g. "--aggressive --auto"
|
;; Arguments for command 'git gc', e.g. "--aggressive --auto"
|
||||||
;; see more on http://git-scm.com/docs/git-gc/
|
;; see more on http://git-scm.com/docs/git-gc/
|
||||||
;GC_ARGS =
|
;GC_ARGS =
|
||||||
|
@ -784,6 +793,11 @@ LEVEL = Info
|
||||||
;; Enable this to require captcha validation for login
|
;; Enable this to require captcha validation for login
|
||||||
;REQUIRE_CAPTCHA_FOR_LOGIN = false
|
;REQUIRE_CAPTCHA_FOR_LOGIN = false
|
||||||
;;
|
;;
|
||||||
|
;; Requires captcha for external registrations
|
||||||
|
;REQUIRE_EXTERNAL_REGISTRATION_CAPTCHA = false
|
||||||
|
;; Requires a password for external registrations
|
||||||
|
;REQUIRE_EXTERNAL_REGISTRATION_PASSWORD = false
|
||||||
|
;;
|
||||||
;; Type of captcha you want to use. Options: image, recaptcha, hcaptcha, mcaptcha, cfturnstile.
|
;; Type of captcha you want to use. Options: image, recaptcha, hcaptcha, mcaptcha, cfturnstile.
|
||||||
;CAPTCHA_TYPE = image
|
;CAPTCHA_TYPE = image
|
||||||
;;
|
;;
|
||||||
|
@ -953,7 +967,7 @@ LEVEL = Info
|
||||||
;;
|
;;
|
||||||
;; Preferred Licenses to place at the top of the List
|
;; Preferred Licenses to place at the top of the List
|
||||||
;; The name here must match the filename in options/license or custom/options/license
|
;; The name here must match the filename in options/license or custom/options/license
|
||||||
;PREFERRED_LICENSES = Apache License 2.0,MIT License
|
;PREFERRED_LICENSES = Apache-2.0,MIT
|
||||||
;;
|
;;
|
||||||
;; Disable the ability to interact with repositories using the HTTP protocol
|
;; Disable the ability to interact with repositories using the HTTP protocol
|
||||||
;DISABLE_HTTP_GIT = false
|
;DISABLE_HTTP_GIT = false
|
||||||
|
@ -1088,6 +1102,9 @@ LEVEL = Info
|
||||||
;; In default merge messages only include approvers who are official
|
;; In default merge messages only include approvers who are official
|
||||||
;DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true
|
;DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true
|
||||||
;;
|
;;
|
||||||
|
;; If an squash commit's comment should be populated with the commit messages of the squashed commits
|
||||||
|
;POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES = false
|
||||||
|
;;
|
||||||
;; Add co-authored-by and co-committed-by trailers if committer does not match author
|
;; Add co-authored-by and co-committed-by trailers if committer does not match author
|
||||||
;ADD_CO_COMMITTER_TRAILERS = true
|
;ADD_CO_COMMITTER_TRAILERS = true
|
||||||
;;
|
;;
|
||||||
|
@ -1103,7 +1120,7 @@ LEVEL = Info
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; List of reasons why a Pull Request or Issue can be locked
|
;; List of reasons why a Pull Request or Issue can be locked
|
||||||
;LOCK_REASONS = Too heated,Off-topic,Resolved,Spam
|
;LOCK_REASONS = Too heated,Off-topic,Spam,Resolved
|
||||||
;; Maximum number of pinned Issues per repo
|
;; Maximum number of pinned Issues per repo
|
||||||
;; Set to 0 to disable pinning Issues
|
;; Set to 0 to disable pinning Issues
|
||||||
;MAX_PINNED = 3
|
;MAX_PINNED = 3
|
||||||
|
@ -1219,6 +1236,12 @@ LEVEL = Info
|
||||||
;; Number of issues that are displayed on one page
|
;; Number of issues that are displayed on one page
|
||||||
;ISSUE_PAGING_NUM = 20
|
;ISSUE_PAGING_NUM = 20
|
||||||
;;
|
;;
|
||||||
|
;; Number of repositories that are displayed on one page when searching.
|
||||||
|
;REPO_SEARCH_PAGING_NUM = 20
|
||||||
|
;;
|
||||||
|
;; Number of members that are displayed on one page
|
||||||
|
;MEMBERS_PAGING_NUM = 20
|
||||||
|
;;
|
||||||
;; Number of maximum commits displayed in one activity feed
|
;; Number of maximum commits displayed in one activity feed
|
||||||
;FEED_MAX_COMMIT_NUM = 5
|
;FEED_MAX_COMMIT_NUM = 5
|
||||||
;;
|
;;
|
||||||
|
@ -1228,6 +1251,9 @@ LEVEL = Info
|
||||||
;; Number of items that are displayed in a single subsitemap
|
;; Number of items that are displayed in a single subsitemap
|
||||||
;SITEMAP_PAGING_NUM = 20
|
;SITEMAP_PAGING_NUM = 20
|
||||||
;;
|
;;
|
||||||
|
;; Number of packages that are displayed on one page
|
||||||
|
;PACKAGES_PAGING_NUM = 20
|
||||||
|
;;
|
||||||
;; Number of maximum commits displayed in commit graph.
|
;; Number of maximum commits displayed in commit graph.
|
||||||
;GRAPH_MAX_COMMIT_NUM = 100
|
;GRAPH_MAX_COMMIT_NUM = 100
|
||||||
;;
|
;;
|
||||||
|
@ -1244,9 +1270,14 @@ LEVEL = Info
|
||||||
;SHOW_USER_EMAIL = true
|
;SHOW_USER_EMAIL = true
|
||||||
;;
|
;;
|
||||||
;; Set the default theme for the Gitea install
|
;; Set the default theme for the Gitea install
|
||||||
;DEFAULT_THEME = gitea-auto
|
;DEFAULT_THEME = forgejo-auto
|
||||||
;;
|
;;
|
||||||
;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
|
;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
|
||||||
|
;; By default available:
|
||||||
|
;; - forgejo-auto, forgejo-light, forgejo-dark
|
||||||
|
;; - gitea-auto, gitea-light, gitea-dark
|
||||||
|
;; - forgejo-auto-deuteranopia-protanopia, forgejo-light-deuteranopia-protanopia, forgejo-dark-deuteranopia-protanopia
|
||||||
|
;; - forgejo-auto-tritanopia, forgejo-light-tritanopia, forgejo-dark-tritanopia
|
||||||
;THEMES = gitea-auto,gitea-light,gitea-dark
|
;THEMES = gitea-auto,gitea-light,gitea-dark
|
||||||
;;
|
;;
|
||||||
;; All available reactions users can choose on issues/prs and comments.
|
;; All available reactions users can choose on issues/prs and comments.
|
||||||
|
@ -1260,7 +1291,7 @@ LEVEL = Info
|
||||||
;; Additional Emojis not defined in the utf8 standard
|
;; Additional Emojis not defined in the utf8 standard
|
||||||
;; By default we support gitea (:gitea:), to add more copy them to public/assets/img/emoji/emoji_name.png and add it to this config.
|
;; By default we support gitea (:gitea:), to add more copy them to public/assets/img/emoji/emoji_name.png and add it to this config.
|
||||||
;; Dont mistake it for Reactions.
|
;; Dont mistake it for Reactions.
|
||||||
;CUSTOM_EMOJIS = gitea, codeberg, gitlab, git, github, gogs
|
;CUSTOM_EMOJIS = gitea, codeberg, gitlab, git, github, gogs, forgejo
|
||||||
;;
|
;;
|
||||||
;; Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
|
;; Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
|
||||||
;DEFAULT_SHOW_FULL_NAME = false
|
;DEFAULT_SHOW_FULL_NAME = false
|
||||||
|
@ -1445,6 +1476,11 @@ LEVEL = Info
|
||||||
;; A comma separated list of glob patterns to exclude from the index; ; default is empty
|
;; A comma separated list of glob patterns to exclude from the index; ; default is empty
|
||||||
;REPO_INDEXER_EXCLUDE =
|
;REPO_INDEXER_EXCLUDE =
|
||||||
;;
|
;;
|
||||||
|
;; If vendored files should be excluded.
|
||||||
|
;; See https://github.com/go-enry/go-enry for more details which files are considered to be vendored.
|
||||||
|
;REPO_INDEXER_EXCLUDE_VENDORED = true
|
||||||
|
;;
|
||||||
|
;; The maximum filesize to include for indexing
|
||||||
;MAX_FILE_SIZE = 1048576
|
;MAX_FILE_SIZE = 1048576
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -1531,7 +1567,7 @@ LEVEL = Info
|
||||||
;;
|
;;
|
||||||
;; Whether to allow registering via OpenID
|
;; Whether to allow registering via OpenID
|
||||||
;; Do not include to rely on rhw DISABLE_REGISTRATION setting
|
;; Do not include to rely on rhw DISABLE_REGISTRATION setting
|
||||||
;;ENABLE_OPENID_SIGNUP = true
|
;ENABLE_OPENID_SIGNUP = true
|
||||||
;;
|
;;
|
||||||
;; Allowed URI patterns (POSIX regexp).
|
;; Allowed URI patterns (POSIX regexp).
|
||||||
;; Space separated.
|
;; Space separated.
|
||||||
|
@ -1807,6 +1843,9 @@ LEVEL = Info
|
||||||
;; Session life time in seconds, default is 86400 (1 day)
|
;; Session life time in seconds, default is 86400 (1 day)
|
||||||
;SESSION_LIFE_TIME = 86400
|
;SESSION_LIFE_TIME = 86400
|
||||||
;;
|
;;
|
||||||
|
;; Cookie domain name. Default is empty
|
||||||
|
;DOMAIN =
|
||||||
|
;;
|
||||||
;; SameSite settings. Either "none", "lax", or "strict"
|
;; SameSite settings. Either "none", "lax", or "strict"
|
||||||
;SAME_SITE=lax
|
;SAME_SITE=lax
|
||||||
|
|
||||||
|
@ -1859,7 +1898,7 @@ LEVEL = Info
|
||||||
;ENABLED = true
|
;ENABLED = true
|
||||||
;;
|
;;
|
||||||
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
|
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
|
||||||
;ALLOWED_TYPES = .csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip
|
;ALLOWED_TYPES = .cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip
|
||||||
;;
|
;;
|
||||||
;; Max size of each file. Defaults to 2048MB
|
;; Max size of each file. Defaults to 2048MB
|
||||||
;MAX_SIZE = 2048
|
;MAX_SIZE = 2048
|
||||||
|
@ -1891,6 +1930,11 @@ LEVEL = Info
|
||||||
;; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
|
;; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
|
||||||
;MINIO_BUCKET = gitea
|
;MINIO_BUCKET = gitea
|
||||||
;;
|
;;
|
||||||
|
;; Url lookup for the minio bucket only available when STORAGE_TYPE is `minio`
|
||||||
|
;; Available values: auto, dns, path
|
||||||
|
;; If empty, it behaves the same as "auto" was set
|
||||||
|
;MINIO_BUCKET_LOOKUP =
|
||||||
|
;;
|
||||||
;; Minio location to create bucket only available when STORAGE_TYPE is `minio`
|
;; Minio location to create bucket only available when STORAGE_TYPE is `minio`
|
||||||
;MINIO_LOCATION = us-east-1
|
;MINIO_LOCATION = us-east-1
|
||||||
;;
|
;;
|
||||||
|
@ -2043,6 +2087,17 @@ LEVEL = Info
|
||||||
;; or only create new users if UPDATE_EXISTING is set to false
|
;; or only create new users if UPDATE_EXISTING is set to false
|
||||||
;UPDATE_EXISTING = true
|
;UPDATE_EXISTING = true
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Cleanup expired actions assets
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;[cron.cleanup_actions]
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;ENABLED = true
|
||||||
|
;RUN_AT_START = true
|
||||||
|
;SCHEDULE = @midnight
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Clean-up deleted branches
|
;; Clean-up deleted branches
|
||||||
|
@ -2338,6 +2393,8 @@ LEVEL = Info
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Set the maximum number of characters in a mermaid source. (Set to -1 to disable limits)
|
;; Set the maximum number of characters in a mermaid source. (Set to -1 to disable limits)
|
||||||
;MERMAID_MAX_SOURCE_CHARACTERS = 5000
|
;MERMAID_MAX_SOURCE_CHARACTERS = 5000
|
||||||
|
;; Set the maximum number of lines allowed for a filepreview. (Set to -1 to disable limits; set to 0 to disable the feature)
|
||||||
|
;FILEPREVIEW_MAX_LINES = 50
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -2385,22 +2442,6 @@ LEVEL = Info
|
||||||
;; Enable issue by repository metrics; default is false
|
;; Enable issue by repository metrics; default is false
|
||||||
;ENABLED_ISSUE_BY_REPOSITORY = false
|
;ENABLED_ISSUE_BY_REPOSITORY = false
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;[task]
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;;
|
|
||||||
;; Task queue type, could be `channel` or `redis`.
|
|
||||||
;QUEUE_TYPE = channel
|
|
||||||
;;
|
|
||||||
;; Task queue length, available only when `QUEUE_TYPE` is `channel`.
|
|
||||||
;QUEUE_LENGTH = 1000
|
|
||||||
;;
|
|
||||||
;; Task queue connection string, available only when `QUEUE_TYPE` is `redis`.
|
|
||||||
;; If there is a password of redis, use `redis://127.0.0.1:6379/0?pool_size=100&idle_timeout=180s` or `redis+cluster://127.0.0.1:6379/0?pool_size=100&idle_timeout=180s` for `redis-clsuter`.
|
|
||||||
;QUEUE_CONN_STR = "redis://127.0.0.1:6379/0?pool_size=100&idle_timeout=180s"
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;[migrations]
|
;[migrations]
|
||||||
|
@ -2426,6 +2467,9 @@ LEVEL = Info
|
||||||
;; Allow private addresses defined by RFC 1918, RFC 1122, RFC 4632 and RFC 4291 (false by default)
|
;; Allow private addresses defined by RFC 1918, RFC 1122, RFC 4632 and RFC 4291 (false by default)
|
||||||
;; If a domain is allowed by ALLOWED_DOMAINS, this option will be ignored.
|
;; If a domain is allowed by ALLOWED_DOMAINS, this option will be ignored.
|
||||||
;ALLOW_LOCALNETWORKS = false
|
;ALLOW_LOCALNETWORKS = false
|
||||||
|
;;
|
||||||
|
;; If set to true, completely ignores server certificate validation errors. This option is unsafe.
|
||||||
|
;SKIP_TLS_VERIFY = false
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -2593,6 +2637,11 @@ LEVEL = Info
|
||||||
;; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
|
;; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
|
||||||
;MINIO_BUCKET = gitea
|
;MINIO_BUCKET = gitea
|
||||||
;;
|
;;
|
||||||
|
;; Url lookup for the minio bucket only available when STORAGE_TYPE is `minio`
|
||||||
|
;; Available values: auto, dns, path
|
||||||
|
;; If empty, it behaves the same as "auto" was set
|
||||||
|
;MINIO_BUCKET_LOOKUP =
|
||||||
|
;;
|
||||||
;; Minio location to create bucket only available when STORAGE_TYPE is `minio`
|
;; Minio location to create bucket only available when STORAGE_TYPE is `minio`
|
||||||
;MINIO_LOCATION = us-east-1
|
;MINIO_LOCATION = us-east-1
|
||||||
;;
|
;;
|
||||||
|
@ -2635,3 +2684,13 @@ LEVEL = Info
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; storage type
|
;; storage type
|
||||||
;STORAGE_TYPE = local
|
;STORAGE_TYPE = local
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; settings for action artifacts, will override storage setting
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;[storage.actions_artifacts]
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; storage type
|
||||||
|
;STORAGE_TYPE = local
|
||||||
|
|
7
docs/.gitignore
vendored
7
docs/.gitignore
vendored
|
@ -1,7 +0,0 @@
|
||||||
public/
|
|
||||||
templates/swagger/v1_json.tmpl
|
|
||||||
themes/
|
|
||||||
resources/
|
|
||||||
|
|
||||||
# Temporary lock file while building
|
|
||||||
/.hugo_build.lock
|
|
202
docs/LICENSE
202
docs/LICENSE
|
@ -1,202 +0,0 @@
|
||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
|
@ -1,22 +0,0 @@
|
||||||
# Gitea: Docs
|
|
||||||
|
|
||||||
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
|
|
||||||
[![](https://images.microbadger.com/badges/image/gitea/docs.svg)](http://microbadger.com/images/gitea/docs "Get your own image badge on microbadger.com")
|
|
||||||
|
|
||||||
These docs are ingested by our [docs repo](https://gitea.com/gitea/gitea-docusaurus).
|
|
||||||
|
|
||||||
## Authors
|
|
||||||
|
|
||||||
* [Maintainers](https://github.com/orgs/go-gitea/people)
|
|
||||||
* [Contributors](https://github.com/go-gitea/docs/graphs/contributors)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is under the Apache-2.0 License. See the [LICENSE](LICENSE) file
|
|
||||||
for the full license text.
|
|
||||||
|
|
||||||
## Copyright
|
|
||||||
|
|
||||||
```
|
|
||||||
Copyright (c) 2016 The Gitea Authors <https://gitea.io>
|
|
||||||
```
|
|
|
@ -1,22 +0,0 @@
|
||||||
# Gitea: 文档
|
|
||||||
|
|
||||||
[![Build Status](http://drone.gitea.io/api/badges/go-gitea/docs/status.svg)](http://drone.gitea.io/go-gitea/docs)
|
|
||||||
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
|
|
||||||
[![](https://images.microbadger.com/badges/image/gitea/docs.svg)](http://microbadger.com/images/gitea/docs "Get your own image badge on microbadger.com")
|
|
||||||
|
|
||||||
https://gitea.com/gitea/gitea-docusaurus
|
|
||||||
|
|
||||||
## 关于我们
|
|
||||||
|
|
||||||
* [维护者信息](https://github.com/orgs/go-gitea/people)
|
|
||||||
* [代码贡献者信息](https://github.com/go-gitea/docs/graphs/contributors)
|
|
||||||
|
|
||||||
## 许可证
|
|
||||||
|
|
||||||
此项目采用 Apache-2.0 许可协议,请参见 [协议文件](LICENSE) 获取更多信息。
|
|
||||||
|
|
||||||
## 版权声明
|
|
||||||
|
|
||||||
```
|
|
||||||
Copyright (c) 2016 The Gitea Authors <https://gitea.io>
|
|
||||||
```
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-04-27T14:00:00+08:00"
|
|
||||||
title: "Actions"
|
|
||||||
slug: "actions"
|
|
||||||
sidebar_position: 36
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "Usage - Actions"
|
|
||||||
sidebar_position: 31
|
|
||||||
identifier: "actions"
|
|
||||||
---
|
|
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "Administration"
|
|
||||||
slug: "administration"
|
|
||||||
sidebar_position: 30
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "Administration"
|
|
||||||
sidebar_position: 20
|
|
||||||
collapse: true
|
|
||||||
identifier: "administration"
|
|
||||||
---
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "运维"
|
|
||||||
slug: "administration"
|
|
||||||
sidebar_position: 30
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "运维"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "administration"
|
|
||||||
---
|
|
|
@ -1,40 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-12-28"
|
|
||||||
title: "Adding Legal Pages"
|
|
||||||
slug: adding-legal-pages
|
|
||||||
sidebar_position: 110
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/adding-legal-pages
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Adding Legal Pages"
|
|
||||||
identifier: "adding-legal-pages"
|
|
||||||
sidebar_position: 110
|
|
||||||
---
|
|
||||||
|
|
||||||
Some jurisdictions (such as EU), requires certain legal pages (e.g. Privacy Policy) to be added to website. Follow these steps to add them to your Gitea instance.
|
|
||||||
|
|
||||||
## Getting Pages
|
|
||||||
|
|
||||||
Gitea source code ships with sample pages, available in `contrib/legal` directory. Copy them to `custom/public/assets/`. For example, to add Privacy Policy:
|
|
||||||
|
|
||||||
```
|
|
||||||
wget -O /path/to/custom/public/assets/privacy.html https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/legal/privacy.html.sample
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you need to edit the page to meet your requirements. In particular you must change the email addresses, web addresses and references to "Your Gitea Instance" to match your situation.
|
|
||||||
|
|
||||||
You absolutely must not place a general ToS or privacy statement that implies that the Gitea project is responsible for your server.
|
|
||||||
|
|
||||||
## Make it Visible
|
|
||||||
|
|
||||||
Create or append to `/path/to/custom/templates/custom/extra_links_footer.tmpl`:
|
|
||||||
|
|
||||||
```go
|
|
||||||
<a class="item" href="{{AppSubUrl}}/assets/privacy.html">Privacy Policy</a>
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart Gitea to see the changes.
|
|
|
@ -1,40 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "添加法律页面"
|
|
||||||
slug: adding-legal-pages
|
|
||||||
sidebar_position: 110
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/adding-legal-pages
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "添加法律页面"
|
|
||||||
identifier: "adding-legal-pages"
|
|
||||||
sidebar_position: 110
|
|
||||||
---
|
|
||||||
|
|
||||||
一些法域(例如欧盟)要求在网站上添加特定的法律页面(例如隐私政策)。按照以下步骤将它们添加到你的 Gitea 实例中。
|
|
||||||
|
|
||||||
## 获取页面
|
|
||||||
|
|
||||||
Gitea 源代码附带了示例页面,位于 `contrib/legal` 目录中。将它们复制到 `custom/public/assets/` 目录下。例如,如果要添加隐私政策:
|
|
||||||
|
|
||||||
```
|
|
||||||
wget -O /path/to/custom/public/assets/privacy.html https://raw.githubusercontent.com/go-gitea/gitea/main/contrib/legal/privacy.html.sample
|
|
||||||
```
|
|
||||||
|
|
||||||
现在,你需要编辑该页面以满足你的需求。特别是,你必须更改电子邮件地址、网址以及与 "Your Gitea Instance" 相关的引用,以匹配你的情况。
|
|
||||||
|
|
||||||
请务必不要放置会暗示 Gitea 项目对你的服务器负责的一般服务条款或隐私声明。
|
|
||||||
|
|
||||||
## 使其可见
|
|
||||||
|
|
||||||
创建或追加到 `/path/to/custom/templates/custom/extra_links_footer.tmpl` 文件中:
|
|
||||||
|
|
||||||
```go
|
|
||||||
<a class="item" href="{{AppSubUrl}}/assets/privacy.html">隐私政策</a>
|
|
||||||
```
|
|
||||||
|
|
||||||
重启 Gitea 以查看更改。
|
|
|
@ -1,158 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-01-01T16:00:00+02:00"
|
|
||||||
title: "Backup and Restore"
|
|
||||||
slug: "backup-and-restore"
|
|
||||||
sidebar_position: 11
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/backup-and-restore
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Backup and Restore"
|
|
||||||
sidebar_position: 11
|
|
||||||
identifier: "backup-and-restore"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Backup and Restore
|
|
||||||
|
|
||||||
Gitea currently has a `dump` command that will save the installation to a ZIP file. This
|
|
||||||
file can be unpacked and used to restore an instance.
|
|
||||||
|
|
||||||
## Backup Consistency
|
|
||||||
|
|
||||||
To ensure the consistency of the Gitea instance, it must be shutdown during backup.
|
|
||||||
|
|
||||||
Gitea consists of a database, files and git repositories, all of which change when it is used. For instance, when a migration is in progress, a transaction is created in the database while the git repository is being copied over. If the backup happens in the middle of the migration, the git repository may be incomplete although the database claims otherwise because it was dumped afterwards. The only way to avoid such race conditions is by stopping the Gitea instance during the backups.
|
|
||||||
|
|
||||||
## Backup Command (`dump`)
|
|
||||||
|
|
||||||
Switch to the user running Gitea: `su git`. Run `./gitea dump -c /path/to/app.ini` in the Gitea installation
|
|
||||||
directory. There should be some output similar to the following:
|
|
||||||
|
|
||||||
```none
|
|
||||||
2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001
|
|
||||||
2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories
|
|
||||||
2016/12/27 22:32:22 Dumping database...
|
|
||||||
2016/12/27 22:32:22 Packing dump files...
|
|
||||||
2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001
|
|
||||||
2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
Inside the `gitea-dump-1482906742.zip` file, will be the following:
|
|
||||||
|
|
||||||
- `app.ini` - Optional copy of configuration file if originally stored outside the default `custom/` directory
|
|
||||||
- `custom/` - All config or customization files in `custom/`.
|
|
||||||
- `data/` - Data directory (APP_DATA_PATH), except sessions if you are using file session. This directory includes `attachments`, `avatars`, `lfs`, `indexers`, SQLite file if you are using SQLite.
|
|
||||||
- `repos/` - Complete copy of the repository directory.
|
|
||||||
- `gitea-db.sql` - SQL dump of database
|
|
||||||
- `log/` - Various logs. They are not needed for a recovery or migration.
|
|
||||||
|
|
||||||
Intermediate backup files are created in a temporary directory specified either with the
|
|
||||||
`--tempdir` command-line parameter or the `TMPDIR` environment variable.
|
|
||||||
|
|
||||||
## Backup the database
|
|
||||||
|
|
||||||
The SQL dump created by `gitea dump` uses XORM and Gitea admins may prefer to use the native the MySQL and PostgreSQL dump tools instead. There are still open issues when using XORM for dumping the database that may cause problems when attempting to restore it.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# mysql
|
|
||||||
mysqldump -u$USER -p$PASS --database $DATABASE > gitea-db.sql
|
|
||||||
# postgres
|
|
||||||
pg_dump -U $USER $DATABASE > gitea-db.sql
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using Docker (`dump`)
|
|
||||||
|
|
||||||
There are a few caveats for using the `dump` command with Docker.
|
|
||||||
|
|
||||||
The command has to be executed with the `RUN_USER = <OS_USERNAME>` specified in `gitea/conf/app.ini`; and, for the zipping of the backup folder to occur without permission error the command `docker exec` must be executed inside of the `--tempdir`.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```none
|
|
||||||
docker exec -u <OS_USERNAME> -it -w <--tempdir> $(docker ps -qf 'name=^<NAME_OF_DOCKER_CONTAINER>$') bash -c '/usr/local/bin/gitea dump -c </path/to/app.ini>'
|
|
||||||
```
|
|
||||||
|
|
||||||
\*Note: `--tempdir` refers to the temporary directory of the docker environment used by Gitea; if you have not specified a custom `--tempdir`, then Gitea uses `/tmp` or the `TMPDIR` environment variable of the docker container. For `--tempdir` adjust your `docker exec` command options accordingly.
|
|
||||||
|
|
||||||
The result should be a file, stored in the `--tempdir` specified, along the lines of: `gitea-dump-1482906742.zip`
|
|
||||||
|
|
||||||
## Restore Command (`restore`)
|
|
||||||
|
|
||||||
There is currently no support for a recovery command. It is a manual process that mostly
|
|
||||||
involves moving files to their correct locations and restoring a database dump.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
unzip gitea-dump-1610949662.zip
|
|
||||||
cd gitea-dump-1610949662
|
|
||||||
mv app.ini /etc/gitea/conf/app.ini
|
|
||||||
mv data/* /var/lib/gitea/data/
|
|
||||||
mv log/* /var/lib/gitea/log/
|
|
||||||
mv repos/* /var/lib/gitea/gitea-repositories/
|
|
||||||
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea
|
|
||||||
|
|
||||||
# mysql
|
|
||||||
mysql --default-character-set=utf8mb4 -u$USER -p$PASS $DATABASE <gitea-db.sql
|
|
||||||
# sqlite3
|
|
||||||
sqlite3 $DATABASE_PATH <gitea-db.sql
|
|
||||||
# postgres
|
|
||||||
psql -U $USER -d $DATABASE < gitea-db.sql
|
|
||||||
|
|
||||||
service gitea restart
|
|
||||||
```
|
|
||||||
|
|
||||||
Repository Git Hooks should be regenerated if installation method is changed (eg. binary -> Docker), or if Gitea is installed to a different directory than the previous installation.
|
|
||||||
|
|
||||||
With Gitea running, and from the directory Gitea's binary is located, execute: `./gitea admin regenerate hooks`
|
|
||||||
|
|
||||||
This ensures that application and configuration file paths in repository Git Hooks are consistent and applicable to the current installation. If these paths are not updated, repository `push` actions will fail.
|
|
||||||
|
|
||||||
### Using Docker (`restore`)
|
|
||||||
|
|
||||||
There is also no support for a recovery command in a Docker-based gitea instance. The restore process contains the same steps as described in the previous section but with different paths.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# open bash session in container
|
|
||||||
docker exec --user git -it 2a83b293548e bash
|
|
||||||
# unzip your backup file within the container
|
|
||||||
unzip gitea-dump-1610949662.zip
|
|
||||||
cd gitea-dump-1610949662
|
|
||||||
# restore the gitea data
|
|
||||||
mv data/* /data/gitea
|
|
||||||
# restore the repositories itself
|
|
||||||
mv repos/* /data/git/gitea-repositories/
|
|
||||||
# adjust file permissions
|
|
||||||
chown -R git:git /data
|
|
||||||
# Regenerate Git Hooks
|
|
||||||
/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks
|
|
||||||
```
|
|
||||||
|
|
||||||
The default user in the gitea container is `git` (1000:1000). Please replace `2a83b293548e` with your gitea container id or name.
|
|
||||||
|
|
||||||
### Using Docker-rootless (`restore`)
|
|
||||||
|
|
||||||
The restore workflow in Docker-rootless containers differs only in the directories to be used:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# open bash session in container
|
|
||||||
docker exec --user git -it 2a83b293548e bash
|
|
||||||
# unzip your backup file within the container
|
|
||||||
unzip gitea-dump-1610949662.zip
|
|
||||||
cd gitea-dump-1610949662
|
|
||||||
# restore the app.ini
|
|
||||||
mv data/conf/app.ini /etc/gitea/app.ini
|
|
||||||
# restore the gitea data
|
|
||||||
mv data/* /var/lib/gitea
|
|
||||||
# restore the repositories itself
|
|
||||||
mv repos/* /var/lib/gitea/git/gitea-repositories
|
|
||||||
# adjust file permissions
|
|
||||||
chown -R git:git /etc/gitea/app.ini /var/lib/gitea
|
|
||||||
# Regenerate Git Hooks
|
|
||||||
/usr/local/bin/gitea -c '/etc/gitea/app.ini' admin regenerate hooks
|
|
||||||
```
|
|
|
@ -1,68 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-06-06T09:33:00+08:00"
|
|
||||||
title: "备份与恢复"
|
|
||||||
slug: "backup-and-restore"
|
|
||||||
sidebar_position: 11
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/backup-and-restore
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "备份与恢复"
|
|
||||||
sidebar_position: 11
|
|
||||||
identifier: "backup-and-restore"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 备份与恢复
|
|
||||||
|
|
||||||
Gitea 已经实现了 `dump` 命令可以用来备份所有需要的文件到一个zip压缩文件。该压缩文件可以被用来进行数据恢复。
|
|
||||||
|
|
||||||
## 备份命令 (`dump`)
|
|
||||||
|
|
||||||
先转到git用户的权限: `su git`. 再Gitea目录运行 `./gitea dump`。一般会显示类似如下的输出:
|
|
||||||
|
|
||||||
```
|
|
||||||
2016/12/27 22:32:09 Creating tmp work dir: /tmp/gitea-dump-417443001
|
|
||||||
2016/12/27 22:32:09 Dumping local repositories.../home/git/gitea-repositories
|
|
||||||
2016/12/27 22:32:22 Dumping database...
|
|
||||||
2016/12/27 22:32:22 Packing dump files...
|
|
||||||
2016/12/27 22:32:34 Removing tmp work dir: /tmp/gitea-dump-417443001
|
|
||||||
2016/12/27 22:32:34 Finish dumping in file gitea-dump-1482906742.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
最后生成的 `gitea-dump-1482906742.zip` 文件将会包含如下内容:
|
|
||||||
|
|
||||||
* `custom` - 所有保存在 `custom/` 目录下的配置和自定义的文件。
|
|
||||||
* `data` - 数据目录下的所有内容不包含使用文件session的文件。该目录包含 `attachments`, `avatars`, `lfs`, `indexers`, 如果使用sqlite 还会包含 sqlite 数据库文件。
|
|
||||||
* `gitea-db.sql` - 数据库dump出来的 SQL。
|
|
||||||
* `gitea-repo.zip` - Git仓库压缩文件。
|
|
||||||
* `log/` - Logs文件,如果用作迁移不是必须的。
|
|
||||||
|
|
||||||
中间备份文件将会在临时目录进行创建,如果您要重新指定临时目录,可以用 `--tempdir` 参数,或者用 `TMPDIR` 环境变量。
|
|
||||||
|
|
||||||
## Restore Command (`restore`)
|
|
||||||
|
|
||||||
当前还没有恢复命令,恢复需要人工进行。主要是把文件和数据库进行恢复。
|
|
||||||
|
|
||||||
例如:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
unzip gitea-dump-1610949662.zip
|
|
||||||
cd gitea-dump-1610949662
|
|
||||||
mv data/conf/app.ini /etc/gitea/conf/app.ini
|
|
||||||
mv data/* /var/lib/gitea/data/
|
|
||||||
mv log/* /var/lib/gitea/log/
|
|
||||||
mv repos/* /var/lib/gitea/repositories/
|
|
||||||
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea
|
|
||||||
|
|
||||||
# mysql
|
|
||||||
mysql --default-character-set=utf8mb4 -u$USER -p$PASS $DATABASE <gitea-db.sql
|
|
||||||
# sqlite3
|
|
||||||
sqlite3 $DATABASE_PATH <gitea-db.sql
|
|
||||||
# postgres
|
|
||||||
psql -U $USER -d $DATABASE < gitea-db.sql
|
|
||||||
|
|
||||||
service gitea restart
|
|
||||||
```
|
|
|
@ -1,119 +0,0 @@
|
||||||
---
|
|
||||||
date: "2020-01-25T21:00:00-03:00"
|
|
||||||
title: "Embedded data extraction tool"
|
|
||||||
slug: "cmd-embedded"
|
|
||||||
sidebar_position: 20
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/cmd-embedded
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Embedded data extraction tool"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "cmd-embedded"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Embedded data extraction tool
|
|
||||||
|
|
||||||
Gitea's executable contains all the resources required to run: templates, images, style-sheets
|
|
||||||
and translations. Any of them can be overridden by placing a replacement in a matching path
|
|
||||||
inside the `custom` directory (see [Customizing Gitea](administration/customizing-gitea.md)).
|
|
||||||
|
|
||||||
To obtain a copy of the embedded resources ready for editing, the `embedded` command from the CLI
|
|
||||||
can be used from the OS shell interface.
|
|
||||||
|
|
||||||
**NOTE:** The embedded data extraction tool is included in Gitea versions 1.12 and above.
|
|
||||||
|
|
||||||
## Listing resources
|
|
||||||
|
|
||||||
To list resources embedded in Gitea's executable, use the following syntax:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
gitea embedded list [--include-vendored] [patterns...]
|
|
||||||
```
|
|
||||||
|
|
||||||
The `--include-vendored` flag makes the command include vendored files, which are
|
|
||||||
normally excluded; that is, files from external libraries that are required for Gitea
|
|
||||||
(e.g. [octicons](https://octicons.github.com/), etc).
|
|
||||||
|
|
||||||
A list of file search patterns can be provided. Gitea uses [gobwas/glob](https://github.com/gobwas/glob)
|
|
||||||
for its glob syntax. Here are some examples:
|
|
||||||
|
|
||||||
- List all template files, in any virtual directory: `**.tmpl`
|
|
||||||
- List all mail template files: `templates/mail/**.tmpl`
|
|
||||||
- List all files inside `public/assets/img`: `public/assets/img/**`
|
|
||||||
|
|
||||||
Don't forget to use quotes for the patterns, as spaces, `*` and other characters might have
|
|
||||||
a special meaning for your command shell.
|
|
||||||
|
|
||||||
If no pattern is provided, all files are listed.
|
|
||||||
|
|
||||||
### Example: Listing all embedded files
|
|
||||||
|
|
||||||
Listing all embedded files with `openid` in their path:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ gitea embedded list '**openid**'
|
|
||||||
public/assets/img/auth/openid_connect.svg
|
|
||||||
public/assets/img/openid-16x16.png
|
|
||||||
templates/user/auth/finalize_openid.tmpl
|
|
||||||
templates/user/auth/signin_openid.tmpl
|
|
||||||
templates/user/auth/signup_openid_connect.tmpl
|
|
||||||
templates/user/auth/signup_openid_navbar.tmpl
|
|
||||||
templates/user/auth/signup_openid_register.tmpl
|
|
||||||
templates/user/settings/security_openid.tmpl
|
|
||||||
```
|
|
||||||
|
|
||||||
## Extracting resources
|
|
||||||
|
|
||||||
To extract resources embedded in Gitea's executable, use the following syntax:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...}
|
|
||||||
```
|
|
||||||
|
|
||||||
The `--config` option tells Gitea the location of the `app.ini` configuration file if
|
|
||||||
it's not in its default location. This option is only used with the `--custom` flag.
|
|
||||||
|
|
||||||
The `--destination` option tells Gitea the directory where the files must be extracted to.
|
|
||||||
The default is the current directory.
|
|
||||||
|
|
||||||
The `--custom` flag tells Gitea to extract the files directly into the `custom` directory.
|
|
||||||
For this to work, the command needs to know the location of the `app.ini` configuration
|
|
||||||
file (`--config`) and, depending of the configuration, be ran from the directory where
|
|
||||||
Gitea normally starts. See [Customizing Gitea](administration/customizing-gitea.md) for details.
|
|
||||||
|
|
||||||
The `--overwrite` flag allows any existing files in the destination directory to be overwritten.
|
|
||||||
|
|
||||||
The `--rename` flag tells Gitea to rename any existing files in the destination directory
|
|
||||||
as `filename.bak`. Previous `.bak` files are overwritten.
|
|
||||||
|
|
||||||
At least one file search pattern must be provided; see `list` subcomand above for pattern
|
|
||||||
syntax and examples.
|
|
||||||
|
|
||||||
### Important notice
|
|
||||||
|
|
||||||
Make sure to **only extract those files that require customization**. Files that
|
|
||||||
are present in the `custom` directory are not upgraded by Gitea's upgrade process.
|
|
||||||
When Gitea is upgraded to a new version (by replacing the executable), many of the
|
|
||||||
embedded files will suffer changes. Gitea will honor and use any files found
|
|
||||||
in the `custom` directory, even if they are old and incompatible.
|
|
||||||
|
|
||||||
### Example: Extracting mail templates
|
|
||||||
|
|
||||||
Extracting mail templates to a temporary directory:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ mkdir tempdir
|
|
||||||
$ gitea embedded extract --destination tempdir 'templates/mail/**.tmpl'
|
|
||||||
Extracting to tempdir:
|
|
||||||
tempdir/templates/mail/auth/activate.tmpl
|
|
||||||
tempdir/templates/mail/auth/activate_email.tmpl
|
|
||||||
tempdir/templates/mail/auth/register_notify.tmpl
|
|
||||||
tempdir/templates/mail/auth/reset_passwd.tmpl
|
|
||||||
tempdir/templates/mail/issue/assigned.tmpl
|
|
||||||
tempdir/templates/mail/issue/default.tmpl
|
|
||||||
tempdir/templates/mail/notify/collaborator.tmpl
|
|
||||||
```
|
|
|
@ -1,101 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "嵌入资源提取工具"
|
|
||||||
slug: "cmd-embedded"
|
|
||||||
sidebar_position: 20
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/cmd-embedded
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "嵌入资源提取工具"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "cmd-embedded"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 嵌入资源提取工具
|
|
||||||
|
|
||||||
Gitea 的可执行文件包含了运行所需的所有资源:模板、图片、样式表和翻译文件。你可以通过在 `custom` 目录下的相应路径中放置替换文件来覆盖其中的任何资源(详见 [自定义 Gitea 配置](administration/customizing-gitea.md))。
|
|
||||||
|
|
||||||
要获取嵌入资源的副本以进行编辑,可以使用 CLI 中的 `embedded` 命令,通过操作系统的 shell 执行。
|
|
||||||
|
|
||||||
**注意:** 嵌入资源提取工具包含在 Gitea 1.12 及以上版本中。
|
|
||||||
|
|
||||||
## 资源列表
|
|
||||||
|
|
||||||
要列出嵌入在 Gitea 可执行文件中的资源,请使用以下语法:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
gitea embedded list [--include-vendored] [patterns...]
|
|
||||||
```
|
|
||||||
|
|
||||||
`--include-vendored` 标志使命令包括被供应的文件,这些文件通常被排除在外;即来自外部库的文件,这些文件是 Gitea 所需的(例如 [octicons](https://octicons.github.com/) 等)。
|
|
||||||
|
|
||||||
可以提供一系列文件搜索模式。Gitea 使用 [gobwas/glob](https://github.com/gobwas/glob) 作为其 glob 语法。以下是一些示例:
|
|
||||||
|
|
||||||
- 列出所有模板文件,无论在哪个虚拟目录下:`**.tmpl`
|
|
||||||
- 列出所有邮件模板文件:`templates/mail/**.tmpl`
|
|
||||||
列出 `public/assets/img` 目录下的所有文件:`public/assets/img/**`
|
|
||||||
|
|
||||||
不要忘记为模式使用引号,因为空格、`*` 和其他字符可能对命令行解释器有特殊含义。
|
|
||||||
|
|
||||||
如果未提供模式,则列出所有文件。
|
|
||||||
|
|
||||||
### 示例:列出所有嵌入文件
|
|
||||||
|
|
||||||
列出所有路径中包含 `openid` 的嵌入文件:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ gitea embedded list '**openid**'
|
|
||||||
public/assets/img/auth/openid_connect.svg
|
|
||||||
public/assets/img/openid-16x16.png
|
|
||||||
templates/user/auth/finalize_openid.tmpl
|
|
||||||
templates/user/auth/signin_openid.tmpl
|
|
||||||
templates/user/auth/signup_openid_connect.tmpl
|
|
||||||
templates/user/auth/signup_openid_navbar.tmpl
|
|
||||||
templates/user/auth/signup_openid_register.tmpl
|
|
||||||
templates/user/settings/security_openid.tmpl
|
|
||||||
```
|
|
||||||
|
|
||||||
## 提取资源
|
|
||||||
|
|
||||||
要提取嵌入在 Gitea 可执行文件中的资源,请使用以下语法:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...}
|
|
||||||
```
|
|
||||||
|
|
||||||
`--config` 选项用于告知 Gitea `app.ini` 配置文件的位置(如果不在默认位置)。此选项仅在使用 `--custom` 标志时使用。
|
|
||||||
|
|
||||||
`--destination` 选项用于指定提取文件的目标目录。默认为当前目录。
|
|
||||||
|
|
||||||
`--custom` 标志告知 Gitea 直接将文件提取到 `custom` 目录中。为使其正常工作,该命令需要知道 `app.ini` 配置文件的位置(通过 `--config` 指定),并且根据配置的不同,需要从 Gitea 通常启动的目录运行。有关详细信息,请参阅 [自定义 Gitea 配置](administration/customizing-gitea.md)。
|
|
||||||
|
|
||||||
`--overwrite` 标志允许覆盖目标目录中的任何现有文件。
|
|
||||||
|
|
||||||
`--rename` 标志告知 Gitea 将目标目录中的任何现有文件重命名为 `filename.bak`。之前的 `.bak` 文件将被覆盖。
|
|
||||||
|
|
||||||
至少需要提供一个文件搜索模式;有关模式的语法和示例,请参阅上述 `list` 子命令。
|
|
||||||
|
|
||||||
### 重要提示
|
|
||||||
|
|
||||||
请确保**只提取需要自定义的文件**。位于 `custom` 目录中的文件不会受到 Gitea 的升级过程的影响。当 Gitea 升级到新版本(通过替换可执行文件)时,许多嵌入文件将发生变化。Gitea 将尊重并使用在 `custom` 目录中找到的任何文件,即使这些文件是旧的和不兼容的。
|
|
||||||
|
|
||||||
### 示例:提取邮件模板
|
|
||||||
|
|
||||||
将邮件模板提取到临时目录:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ mkdir tempdir
|
|
||||||
$ gitea embedded extract --destination tempdir 'templates/mail/**.tmpl'
|
|
||||||
Extracting to tempdir:
|
|
||||||
tempdir/templates/mail/auth/activate.tmpl
|
|
||||||
tempdir/templates/mail/auth/activate_email.tmpl
|
|
||||||
tempdir/templates/mail/auth/register_notify.tmpl
|
|
||||||
tempdir/templates/mail/auth/reset_passwd.tmpl
|
|
||||||
tempdir/templates/mail/issue/assigned.tmpl
|
|
||||||
tempdir/templates/mail/issue/default.tmpl
|
|
||||||
tempdir/templates/mail/notify/collaborator.tmpl
|
|
||||||
```
|
|
|
@ -1,572 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-01-01T16:00:00+02:00"
|
|
||||||
title: "Gitea Command Line"
|
|
||||||
slug: "command-line"
|
|
||||||
sidebar_position: 1
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/command-line
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Command Line"
|
|
||||||
sidebar_position: 1
|
|
||||||
identifier: "command-line"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Command Line
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
`gitea [global options] command [command or global options] [arguments...]`
|
|
||||||
|
|
||||||
## Global options
|
|
||||||
|
|
||||||
All global options can be placed at the command level.
|
|
||||||
|
|
||||||
- `--help`, `-h`: Show help text and exit. Optional.
|
|
||||||
- `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`).
|
|
||||||
- `--work-path path`, `-w path`: Gitea's work path. Optional. (default: the binary's path or `$GITEA_WORK_DIR`)
|
|
||||||
- `--custom-path path`, `-C path`: Gitea's custom folder path. Optional. (default: `WorkPath`/custom or `$GITEA_CUSTOM`).
|
|
||||||
- `--config path`, `-c path`: Gitea configuration file path. Optional. (default: `CustomPath`/conf/app.ini).
|
|
||||||
|
|
||||||
NB: The defaults custom-path, config and work-path can also be
|
|
||||||
changed at build time (if preferred).
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
### web
|
|
||||||
|
|
||||||
Starts the server:
|
|
||||||
|
|
||||||
- Options:
|
|
||||||
- `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
|
|
||||||
- `--install-port number`: Port number to run the install page on. Optional. (default: 3000). Overrides configuration file.
|
|
||||||
- `--pid path`, `-P path`: Pidfile path. Optional.
|
|
||||||
- `--quiet`, `-q`: Only emit Fatal logs on the console for logs emitted before logging set up.
|
|
||||||
- `--verbose`: Emit tracing logs on the console for logs emitted before logging is set-up.
|
|
||||||
- Examples:
|
|
||||||
- `gitea web`
|
|
||||||
- `gitea web --port 80`
|
|
||||||
- `gitea web --config /etc/gitea.ini --pid /some/custom/gitea.pid`
|
|
||||||
- Notes:
|
|
||||||
- Gitea should not be run as root. To bind to a port below 1024, you can use setcap on
|
|
||||||
Linux: `sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`. This will need to be
|
|
||||||
redone every time you update Gitea.
|
|
||||||
|
|
||||||
### admin
|
|
||||||
|
|
||||||
Admin operations:
|
|
||||||
|
|
||||||
- Commands:
|
|
||||||
- `user`:
|
|
||||||
- `list`:
|
|
||||||
- Options:
|
|
||||||
- `--admin`: List only admin users. Optional.
|
|
||||||
- Description: lists all users that exist
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin user list`
|
|
||||||
- `delete`:
|
|
||||||
- Options:
|
|
||||||
- `--email`: Email of the user to be deleted.
|
|
||||||
- `--username`: Username of user to be deleted.
|
|
||||||
- `--id`: ID of user to be deleted.
|
|
||||||
- One of `--id`, `--username` or `--email` is required. If more than one is provided then all have to match.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin user delete --id 1`
|
|
||||||
- `create`:
|
|
||||||
- Options:
|
|
||||||
- `--name value`: Username. Required. As of Gitea 1.9.0, use the `--username` flag instead.
|
|
||||||
- `--username value`: Username. Required. New in Gitea 1.9.0.
|
|
||||||
- `--password value`: Password. Required.
|
|
||||||
- `--email value`: Email. Required.
|
|
||||||
- `--admin`: If provided, this makes the user an admin. Optional.
|
|
||||||
- `--access-token`: If provided, an access token will be created for the user. Optional. (default: false).
|
|
||||||
- `--must-change-password`: If provided, the created user will be required to choose a newer password after the
|
|
||||||
initial login. Optional. (default: true).
|
|
||||||
- `--random-password`: If provided, a randomly generated password will be used as the password of the created
|
|
||||||
user. The value of `--password` will be discarded. Optional.
|
|
||||||
- `--random-password-length`: If provided, it will be used to configure the length of the randomly generated
|
|
||||||
password. Optional. (default: 12)
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin user create --username myname --password asecurepassword --email me@example.com`
|
|
||||||
- `change-password`:
|
|
||||||
- Options:
|
|
||||||
- `--username value`, `-u value`: Username. Required.
|
|
||||||
- `--password value`, `-p value`: New password. Required.
|
|
||||||
- `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin user change-password --username myname --password asecurepassword`
|
|
||||||
- `must-change-password`:
|
|
||||||
- Args:
|
|
||||||
- `[username...]`: Users that must change their passwords
|
|
||||||
- Options:
|
|
||||||
- `--all`, `-A`: Force a password change for all users
|
|
||||||
- `--exclude username`, `-e username`: Exclude the given user. Can be set multiple times.
|
|
||||||
- `--unset`: Revoke forced password change for the given users
|
|
||||||
- `generate-access-token`:
|
|
||||||
- Options:
|
|
||||||
- `--username value`, `-u value`: Username. Required.
|
|
||||||
- `--token-name value`, `-t value`: Token name. Required.
|
|
||||||
- `--scopes value`: Comma-separated list of scopes. Scopes follow the format `[read|write]:<block>` or `all` where `<block>` is one of the available visual groups you can see when opening the API page showing the available routes (for example `repo`).
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin user generate-access-token --username myname --token-name mytoken`
|
|
||||||
- `gitea admin user generate-access-token --help`
|
|
||||||
- `regenerate`
|
|
||||||
- Options:
|
|
||||||
- `hooks`: Regenerate Git Hooks for all repositories
|
|
||||||
- `keys`: Regenerate authorized_keys file
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin regenerate hooks`
|
|
||||||
- `gitea admin regenerate keys`
|
|
||||||
- `auth`:
|
|
||||||
- `list`:
|
|
||||||
- Description: lists all external authentication sources that exist
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth list`
|
|
||||||
- `delete`:
|
|
||||||
- Options:
|
|
||||||
- `--id`: ID of source to be deleted. Required.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth delete --id 1`
|
|
||||||
- `add-oauth`:
|
|
||||||
- Options:
|
|
||||||
- `--name`: Application Name.
|
|
||||||
- `--provider`: OAuth2 Provider.
|
|
||||||
- `--key`: Client ID (Key).
|
|
||||||
- `--secret`: Client Secret.
|
|
||||||
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
|
|
||||||
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
|
|
||||||
- `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
|
|
||||||
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
|
|
||||||
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
|
|
||||||
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
|
|
||||||
- `--custom-email-url`: Use a custom Email URL (option for GitHub).
|
|
||||||
- `--icon-url`: Custom icon URL for OAuth2 login source.
|
|
||||||
- `--skip-local-2fa`: Allow source to override local 2FA. (Optional)
|
|
||||||
- `--scopes`: Additional scopes to request for this OAuth2 source. (Optional)
|
|
||||||
- `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional)
|
|
||||||
- `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional)
|
|
||||||
- `--group-claim-name`: Claim name providing group names for this source. (Optional)
|
|
||||||
- `--admin-group`: Group Claim value for administrator users. (Optional)
|
|
||||||
- `--restricted-group`: Group Claim value for restricted users. (Optional)
|
|
||||||
- `--group-team-map`: JSON mapping between groups and org teams. (Optional)
|
|
||||||
- `--group-team-map-removal`: Activate automatic team membership removal depending on groups. (Optional)
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
|
|
||||||
- `update-oauth`:
|
|
||||||
- Options:
|
|
||||||
- `--id`: ID of source to be updated. Required.
|
|
||||||
- `--name`: Application Name.
|
|
||||||
- `--provider`: OAuth2 Provider.
|
|
||||||
- `--key`: Client ID (Key).
|
|
||||||
- `--secret`: Client Secret.
|
|
||||||
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
|
|
||||||
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
|
|
||||||
- `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
|
|
||||||
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
|
|
||||||
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
|
|
||||||
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
|
|
||||||
- `--custom-email-url`: Use a custom Email URL (option for GitHub).
|
|
||||||
- `--icon-url`: Custom icon URL for OAuth2 login source.
|
|
||||||
- `--skip-local-2fa`: Allow source to override local 2FA. (Optional)
|
|
||||||
- `--scopes`: Additional scopes to request for this OAuth2 source.
|
|
||||||
- `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional)
|
|
||||||
- `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional)
|
|
||||||
- `--group-claim-name`: Claim name providing group names for this source. (Optional)
|
|
||||||
- `--admin-group`: Group Claim value for administrator users. (Optional)
|
|
||||||
- `--restricted-group`: Group Claim value for restricted users. (Optional)
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth update-oauth --id 1 --name external-github-updated`
|
|
||||||
- `add-smtp`:
|
|
||||||
- Options:
|
|
||||||
- `--name`: Application Name. Required.
|
|
||||||
- `--auth-type`: SMTP Authentication Type (PLAIN/LOGIN/CRAM-MD5). Default to PLAIN.
|
|
||||||
- `--host`: SMTP host. Required.
|
|
||||||
- `--port`: SMTP port. Required.
|
|
||||||
- `--force-smtps`: SMTPS is always used on port 465. Set this to force SMTPS on other ports.
|
|
||||||
- `--skip-verify`: Skip TLS verify.
|
|
||||||
- `--helo-hostname`: Hostname sent with HELO. Leave blank to send current hostname.
|
|
||||||
- `--disable-helo`: Disable SMTP helo.
|
|
||||||
- `--allowed-domains`: Leave empty to allow all domains. Separate multiple domains with a comma (',').
|
|
||||||
- `--skip-local-2fa`: Skip 2FA to log on.
|
|
||||||
- `--active`: This Authentication Source is Activated.
|
|
||||||
Remarks:
|
|
||||||
`--force-smtps`, `--skip-verify`, `--disable-helo`, `--skip-loca-2fs` and `--active` options can be used in form:
|
|
||||||
- `--option`, `--option=true` to enable
|
|
||||||
- `--option=false` to disable
|
|
||||||
If those options are not specified value would not be changed in `update-smtp` or would use default `false` value in `add-smtp`
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth add-smtp --name ldap --host smtp.mydomain.org --port 587 --skip-verify --active`
|
|
||||||
- `update-smtp`:
|
|
||||||
- Options:
|
|
||||||
- `--id`: ID of source to be updated. Required.
|
|
||||||
- other options are shared with `add-smtp`
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth update-smtp --id 1 --host smtp.mydomain.org --port 587 --skip-verify=false`
|
|
||||||
- `gitea admin auth update-smtp --id 1 --active=false`
|
|
||||||
- `add-ldap`: Add new LDAP (via Bind DN) authentication source
|
|
||||||
- Options:
|
|
||||||
- `--name value`: Authentication name. Required.
|
|
||||||
- `--not-active`: Deactivate the authentication source.
|
|
||||||
- `--security-protocol value`: Security protocol name. Required.
|
|
||||||
- `--skip-tls-verify`: Disable TLS verification.
|
|
||||||
- `--host value`: The address where the LDAP server can be reached. Required.
|
|
||||||
- `--port value`: The port to use when connecting to the LDAP server. Required.
|
|
||||||
- `--user-search-base value`: The LDAP base at which user accounts will be searched for. Required.
|
|
||||||
- `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
|
|
||||||
- `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
|
|
||||||
- `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
|
|
||||||
- `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
|
|
||||||
- `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
|
|
||||||
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
|
|
||||||
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
|
|
||||||
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
|
|
||||||
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
|
|
||||||
- `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
|
|
||||||
- `--bind-password value`: The password for the Bind DN, if any.
|
|
||||||
- `--attributes-in-bind`: Fetch attributes in bind DN context.
|
|
||||||
- `--synchronize-users`: Enable user synchronization.
|
|
||||||
- `--page-size value`: Search page size.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" --email-attribute mail`
|
|
||||||
- `update-ldap`: Update existing LDAP (via Bind DN) authentication source
|
|
||||||
- Options:
|
|
||||||
- `--id value`: ID of authentication source. Required.
|
|
||||||
- `--name value`: Authentication name.
|
|
||||||
- `--not-active`: Deactivate the authentication source.
|
|
||||||
- `--security-protocol value`: Security protocol name.
|
|
||||||
- `--skip-tls-verify`: Disable TLS verification.
|
|
||||||
- `--host value`: The address where the LDAP server can be reached.
|
|
||||||
- `--port value`: The port to use when connecting to the LDAP server.
|
|
||||||
- `--user-search-base value`: The LDAP base at which user accounts will be searched for.
|
|
||||||
- `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
|
|
||||||
- `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
|
|
||||||
- `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
|
|
||||||
- `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
|
|
||||||
- `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
|
|
||||||
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
|
|
||||||
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
|
|
||||||
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
|
|
||||||
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
|
|
||||||
- `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
|
|
||||||
- `--bind-password value`: The password for the Bind DN, if any.
|
|
||||||
- `--attributes-in-bind`: Fetch attributes in bind DN context.
|
|
||||||
- `--synchronize-users`: Enable user synchronization.
|
|
||||||
- `--page-size value`: Search page size.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth update-ldap --id 1 --name "my ldap auth source"`
|
|
||||||
- `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
|
|
||||||
- `add-ldap-simple`: Add new LDAP (simple auth) authentication source
|
|
||||||
- Options:
|
|
||||||
- `--name value`: Authentication name. Required.
|
|
||||||
- `--not-active`: Deactivate the authentication source.
|
|
||||||
- `--security-protocol value`: Security protocol name. Required.
|
|
||||||
- `--skip-tls-verify`: Disable TLS verification.
|
|
||||||
- `--host value`: The address where the LDAP server can be reached. Required.
|
|
||||||
- `--port value`: The port to use when connecting to the LDAP server. Required.
|
|
||||||
- `--user-search-base value`: The LDAP base at which user accounts will be searched for.
|
|
||||||
- `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
|
|
||||||
- `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
|
|
||||||
- `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
|
|
||||||
- `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
|
|
||||||
- `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
|
|
||||||
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
|
|
||||||
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
|
|
||||||
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
|
|
||||||
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
|
|
||||||
- `--user-dn value`: The user’s DN. Required.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail`
|
|
||||||
- `update-ldap-simple`: Update existing LDAP (simple auth) authentication source
|
|
||||||
- Options:
|
|
||||||
- `--id value`: ID of authentication source. Required.
|
|
||||||
- `--name value`: Authentication name.
|
|
||||||
- `--not-active`: Deactivate the authentication source.
|
|
||||||
- `--security-protocol value`: Security protocol name.
|
|
||||||
- `--skip-tls-verify`: Disable TLS verification.
|
|
||||||
- `--host value`: The address where the LDAP server can be reached.
|
|
||||||
- `--port value`: The port to use when connecting to the LDAP server.
|
|
||||||
- `--user-search-base value`: The LDAP base at which user accounts will be searched for.
|
|
||||||
- `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
|
|
||||||
- `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
|
|
||||||
- `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
|
|
||||||
- `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
|
|
||||||
- `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
|
|
||||||
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
|
|
||||||
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
|
|
||||||
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
|
|
||||||
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
|
|
||||||
- `--user-dn value`: The user’s DN.
|
|
||||||
- Examples:
|
|
||||||
- `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"`
|
|
||||||
- `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
|
|
||||||
|
|
||||||
### cert
|
|
||||||
|
|
||||||
Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
|
|
||||||
directory and will overwrite any existing files.
|
|
||||||
|
|
||||||
- Options:
|
|
||||||
- `--host value`: Comma separated hostnames and ips which this certificate is valid for.
|
|
||||||
Wildcards are supported. Required.
|
|
||||||
- `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
|
|
||||||
are P224, P256, P384, P521.
|
|
||||||
- `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
|
|
||||||
set. (default: 3072).
|
|
||||||
- `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
|
|
||||||
- `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
|
|
||||||
- `--ca`: If provided, this cert generates it's own certificate authority. Optional.
|
|
||||||
- Examples:
|
|
||||||
- `gitea cert --host git.example.com,example.com,www.example.com --ca`
|
|
||||||
|
|
||||||
### dump
|
|
||||||
|
|
||||||
Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
|
|
||||||
in the current directory.
|
|
||||||
|
|
||||||
- Options:
|
|
||||||
- `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
|
|
||||||
- `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
|
|
||||||
- `--skip-repository`, `-R`: Skip the repository dumping. Optional.
|
|
||||||
- `--skip-custom-dir`: Skip dumping of the custom dir. Optional.
|
|
||||||
- `--skip-lfs-data`: Skip dumping of LFS data. Optional.
|
|
||||||
- `--skip-attachment-data`: Skip dumping of attachment data. Optional.
|
|
||||||
- `--skip-package-data`: Skip dumping of package data. Optional.
|
|
||||||
- `--skip-log`: Skip dumping of log data. Optional.
|
|
||||||
- `--database`, `-d`: Specify the database SQL syntax. Optional (supported arguments: sqlite3, mysql, mssql, postgres).
|
|
||||||
- `--verbose`, `-V`: If provided, shows additional details. Optional.
|
|
||||||
- `--type`: Set the dump output format. Optional. (formats: zip, tar, tar.sz, tar.gz, tar.xz, tar.bz2, tar.br, tar.lz4, tar.zst default: zip).
|
|
||||||
- Examples:
|
|
||||||
- `gitea dump`
|
|
||||||
- `gitea dump --verbose`
|
|
||||||
|
|
||||||
### generate
|
|
||||||
|
|
||||||
Generates random values and tokens for usage in configuration file. Useful for generating values
|
|
||||||
for automatic deployments.
|
|
||||||
|
|
||||||
- Commands:
|
|
||||||
- `secret`:
|
|
||||||
- Options:
|
|
||||||
- `INTERNAL_TOKEN`: Token used for an internal API call authentication.
|
|
||||||
- `JWT_SECRET`: LFS & OAUTH2 JWT authentication secret (LFS_JWT_SECRET is aliased to this option for backwards compatibility).
|
|
||||||
- `SECRET_KEY`: Global secret key.
|
|
||||||
- Examples:
|
|
||||||
- `gitea generate secret INTERNAL_TOKEN`
|
|
||||||
- `gitea generate secret JWT_SECRET`
|
|
||||||
- `gitea generate secret SECRET_KEY`
|
|
||||||
|
|
||||||
### keys
|
|
||||||
|
|
||||||
Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
...
|
|
||||||
# The value of -e and the AuthorizedKeysCommandUser should match the
|
|
||||||
# username running Gitea
|
|
||||||
AuthorizedKeysCommandUser git
|
|
||||||
AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
|
|
||||||
```
|
|
||||||
|
|
||||||
The command will return the appropriate authorized_keys line for the
|
|
||||||
provided key. You should also set the value
|
|
||||||
`SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
|
|
||||||
`app.ini`.
|
|
||||||
|
|
||||||
NB: opensshd requires the Gitea program to be owned by root and not
|
|
||||||
writable by group or others. The program must be specified by an absolute
|
|
||||||
path.
|
|
||||||
NB: Gitea must be running for this command to succeed.
|
|
||||||
|
|
||||||
### migrate
|
|
||||||
|
|
||||||
Migrates the database. This command can be used to run other commands before starting the server for the first time.
|
|
||||||
This command is idempotent.
|
|
||||||
|
|
||||||
### doctor check
|
|
||||||
|
|
||||||
Diagnose and potentially fix problems with the current Gitea instance.
|
|
||||||
Several checks are run by default, but additional ones can be run:
|
|
||||||
|
|
||||||
- `gitea doctor check --list` - will list all the available checks
|
|
||||||
- `gitea doctor check --all` - will run all available checks
|
|
||||||
- `gitea doctor check --default` - will run the default checks
|
|
||||||
- `gitea doctor check --run [check(s),]...` - will run the named checks
|
|
||||||
|
|
||||||
Some problems can be automatically fixed by passing the `--fix` option.
|
|
||||||
Extra logging can be set with `--log-file=...`.
|
|
||||||
|
|
||||||
#### doctor recreate-table
|
|
||||||
|
|
||||||
Sometimes when there are migrations the old columns and default values may be left
|
|
||||||
unchanged in the database schema. This may lead to warning such as:
|
|
||||||
|
|
||||||
```
|
|
||||||
2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0
|
|
||||||
```
|
|
||||||
|
|
||||||
You can cause Gitea to recreate these tables and copy the old data into the new table
|
|
||||||
with the defaults set appropriately by using:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table user
|
|
||||||
```
|
|
||||||
|
|
||||||
You can ask Gitea to recreate multiple tables using:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table table1 table2 ...
|
|
||||||
```
|
|
||||||
|
|
||||||
And if you would like Gitea to recreate all tables simply call:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table
|
|
||||||
```
|
|
||||||
|
|
||||||
It is highly recommended to back-up your database before running these commands.
|
|
||||||
|
|
||||||
### doctor convert
|
|
||||||
|
|
||||||
Converts a MySQL database from utf8 to utf8mb4 or a MSSQL database from varchar to nvarchar.
|
|
||||||
|
|
||||||
### manager
|
|
||||||
|
|
||||||
Manage running server operations:
|
|
||||||
|
|
||||||
- Commands:
|
|
||||||
- `shutdown`: Gracefully shutdown the running process
|
|
||||||
- `restart`: Gracefully restart the running process - (not implemented for windows servers)
|
|
||||||
- `flush-queues`: Flush queues in the running process
|
|
||||||
- Options:
|
|
||||||
- `--timeout value`: Timeout for the flushing process (default: 1m0s)
|
|
||||||
- `--non-blocking`: Set to true to not wait for flush to complete before returning
|
|
||||||
- `logging`: Adjust logging commands
|
|
||||||
- Commands:
|
|
||||||
- `pause`: Pause logging
|
|
||||||
- Notes:
|
|
||||||
- The logging level will be raised to INFO temporarily if it is below this level.
|
|
||||||
- Gitea will buffer logs up to a certain point and will drop them after that point.
|
|
||||||
- `resume`: Resume logging
|
|
||||||
- `release-and-reopen`: Cause Gitea to release and re-open files and connections used for logging (Equivalent to sending SIGUSR1 to Gitea.)
|
|
||||||
- `remove name`: Remove the named logger
|
|
||||||
- Options:
|
|
||||||
- `--group group`, `-g group`: Set the group to remove the sublogger from. (defaults to `default`)
|
|
||||||
- `add`: Add a logger
|
|
||||||
- Commands:
|
|
||||||
- `console`: Add a console logger
|
|
||||||
- Options:
|
|
||||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
|
||||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
|
||||||
- `--level value`, `-l value`: Logging level for the new logger
|
|
||||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
|
||||||
- `--flags value`, `-F value`: Flags for the logger
|
|
||||||
- `--expression value`, `-e value`: Matching expression for the logger
|
|
||||||
- `--prefix value`, `-p value`: Prefix for the logger
|
|
||||||
- `--color`: Use color in the logs
|
|
||||||
- `--stderr`: Output console logs to stderr - only relevant for console
|
|
||||||
- `file`: Add a file logger
|
|
||||||
- Options:
|
|
||||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
|
||||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
|
||||||
- `--level value`, `-l value`: Logging level for the new logger
|
|
||||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
|
||||||
- `--flags value`, `-F value`: Flags for the logger
|
|
||||||
- `--expression value`, `-e value`: Matching expression for the logger
|
|
||||||
- `--prefix value`, `-p value`: Prefix for the logger
|
|
||||||
- `--color`: Use color in the logs
|
|
||||||
- `--filename value`, `-f value`: Filename for the logger -
|
|
||||||
- `--rotate`, `-r`: Rotate logs
|
|
||||||
- `--max-size value`, `-s value`: Maximum size in bytes before rotation
|
|
||||||
- `--daily`, `-d`: Rotate logs daily
|
|
||||||
- `--max-days value`, `-D value`: Maximum number of daily logs to keep
|
|
||||||
- `--compress`, `-z`: Compress rotated logs
|
|
||||||
- `--compression-level value`, `-Z value`: Compression level to use
|
|
||||||
- `conn`: Add a network connection logger
|
|
||||||
- Options:
|
|
||||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
|
||||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
|
||||||
- `--level value`, `-l value`: Logging level for the new logger
|
|
||||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
|
||||||
- `--flags value`, `-F value`: Flags for the logger
|
|
||||||
- `--expression value`, `-e value`: Matching expression for the logger
|
|
||||||
- `--prefix value`, `-p value`: Prefix for the logger
|
|
||||||
- `--color`: Use color in the logs
|
|
||||||
- `--reconnect-on-message`, `-R`: Reconnect to host for every message
|
|
||||||
- `--reconnect`, `-r`: Reconnect to host when connection is dropped
|
|
||||||
- `--protocol value`, `-P value`: Set protocol to use: tcp, unix, or udp (defaults to tcp)
|
|
||||||
- `--address value`, `-a value`: Host address and port to connect to (defaults to :7020)
|
|
||||||
- `smtp`: Add an SMTP logger
|
|
||||||
- Options:
|
|
||||||
- `--group value`, `-g value`: Group to add logger to - will default to "default"
|
|
||||||
- `--name value`, `-n value`: Name of the new logger - will default to mode
|
|
||||||
- `--level value`, `-l value`: Logging level for the new logger
|
|
||||||
- `--stacktrace-level value`, `-L value`: Stacktrace logging level
|
|
||||||
- `--flags value`, `-F value`: Flags for the logger
|
|
||||||
- `--expression value`, `-e value`: Matching expression for the logger
|
|
||||||
- `--prefix value`, `-p value`: Prefix for the logger
|
|
||||||
- `--color`: Use color in the logs
|
|
||||||
- `--username value`, `-u value`: Mail server username
|
|
||||||
- `--password value`, `-P value`: Mail server password
|
|
||||||
- `--host value`, `-H value`: Mail server host (defaults to: 127.0.0.1:25)
|
|
||||||
- `--send-to value`, `-s value`: Email address(es) to send to
|
|
||||||
- `--subject value`, `-S value`: Subject header of sent emails
|
|
||||||
- `processes`: Display Gitea processes and goroutine information
|
|
||||||
- Options:
|
|
||||||
- `--flat`: Show processes as flat table rather than as tree
|
|
||||||
- `--no-system`: Do not show system processes
|
|
||||||
- `--stacktraces`: Show stacktraces for goroutines associated with processes
|
|
||||||
- `--json`: Output as json
|
|
||||||
- `--cancel PID`: Send cancel to process with PID. (Only for non-system processes.)
|
|
||||||
|
|
||||||
### dump-repo
|
|
||||||
|
|
||||||
Dump-repo dumps repository data from Git/GitHub/Gitea/GitLab:
|
|
||||||
|
|
||||||
- Options:
|
|
||||||
- `--git_service service` : Git service, it could be `git`, `github`, `gitea`, `gitlab`, If clone_addr could be recognized, this could be ignored.
|
|
||||||
- `--repo_dir dir`, `-r dir`: Repository dir path to store the data
|
|
||||||
- `--clone_addr addr`: The URL will be clone, currently could be a git/github/gitea/gitlab http/https URL. i.e. https://github.com/lunny/tango.git
|
|
||||||
- `--auth_username lunny`: The username to visit the clone_addr
|
|
||||||
- `--auth_password <password>`: The password to visit the clone_addr
|
|
||||||
- `--auth_token <token>`: The personal token to visit the clone_addr
|
|
||||||
- `--owner_name lunny`: The data will be stored on a directory with owner name if not empty
|
|
||||||
- `--repo_name tango`: The data will be stored on a directory with repository name if not empty
|
|
||||||
- `--units <units>`: Which items will be migrated, one or more units should be separated as comma. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.
|
|
||||||
|
|
||||||
### restore-repo
|
|
||||||
|
|
||||||
Restore-repo restore repository data from disk dir:
|
|
||||||
|
|
||||||
- Options:
|
|
||||||
- `--repo_dir dir`, `-r dir`: Repository dir path to restore from
|
|
||||||
- `--owner_name lunny`: Restore destination owner name
|
|
||||||
- `--repo_name tango`: Restore destination repository name
|
|
||||||
- `--units <units>`: Which items will be restored, one or more units should be separated as comma. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.
|
|
||||||
|
|
||||||
### actions generate-runner-token
|
|
||||||
|
|
||||||
Generate a new token for a runner to use to register with the server
|
|
||||||
|
|
||||||
- Options:
|
|
||||||
- `--scope {owner}[/{repo}]`, `-s {owner}[/{repo}]`: To limit the scope of the runner, no scope means the runner can be used for all repos, but you can also limit it to a specific repo or owner
|
|
||||||
|
|
||||||
To register a global runner:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea actions generate-runner-token
|
|
||||||
```
|
|
||||||
|
|
||||||
To register a runner for a specific organization, in this case `org`:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea actions generate-runner-token -s org
|
|
||||||
```
|
|
||||||
|
|
||||||
To register a runner for a specific repo, in this case `username/test-repo`:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea actions generate-runner-token -s username/test-repo
|
|
||||||
```
|
|
|
@ -1,542 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "Gitea 命令行"
|
|
||||||
slug: "command-line"
|
|
||||||
sidebar_position: 1
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/command-line
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Gitea 命令行"
|
|
||||||
sidebar_position: 1
|
|
||||||
identifier: "command-line"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 命令行
|
|
||||||
|
|
||||||
## 用法
|
|
||||||
|
|
||||||
`gitea [全局选项] 命令 [命令或全局选项] [参数...]`
|
|
||||||
|
|
||||||
## 全局选项
|
|
||||||
|
|
||||||
所有全局选项均可被放置在命令级别。
|
|
||||||
|
|
||||||
- `--help`,`-h`:显示帮助文本并退出。可选。
|
|
||||||
- `--version`,`-v`:显示版本信息并退出。可选。 (示例:`Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`)。
|
|
||||||
- `--custom-path path`,`-C path`:Gitea 自定义文件夹的路径。可选。 (默认值:`AppWorkPath`/custom 或 `$GITEA_CUSTOM`)。
|
|
||||||
- `--config path`,`-c path`:Gitea 配置文件的路径。可选。 (默认值:`custom`/conf/app.ini)。
|
|
||||||
- `--work-path path`,`-w path`:Gitea 的 `AppWorkPath`。可选。 (默认值:LOCATION_OF_GITEA_BINARY 或 `$GITEA_WORK_DIR`)
|
|
||||||
|
|
||||||
注意:默认的 custom-path、config 和 work-path 也可以在构建时更改(如果需要)。
|
|
||||||
|
|
||||||
## 命令
|
|
||||||
|
|
||||||
### web
|
|
||||||
|
|
||||||
启动服务器:
|
|
||||||
|
|
||||||
- 选项:
|
|
||||||
- `--port number`,`-p number`:端口号。可选。 (默认值:3000)。覆盖配置文件中的设置。
|
|
||||||
- `--install-port number`:运行安装页面的端口号。可选。 (默认值:3000)。覆盖配置文件中的设置。
|
|
||||||
- `--pid path`,`-P path`:Pid 文件的路径。可选。
|
|
||||||
- `--quiet`,`-q`:只在控制台上输出 Fatal 日志,用于在设置日志之前发出的日志。
|
|
||||||
- `--verbose`:在控制台上输出跟踪日志,用于在设置日志之前发出的日志。
|
|
||||||
- 示例:
|
|
||||||
- `gitea web`
|
|
||||||
- `gitea web --port 80`
|
|
||||||
- `gitea web --config /etc/gitea.ini --pid /some/custom/gitea.pid`
|
|
||||||
- 注意:
|
|
||||||
- Gitea 不应以 root 用户身份运行。要绑定到低于 1024 的端口,您可以在 Linux 上使用 setcap 命令:`sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`。每次更新 Gitea 都需要重新执行此操作。
|
|
||||||
|
|
||||||
### admin
|
|
||||||
|
|
||||||
管理员操作:
|
|
||||||
|
|
||||||
- 命令:
|
|
||||||
- `user`:
|
|
||||||
- `list`:
|
|
||||||
- 选项:
|
|
||||||
- `--admin`:仅列出管理员用户。可选。
|
|
||||||
- 描述:列出所有现有用户。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin user list`
|
|
||||||
- `delete`:
|
|
||||||
- 选项:
|
|
||||||
- `--email`:要删除的用户的电子邮件。
|
|
||||||
- `--username`:要删除的用户的用户名。
|
|
||||||
- `--id`:要删除的用户的ID。
|
|
||||||
- 必须提供 `--id`、`--username` 或 `--email` 中的一个。如果提供多个,则所有条件必须匹配。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin user delete --id 1`
|
|
||||||
- `create`:
|
|
||||||
- 选项:
|
|
||||||
- `--name value`:用户名。必填。自 Gitea 1.9.0 版本起,请改用 `--username` 标志。
|
|
||||||
- `--username value`:用户名。必填。Gitea 1.9.0 新增。
|
|
||||||
- `--password value`:密码。必填。
|
|
||||||
- `--email value`:邮箱。必填。
|
|
||||||
- `--admin`:如果提供此选项,将创建一个管理员用户。可选。
|
|
||||||
- `--access-token`:如果提供,将为用户创建访问令牌。可选。(默认值:false)。
|
|
||||||
- `--must-change-password`:如果提供,创建的用户将在初始登录后需要选择一个新密码。可选。(默认值:true)。
|
|
||||||
- `--random-password`:如果提供,将使用随机生成的密码作为创建用户的密码。`--password` 的值将被忽略。可选。
|
|
||||||
- `--random-password-length`:如果提供,将用于配置随机生成密码的长度。可选。(默认值:12)
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin user create --username myname --password asecurepassword --email me@example.com`
|
|
||||||
- `change-password`:
|
|
||||||
- 选项:
|
|
||||||
- `--username value`,`-u value`:用户名。必填。
|
|
||||||
- `--password value`,`-p value`:新密码。必填。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin user change-password --username myname --password asecurepassword`
|
|
||||||
- `must-change-password`:
|
|
||||||
- 参数:
|
|
||||||
- `[username...]`:需要更改密码的用户
|
|
||||||
- 选项:
|
|
||||||
- `--all`,`-A`:强制所有用户更改密码
|
|
||||||
- `--exclude username`,`-e username`:排除给定的用户。可以多次设置。
|
|
||||||
- `--unset`:撤销对给定用户的强制密码更改
|
|
||||||
- `regenerate`:
|
|
||||||
- 选项:
|
|
||||||
- `hooks`:重新生成所有仓库的 Git Hooks。
|
|
||||||
- `keys`:重新生成 authorized_keys 文件。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin regenerate hooks`
|
|
||||||
- `gitea admin regenerate keys`
|
|
||||||
- `auth`:
|
|
||||||
- `list`:
|
|
||||||
- 描述:列出所有存在的外部认证源。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth list`
|
|
||||||
- `delete`:
|
|
||||||
- 选项:
|
|
||||||
- `--id`:要删除的源的 ID。必填。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth delete --id 1`
|
|
||||||
- `add-oauth`:
|
|
||||||
- 选项:
|
|
||||||
- `--name`:应用程序名称。
|
|
||||||
- `--provider`:OAuth2 提供者。
|
|
||||||
- `--key`:客户端 ID(Key)。
|
|
||||||
- `--secret`:客户端密钥。
|
|
||||||
- `--auto-discover-url`:OpenID Connect 自动发现 URL(仅在使用 OpenID Connect 作为提供程序时需要)。
|
|
||||||
- `--use-custom-urls`:在 GitLab/GitHub OAuth 端点上使用自定义 URL。
|
|
||||||
- `--custom-tenant-id`:在 OAuth 端点上使用自定义租户 ID。
|
|
||||||
- `--custom-auth-url`:使用自定义授权 URL(GitLab/GitHub 的选项)。
|
|
||||||
- `--custom-token-url`:使用自定义令牌 URL(GitLab/GitHub 的选项)。
|
|
||||||
- `--custom-profile-url`:使用自定义配置文件 URL(GitLab/GitHub 的选项)。
|
|
||||||
- `--custom-email-url`:使用自定义电子邮件 URL(GitHub 的选项)。
|
|
||||||
- `--icon-url`:OAuth2 登录源的自定义图标 URL。
|
|
||||||
- `--skip-local-2fa`:允许源覆盖本地 2FA。(可选)
|
|
||||||
- `--scopes`:请求此 OAuth2 源的附加范围。(可选)
|
|
||||||
- `--required-claim-name`:必须设置的声明名称,以允许用户使用此源登录。(可选)
|
|
||||||
- `--required-claim-value`:必须设置的声明值,以允许用户使用此源登录。(可选)
|
|
||||||
- `--group-claim-name`:提供此源的组名的声明名称。(可选)
|
|
||||||
- `--admin-group`:管理员用户的组声明值。(可选)
|
|
||||||
- `--restricted-group`:受限用户的组声明值。(可选)
|
|
||||||
- `--group-team-map`:组与组织团队之间的 JSON 映射。(可选)
|
|
||||||
- `--group-team-map-removal`:根据组自动激活团队成员资格的删除。(可选)
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
|
|
||||||
- `update-oauth`:
|
|
||||||
- 选项:
|
|
||||||
- `--id`:要更新的源的 ID。必填。
|
|
||||||
- `--name`:应用程序名称。
|
|
||||||
- `--provider`:OAuth2 提供者。
|
|
||||||
- `--key`:客户端 ID(Key)。
|
|
||||||
- `--secret`:客户端密钥。
|
|
||||||
- `--auto-discover-url`:OpenID Connect 自动发现 URL(仅在使用 OpenID Connect 作为提供程序时需要)。
|
|
||||||
- `--use-custom-urls`:在 GitLab/GitHub OAuth 端点上使用自定义 URL。
|
|
||||||
- `--custom-tenant-id`:在 OAuth 端点上使用自定义租户 ID。
|
|
||||||
- `--custom-auth-url`:使用自定义授权 URL(GitLab/GitHub 的选项)。
|
|
||||||
- `--custom-token-url`:使用自定义令牌 URL(GitLab/GitHub 的选项)。
|
|
||||||
- `--custom-profile-url`:使用自定义配置文件 URL(GitLab/GitHub 的选项)。
|
|
||||||
- `--custom-email-url`:使用自定义电子邮件 URL(GitHub 的选项)。
|
|
||||||
- `--icon-url`:OAuth2 登录源的自定义图标 URL。
|
|
||||||
- `--skip-local-2fa`:允许源覆盖本地 2FA。(可选)
|
|
||||||
- `--scopes`:请求此 OAuth2 源的附加范围。
|
|
||||||
- `--required-claim-name`:必须设置的声明名称,以允许用户使用此源登录。(可选)
|
|
||||||
- `--required-claim-value`:必须设置的声明值,以允许用户使用此源登录。(可选)
|
|
||||||
- `--group-claim-name`:提供此源的组名的声明名称。(可选)
|
|
||||||
- `--admin-group`:管理员用户的组声明值。(可选)
|
|
||||||
- `--restricted-group`:受限用户的组声明值。(可选)
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth update-oauth --id 1 --name external-github-updated`
|
|
||||||
- `add-smtp`:
|
|
||||||
- 选项:
|
|
||||||
- `--name`:应用程序名称。必填。
|
|
||||||
- `--auth-type`:SMTP 认证类型(PLAIN/LOGIN/CRAM-MD5)。默认为 PLAIN。
|
|
||||||
- `--host`:SMTP 主机。必填。
|
|
||||||
- `--port`:SMTP 端口。必填。
|
|
||||||
- `--force-smtps`:SMTPS 始终在端口 465 上使用。设置此选项以强制在其他端口上使用 SMTPS。
|
|
||||||
- `--skip-verify`:跳过 TLS 验证。
|
|
||||||
- `--helo-hostname`:发送 HELO 时使用的主机名。留空以发送当前主机名。
|
|
||||||
- `--disable-helo`:禁用 SMTP helo。
|
|
||||||
- `--allowed-domains`:留空以允许所有域。使用逗号(',')分隔多个域。
|
|
||||||
- `--skip-local-2fa`:跳过 2FA 登录。
|
|
||||||
- `--active`:启用此认证源。
|
|
||||||
备注:
|
|
||||||
`--force-smtps`、`--skip-verify`、`--disable-helo`、`--skip-local-2fs` 和 `--active` 选项可以采用以下形式使用:
|
|
||||||
- `--option`、`--option=true` 以启用选项
|
|
||||||
- `--option=false` 以禁用选项
|
|
||||||
如果未指定这些选项,则在 `update-smtp` 中不会更改值,或者在 `add-smtp` 中将使用默认的 `false` 值。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth add-smtp --name ldap --host smtp.mydomain.org --port 587 --skip-verify --active`
|
|
||||||
- `update-smtp`:
|
|
||||||
- 选项:
|
|
||||||
- `--id`:要更新的源的 ID。必填。
|
|
||||||
- 其他选项与 `add-smtp` 共享
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth update-smtp --id 1 --host smtp.mydomain.org --port 587 --skip-verify=false`
|
|
||||||
- `gitea admin auth update-smtp --id 1 --active=false`
|
|
||||||
- `add-ldap`:添加新的 LDAP(通过 Bind DN)认证源
|
|
||||||
- 选项:
|
|
||||||
- `--name value`:认证名称。必填。
|
|
||||||
- `--not-active`:停用认证源。
|
|
||||||
- `--security-protocol value`:安全协议名称。必填。
|
|
||||||
- `--skip-tls-verify`:禁用 TLS 验证。
|
|
||||||
- `--host value`:LDAP 服务器的地址。必填。
|
|
||||||
- `--port value`:连接到 LDAP 服务器时使用的端口。必填。
|
|
||||||
- `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。必填。
|
|
||||||
- `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。必填。
|
|
||||||
- `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。
|
|
||||||
- `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。
|
|
||||||
- `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。
|
|
||||||
- `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。
|
|
||||||
- `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。
|
|
||||||
- `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。必填。
|
|
||||||
- `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。
|
|
||||||
- `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。
|
|
||||||
- `--bind-dn value`:在搜索用户时绑定到 LDAP 服务器的 DN。
|
|
||||||
- `--bind-password value`:绑定 DN 的密码(如果有)。
|
|
||||||
- `--attributes-in-bind`:在绑定 DN 上下文中获取属性。
|
|
||||||
- `--synchronize-users`:启用用户同步。
|
|
||||||
- `--page-size value`:搜索页面大小。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" --email-attribute mail`
|
|
||||||
- `update-ldap`:更新现有的 LDAP(通过 Bind DN)认证源
|
|
||||||
- 选项:
|
|
||||||
- `--id value`:认证源的 ID。必填。
|
|
||||||
- `--name value`:认证名称。
|
|
||||||
- `--not-active`:停用认证源。
|
|
||||||
- `--security-protocol value`:安全协议名称。
|
|
||||||
- `--skip-tls-verify`:禁用 TLS 验证。
|
|
||||||
- `--host value`:LDAP 服务器的地址。
|
|
||||||
- `--port value`:连接到 LDAP 服务器时使用的端口。
|
|
||||||
- `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。
|
|
||||||
- `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。
|
|
||||||
- `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。
|
|
||||||
- `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。
|
|
||||||
- `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。
|
|
||||||
- `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。
|
|
||||||
- `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。
|
|
||||||
- `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。
|
|
||||||
- `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。
|
|
||||||
- `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。
|
|
||||||
- `--bind-dn value`:在搜索用户时绑定到 LDAP 服务器的 DN。
|
|
||||||
- `--bind-password value`:绑定 DN 的密码(如果有)。
|
|
||||||
- `--attributes-in-bind`:在绑定 DN 上下文中获取属性。
|
|
||||||
- `--synchronize-users`:启用用户同步。
|
|
||||||
- `--page-size value`:搜索页面大小。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth update-ldap --id 1 --name "my ldap auth source"`
|
|
||||||
- `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
|
|
||||||
- `add-ldap-simple`:添加新的 LDAP(简单身份验证)认证源
|
|
||||||
- 选项:
|
|
||||||
- `--name value`:认证名称。必填。
|
|
||||||
- `--not-active`:停用认证源。
|
|
||||||
- `--security-protocol value`:安全协议名称。必填。
|
|
||||||
- `--skip-tls-verify`:禁用 TLS 验证。
|
|
||||||
- `--host value`:LDAP 服务器的地址。必填。
|
|
||||||
- `--port value`:连接到 LDAP 服务器时使用的端口。必填。
|
|
||||||
- `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。
|
|
||||||
- `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。必填。
|
|
||||||
- `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。
|
|
||||||
- `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。
|
|
||||||
- `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。
|
|
||||||
- `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。
|
|
||||||
- `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。
|
|
||||||
- `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。必填。
|
|
||||||
- `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。
|
|
||||||
- `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。
|
|
||||||
- `--user-dn value`:用户的 DN。必填。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail`
|
|
||||||
- `update-ldap-simple`:更新现有的 LDAP(简单身份验证)认证源
|
|
||||||
- 选项:
|
|
||||||
- `--id value`:认证源的 ID。必填。
|
|
||||||
- `--name value`:认证名称。
|
|
||||||
- `--not-active`:停用认证源。
|
|
||||||
- `--security-protocol value`:安全协议名称。
|
|
||||||
- `--skip-tls-verify`:禁用 TLS 验证。
|
|
||||||
- `--host value`:LDAP 服务器的地址。
|
|
||||||
- `--port value`:连接到 LDAP 服务器时使用的端口。
|
|
||||||
- `--user-search-base value`:用户帐户将在其中搜索的 LDAP 基础路径。
|
|
||||||
- `--user-filter value`:声明如何查找试图进行身份验证的用户记录的 LDAP 过滤器。
|
|
||||||
- `--admin-filter value`:指定是否应授予用户管理员特权的 LDAP 过滤器。
|
|
||||||
- `--restricted-filter value`:指定是否应将用户设置为受限状态的 LDAP 过滤器。
|
|
||||||
- `--username-attribute value`:用户 LDAP 记录中包含用户名的属性。
|
|
||||||
- `--firstname-attribute value`:用户 LDAP 记录中包含用户名字的属性。
|
|
||||||
- `--surname-attribute value`:用户 LDAP 记录中包含用户姓氏的属性。
|
|
||||||
- `--email-attribute value`:用户 LDAP 记录中包含用户电子邮件地址的属性。
|
|
||||||
- `--public-ssh-key-attribute value`:用户 LDAP 记录中包含用户公共 SSH 密钥的属性。
|
|
||||||
- `--avatar-attribute value`:用户 LDAP 记录中包含用户头像的属性。
|
|
||||||
- `--user-dn value`:用户的 DN。
|
|
||||||
- 示例:
|
|
||||||
- `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"`
|
|
||||||
- `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
|
|
||||||
|
|
||||||
### cert
|
|
||||||
|
|
||||||
生成自签名的SSL证书。将输出到当前目录下的`cert.pem`和`key.pem`文件中,并且会覆盖任何现有文件。
|
|
||||||
|
|
||||||
- 选项:
|
|
||||||
- `--host value`:逗号分隔的主机名和IP地址列表,此证书适用于这些主机。支持使用通配符。必填。
|
|
||||||
- `--ecdsa-curve value`:用于生成密钥的ECDSA曲线。可选。有效选项为P224、P256、P384、P521。
|
|
||||||
- `--rsa-bits value`:要生成的RSA密钥的大小。可选。如果设置了--ecdsa-curve,则忽略此选项。(默认值:3072)。
|
|
||||||
- `--start-date value`:证书的创建日期。可选。(格式:`Jan 1 15:04:05 2011`)。
|
|
||||||
- `--duration value`:证书有效期。可选。(默认值:8760h0m0s)
|
|
||||||
- `--ca`:如果提供此选项,则证书将生成自己的证书颁发机构。可选。
|
|
||||||
- 示例:
|
|
||||||
- `gitea cert --host git.example.com,example.com,www.example.com --ca`
|
|
||||||
|
|
||||||
### dump
|
|
||||||
|
|
||||||
将所有文件和数据库导出到一个zip文件中。输出文件将保存在当前目录下,类似于`gitea-dump-1482906742.zip`。
|
|
||||||
|
|
||||||
- 选项:
|
|
||||||
- `--file name`,`-f name`:指定要创建的导出文件的名称。可选。(默认值:gitea-dump-[timestamp].zip)。
|
|
||||||
- `--tempdir path`,`-t path`:指定临时目录的路径。可选。(默认值:/tmp)。
|
|
||||||
- `--skip-repository`,`-R`:跳过仓库的导出。可选。
|
|
||||||
- `--skip-custom-dir`:跳过自定义目录的导出。可选。
|
|
||||||
- `--skip-lfs-data`:跳过LFS数据的导出。可选。
|
|
||||||
- `--skip-attachment-data`:跳过附件数据的导出。可选。
|
|
||||||
- `--skip-package-data`:跳过包数据的导出。可选。
|
|
||||||
- `--skip-log`:跳过日志数据的导出。可选。
|
|
||||||
- `--database`,`-d`:指定数据库的SQL语法。可选。
|
|
||||||
- `--verbose`,`-V`:如果提供此选项,显示附加详细信息。可选。
|
|
||||||
- `--type`:设置导出的格式。可选。(默认值:zip)
|
|
||||||
- 示例:
|
|
||||||
- `gitea dump`
|
|
||||||
- `gitea dump --verbose`
|
|
||||||
|
|
||||||
### generate
|
|
||||||
|
|
||||||
用于在配置文件中生成随机值和令牌。对于自动部署时生成值非常有用。
|
|
||||||
|
|
||||||
- 命令:
|
|
||||||
- `secret`:
|
|
||||||
- 选项:
|
|
||||||
- `INTERNAL_TOKEN`: 用于内部 API 调用身份验证的令牌。
|
|
||||||
- `JWT_SECRET`: 用于 LFS 和 OAUTH2 JWT 身份验证的密钥(LFS_JWT_SECRET 是此选项的别名,用于向后兼容)。
|
|
||||||
- `SECRET_KEY`: 全局密钥。
|
|
||||||
- 示例:
|
|
||||||
- `gitea generate secret INTERNAL_TOKEN`
|
|
||||||
- `gitea generate secret JWT_SECRET`
|
|
||||||
- `gitea generate secret SECRET_KEY`
|
|
||||||
|
|
||||||
### keys
|
|
||||||
|
|
||||||
提供一个 SSHD AuthorizedKeysCommand。需要在 sshd 配置文件中进行配置:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
...
|
|
||||||
# -e 的值和 AuthorizedKeysCommandUser 应与运行 Gitea 的用户名匹配
|
|
||||||
AuthorizedKeysCommandUser git
|
|
||||||
AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
|
|
||||||
```
|
|
||||||
|
|
||||||
该命令将返回适用于提供的密钥的合适 authorized_keys 行。您还应在 `app.ini` 的 `[server]` 部分设置值 `SSH_CREATE_AUTHORIZED_KEYS_FILE=false`。
|
|
||||||
|
|
||||||
注意: opensshd 要求 Gitea 程序由 root 拥有,并且不可由组或其他人写入。程序必须使用绝对路径指定。
|
|
||||||
注意: Gitea 必须在运行此命令时处于运行状态才能成功。
|
|
||||||
|
|
||||||
### migrate
|
|
||||||
|
|
||||||
迁移数据库。该命令可用于在首次启动服务器之前运行其他命令。此命令是幂等的。
|
|
||||||
|
|
||||||
### doctor check
|
|
||||||
|
|
||||||
对 Gitea 实例进行诊断,可以修复一些可修复的问题。
|
|
||||||
默认只运行部分检查,额外的检查可以参考:
|
|
||||||
|
|
||||||
- `gitea doctor check --list` - 列出所有可用的检查
|
|
||||||
- `gitea doctor check --all` - 运行所有可用的检查
|
|
||||||
- `gitea doctor check --default` - 运行默认的检查
|
|
||||||
- `gitea doctor check --run [check(s),]...` - 运行指定的名字的检查
|
|
||||||
|
|
||||||
有些问题可以通过设置 `--fix` 选项进行自动修复。
|
|
||||||
额外的日志可以通过 `--log-file=...` 进行设置。
|
|
||||||
|
|
||||||
#### doctor recreate-table
|
|
||||||
|
|
||||||
有时,在迁移时,旧的列和默认值可能会在数据库模式中保持不变。这可能会导致警告,如下所示:
|
|
||||||
|
|
||||||
```
|
|
||||||
2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0
|
|
||||||
```
|
|
||||||
|
|
||||||
您可以通过以下方式让 Gitea 重新创建这些表,并将旧数据复制到新表中,并适当设置默认值:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table user
|
|
||||||
```
|
|
||||||
|
|
||||||
您可以使用以下方式让 Gitea 重新创建多个表:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table table1 table2 ...
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您希望 Gitea 重新创建所有表,请直接调用:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table
|
|
||||||
```
|
|
||||||
|
|
||||||
强烈建议在运行这些命令之前备份您的数据库。
|
|
||||||
|
|
||||||
### doctor convert
|
|
||||||
|
|
||||||
将现有的 MySQL 数据库从 utf8 转换为 utf8mb4,或者把 MSSQL 数据库从 varchar 转换为 nvarchar。
|
|
||||||
|
|
||||||
### manager
|
|
||||||
|
|
||||||
管理运行中的服务器操作:
|
|
||||||
|
|
||||||
- 命令:
|
|
||||||
- `shutdown`: 优雅地关闭运行中的进程
|
|
||||||
- `restart`: 优雅地重新启动运行中的进程(对于Windows服务器尚未实现)
|
|
||||||
- `flush-queues`: 刷新运行中的进程中的队列
|
|
||||||
- 选项:
|
|
||||||
- `--timeout value`: 刷新过程的超时时间(默认值: 1m0s)
|
|
||||||
- `--non-blocking`: 设置为true,以在返回之前不等待刷新完成
|
|
||||||
- `logging`: 调整日志命令
|
|
||||||
- 命令:
|
|
||||||
- `pause`: 暂停日志记录
|
|
||||||
- 注意:
|
|
||||||
- 如果日志级别低于此级别,日志级别将被临时提升为INFO。
|
|
||||||
- Gitea将在一定程度上缓冲日志,并在超过该点后丢弃日志。
|
|
||||||
- `resume`: 恢复日志记录
|
|
||||||
- `release-and-reopen`: 使Gitea释放和重新打开用于日志记录的文件和连接(相当于向Gitea发送SIGUSR1信号)。
|
|
||||||
- `remove name`: 删除指定的日志记录器
|
|
||||||
- 选项:
|
|
||||||
- `--group group`, `-g group`: 从中删除子记录器的组(默认为`default`)
|
|
||||||
- `add`: 添加日志记录器
|
|
||||||
- 命令:
|
|
||||||
- `console`: 添加控制台日志记录器
|
|
||||||
- 选项:
|
|
||||||
- `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default"
|
|
||||||
- `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式
|
|
||||||
- `--level value`, `-l value`: 新日志记录器的日志级别
|
|
||||||
- `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别
|
|
||||||
- `--flags value`, `-F value`: 日志记录器的标志
|
|
||||||
- `--expression value`, `-e value`: 日志记录器的匹配表达式
|
|
||||||
- `--prefix value`, `-p value`: 日志记录器的前缀
|
|
||||||
- `--color`: 在日志中使用颜色
|
|
||||||
- `--stderr`: 将控制台日志输出到stderr - 仅适用于控制台
|
|
||||||
- `file`: 添加文件日志记录器
|
|
||||||
- 选项:
|
|
||||||
- `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default"
|
|
||||||
- `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式
|
|
||||||
- `--level value`, `-l value`: 新日志记录器的日志级别
|
|
||||||
- `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别
|
|
||||||
- `--flags value`, `-F value`: 日志记录器的标志
|
|
||||||
- `--expression value`, `-e value`: 日志记录器的匹配表达式
|
|
||||||
- `--prefix value`, `-p value`: 日志记录器的前缀
|
|
||||||
- `--color`: 在日志中使用颜色
|
|
||||||
- `--filename value`, `-f value`: 日志记录器的文件名
|
|
||||||
- `--rotate`, `-r`: 轮转日志
|
|
||||||
- `--max-size value`, `-s value`: 在轮转之前的最大大小(以字节为单位)
|
|
||||||
- `--daily`, `-d`: 每天轮转日志
|
|
||||||
- `--max-days value`, `-D value`: 保留的每日日志的最大数量
|
|
||||||
- `--compress`, `-z`: 压缩轮转的日志
|
|
||||||
- `--compression-level value`, `-Z value`: 使用的压缩级别
|
|
||||||
- `conn`: 添加网络连接日志记录器
|
|
||||||
- 选项:
|
|
||||||
- `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default"
|
|
||||||
- `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式
|
|
||||||
- `--level value`, `-l value`: 新日志记录器的日志级别
|
|
||||||
- `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别
|
|
||||||
- `--flags value`, `-F value`: 日志记录器的标志
|
|
||||||
- `--expression value`, `-e value`: 日志记录器的匹配表达式
|
|
||||||
- `--prefix value`, `-p value`: 日志记录器的前缀
|
|
||||||
- `--color`: 在日志中使用颜色
|
|
||||||
- `--reconnect-on-message`, `-R`: 对于每个消息重新连接主机
|
|
||||||
- `--reconnect`, `-r`: 连接中断时重新连接主机
|
|
||||||
- `--protocol value`, `-P value`: 设置要使用的协议:tcp、unix或udp(默认为tcp)
|
|
||||||
- `--address value`, `-a value`: 要连接到的主机地址和端口(默认为:7020)
|
|
||||||
- `smtp`: 添加SMTP日志记录器
|
|
||||||
- 选项:
|
|
||||||
- `--group value`, `-g value`: 要添加日志记录器的组 - 默认为"default"
|
|
||||||
- `--name value`, `-n value`: 新日志记录器的名称 - 默认为模式
|
|
||||||
- `--level value`, `-l value`: 新日志记录器的日志级别
|
|
||||||
- `--stacktrace-level value`, `-L value`: 堆栈跟踪日志级别
|
|
||||||
- `--flags value`, `-F value`: 日志记录器的标志
|
|
||||||
- `--expression value`, `-e value`: 日志记录器的匹配表达式
|
|
||||||
- `--prefix value`, `-p value`: 日志记录器的前缀
|
|
||||||
- `--color`: 在日志中使用颜色
|
|
||||||
- `--username value`, `-u value`: 邮件服务器用户名
|
|
||||||
- `--password value`, `-P value`: 邮件服务器密码
|
|
||||||
- `--host value`, `-H value`: 邮件服务器主机(默认为: 127.0.0.1:25)
|
|
||||||
- `--send-to value`, `-s value`: 要发送到的电子邮件地址
|
|
||||||
- `--subject value`, `-S value`: 发送电子邮件的主题标题
|
|
||||||
- `processes`: 显示 Gitea 进程和 Goroutine 信息
|
|
||||||
- 选项:
|
|
||||||
- `--flat`: 以平面表格形式显示进程,而不是树形结构
|
|
||||||
- `--no-system`: 不显示系统进程
|
|
||||||
- `--stacktraces`: 显示与进程关联的 Goroutine 的堆栈跟踪
|
|
||||||
- `--json`: 输出为 JSON 格式
|
|
||||||
- `--cancel PID`: 向具有 PID 的进程发送取消命令(仅适用于非系统进程)
|
|
||||||
|
|
||||||
### dump-repo
|
|
||||||
|
|
||||||
`dump-repo` 从 Git/GitHub/Gitea/GitLab 中转储存储库数据:
|
|
||||||
|
|
||||||
- 选项:
|
|
||||||
- `--git_service service`:Git 服务,可以是 `git`、`github`、`gitea`、`gitlab`。如果 `clone_addr` 可以被识别,则可以忽略此选项。
|
|
||||||
- `--repo_dir dir`,`-r dir`:存储数据的存储库目录路径。
|
|
||||||
- `--clone_addr addr`:将被克隆的 URL,目前可以是 git/github/gitea/gitlab 的 http/https URL。例如:https://github.com/lunny/tango.git
|
|
||||||
- `--auth_username lunny`:访问 `clone_addr` 的用户名。
|
|
||||||
- `--auth_password <password>`:访问 `clone_addr` 的密码。
|
|
||||||
- `--auth_token <token>`:访问 `clone_addr` 的个人令牌。
|
|
||||||
- `--owner_name lunny`:如果非空,数据将存储在具有所有者名称的目录中。
|
|
||||||
- `--repo_name tango`:如果非空,数据将存储在具有存储库名称的目录中。
|
|
||||||
- `--units <units>`:要迁移的项目,一个或多个项目应以逗号分隔。允许的项目有 wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments。如果为空,则表示所有项目。
|
|
||||||
|
|
||||||
### restore-repo
|
|
||||||
|
|
||||||
`restore-repo` 从磁盘目录中还原存储库数据:
|
|
||||||
|
|
||||||
- 选项:
|
|
||||||
- `--repo_dir dir`,`-r dir`:还原数据的存储库目录路径。
|
|
||||||
- `--owner_name lunny`:还原目标所有者名称。
|
|
||||||
- `--repo_name tango`:还原目标存储库名称。
|
|
||||||
- `--units <units>`:要还原的项目,一个或多个项目应以逗号分隔。允许的项目有 wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments。如果为空,则表示所有项目。
|
|
||||||
|
|
||||||
### actions generate-runner-token
|
|
||||||
|
|
||||||
生成一个供 Runner 使用的新令牌,用于向服务器注册。
|
|
||||||
|
|
||||||
- 选项:
|
|
||||||
- `--scope {owner}[/{repo}]`,`-s {owner}[/{repo}]`:限制 Runner 的范围,没有范围表示该 Runner 可用于所有仓库,但你也可以将其限制为特定的仓库或所有者。
|
|
||||||
|
|
||||||
要注册全局 Runner:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea actions generate-runner-token
|
|
||||||
```
|
|
||||||
|
|
||||||
要注册特定组织的 Runner,例如 `org`:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea actions generate-runner-token -s org
|
|
||||||
```
|
|
||||||
|
|
||||||
要注册特定仓库的 Runner,例如 `username/test-repo`:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea actions generate-runner-token -s username/test-repo
|
|
||||||
```
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,403 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-04-15T14:56:00+02:00"
|
|
||||||
title: "Customizing Gitea"
|
|
||||||
slug: "customizing-gitea"
|
|
||||||
sidebar_position: 100
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/customizing-gitea
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Customizing Gitea"
|
|
||||||
identifier: "customizing-gitea"
|
|
||||||
sidebar_position: 100
|
|
||||||
---
|
|
||||||
|
|
||||||
# Customizing Gitea
|
|
||||||
|
|
||||||
Customizing Gitea is typically done using the `CustomPath` folder - by default this is
|
|
||||||
the `custom` folder from the working directory (WorkPath), but may be different if your build has
|
|
||||||
set this differently. This is the central place to override configuration settings,
|
|
||||||
templates, etc. You can check the `CustomPath` using `gitea help`. You can also find
|
|
||||||
the path on the _Configuration_ tab in the _Site Administration_ page. You can override
|
|
||||||
the `CustomPath` by setting either the `GITEA_CUSTOM` environment variable or by
|
|
||||||
using the `--custom-path` option on the `gitea` binary. (The option will override the
|
|
||||||
environment variable.)
|
|
||||||
|
|
||||||
If Gitea is deployed from binary, all default paths will be relative to the Gitea
|
|
||||||
binary. If installed from a distribution, these paths will likely be modified to
|
|
||||||
the Linux Filesystem Standard. Gitea will attempt to create required folders, including
|
|
||||||
`custom/`. Distributions may provide a symlink for `custom` using `/etc/gitea/`.
|
|
||||||
|
|
||||||
Application settings can be found in file `CustomConf` which is by default,
|
|
||||||
`$GITEA_CUSTOM/conf/app.ini` but may be different if your build has set this differently.
|
|
||||||
Again `gitea help` will allow you review this variable and you can override it using the
|
|
||||||
`--config` option on the `gitea` binary.
|
|
||||||
|
|
||||||
- [Quick Cheat Sheet](administration/config-cheat-sheet.md)
|
|
||||||
- [Complete List](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini)
|
|
||||||
|
|
||||||
If the `CustomPath` folder can't be found despite checking `gitea help`, check the `GITEA_CUSTOM`
|
|
||||||
environment variable; this can be used to override the default path to something else.
|
|
||||||
`GITEA_CUSTOM` might, for example, be set by an init script. You can check whether the value
|
|
||||||
is set under the "Configuration" tab on the site administration page.
|
|
||||||
|
|
||||||
- [List of Environment Variables](administration/environment-variables.md)
|
|
||||||
|
|
||||||
**Note:** Gitea must perform a full restart to see configuration changes.
|
|
||||||
|
|
||||||
## Serving custom public files
|
|
||||||
|
|
||||||
To make Gitea serve custom public files (like pages and images), use the folder
|
|
||||||
`$GITEA_CUSTOM/public/` as the webroot. Symbolic links will be followed.
|
|
||||||
At the moment, only the following files are served:
|
|
||||||
|
|
||||||
- `public/robots.txt`
|
|
||||||
- files in the `public/.well-known/` folder
|
|
||||||
- files in the `public/assets/` folder
|
|
||||||
|
|
||||||
For example, a file `image.png` stored in `$GITEA_CUSTOM/public/assets/`, can be accessed with
|
|
||||||
the url `http://gitea.domain.tld/assets/image.png`.
|
|
||||||
|
|
||||||
## Changing the logo
|
|
||||||
|
|
||||||
To build a custom logo and/or favicon clone the Gitea source repository, replace `assets/logo.svg` and/or `assets/favicon.svg` and run
|
|
||||||
`make generate-images`. `assets/favicon.svg` is used for the favicon only. This will update below output files which you can then place in `$GITEA_CUSTOM/public/assets/img` on your server:
|
|
||||||
|
|
||||||
- `public/assets/img/logo.svg` - Used for site icon, app icon
|
|
||||||
- `public/assets/img/logo.png` - Used for Open Graph
|
|
||||||
- `public/assets/img/avatar_default.png` - Used as the default avatar image
|
|
||||||
- `public/assets/img/apple-touch-icon.png` - Used on iOS devices for bookmarks
|
|
||||||
- `public/assets/img/favicon.svg` - Used for favicon
|
|
||||||
- `public/assets/img/favicon.png` - Used as fallback for browsers that don't support SVG favicons
|
|
||||||
|
|
||||||
In case the source image is not in vector format, you can attempt to convert a raster image using tools like [this](https://www.aconvert.com/image/png-to-svg/).
|
|
||||||
|
|
||||||
## Customizing Gitea pages and resources
|
|
||||||
|
|
||||||
Gitea's executable contains all the resources required to run: templates, images, style-sheets
|
|
||||||
and translations. Any of them can be overridden by placing a replacement in a matching path
|
|
||||||
inside the `custom` directory. For example, to replace the default `.gitignore` provided
|
|
||||||
for C++ repositories, we want to replace `options/gitignore/C++`. To do this, a replacement
|
|
||||||
must be placed in `$GITEA_CUSTOM/options/gitignore/C++` (see about the location of the `CustomPath`
|
|
||||||
directory at the top of this document).
|
|
||||||
|
|
||||||
Every single page of Gitea can be changed. Dynamic content is generated using [go templates](https://pkg.go.dev/html/template),
|
|
||||||
which can be modified by placing replacements below the `$GITEA_CUSTOM/templates` directory.
|
|
||||||
|
|
||||||
To obtain any embedded file (including templates), the [`gitea embedded` tool](administration/cmd-embedded.md) can be used. Alternatively, they can be found in the [`templates`](https://github.com/go-gitea/gitea/tree/main/templates) directory of Gitea source (Note: the example link is from the `main` branch. Make sure to use templates compatible with the release you are using).
|
|
||||||
|
|
||||||
Be aware that any statement contained inside `{{` and `}}` are Gitea's template syntax and
|
|
||||||
shouldn't be touched without fully understanding these components.
|
|
||||||
|
|
||||||
### Customizing startpage / homepage
|
|
||||||
|
|
||||||
Copy [`home.tmpl`](https://github.com/go-gitea/gitea/blob/main/templates/home.tmpl) for your version of Gitea from `templates` to `$GITEA_CUSTOM/templates`.
|
|
||||||
Edit as you wish.
|
|
||||||
Dont forget to restart your Gitea to apply the changes.
|
|
||||||
|
|
||||||
### Adding links and tabs
|
|
||||||
|
|
||||||
If all you want is to add extra links to the top navigation bar or footer, or extra tabs to the repository view, you can put them in `extra_links.tmpl` (links added to the navbar), `extra_links_footer.tmpl` (links added to the left side of footer), and `extra_tabs.tmpl` inside your `$GITEA_CUSTOM/templates/custom/` directory.
|
|
||||||
|
|
||||||
For instance, let's say you are in Germany and must add the famously legally-required "Impressum"/about page, listing who is responsible for the site's content:
|
|
||||||
just place it under your "$GITEA_CUSTOM/public/assets/" directory (for instance `$GITEA_CUSTOM/public/assets/impressum.html`) and put a link to it in either `$GITEA_CUSTOM/templates/custom/extra_links.tmpl` or `$GITEA_CUSTOM/templates/custom/extra_links_footer.tmpl`.
|
|
||||||
|
|
||||||
To match the current style, the link should have the class name "item", and you can use `{{AppSubUrl}}` to get the base URL:
|
|
||||||
`<a class="item" href="{{AppSubUrl}}/assets/impressum.html">Impressum</a>`
|
|
||||||
|
|
||||||
For more information, see [Adding Legal Pages](administration/adding-legal-pages.md).
|
|
||||||
|
|
||||||
You can add new tabs in the same way, putting them in `extra_tabs.tmpl`.
|
|
||||||
The exact HTML needed to match the style of other tabs is in the file
|
|
||||||
`templates/repo/header.tmpl`
|
|
||||||
([source in GitHub](https://github.com/go-gitea/gitea/blob/main/templates/repo/header.tmpl))
|
|
||||||
|
|
||||||
### Other additions to the page
|
|
||||||
|
|
||||||
Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful templates you can put in your `$GITEA_CUSTOM/templates/custom/` directory:
|
|
||||||
|
|
||||||
- `header.tmpl`, just before the end of the `<head>` tag where you can add custom CSS files for instance.
|
|
||||||
- `body_outer_pre.tmpl`, right after the start of `<body>`.
|
|
||||||
- `body_inner_pre.tmpl`, before the top navigation bar, but already inside the main container `<div class="full height">`.
|
|
||||||
- `body_inner_post.tmpl`, before the end of the main container.
|
|
||||||
- `body_outer_post.tmpl`, before the bottom `<footer>` element.
|
|
||||||
- `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional JavaScript.
|
|
||||||
|
|
||||||
### Using Gitea variables
|
|
||||||
|
|
||||||
It's possible to use various Gitea variables in your custom templates.
|
|
||||||
|
|
||||||
First, _temporarily_ enable development mode: in your `app.ini` change from `RUN_MODE = prod` to `RUN_MODE = dev`. Then add `{{ $ | DumpVar }}` to any of your templates, restart Gitea and refresh that page; that will dump all available variables.
|
|
||||||
|
|
||||||
Find the data that you need, and use the corresponding variable; for example, if you need the name of the repository then you'd use `{{.Repository.Name}}`.
|
|
||||||
|
|
||||||
If you need to transform that data somehow, and aren't familiar with Go, an easy workaround is to add the data to the DOM and add a small JavaScript script block to manipulate the data.
|
|
||||||
|
|
||||||
### Example: PlantUML
|
|
||||||
|
|
||||||
You can add [PlantUML](https://plantuml.com/) support to Gitea's markdown by using a PlantUML server.
|
|
||||||
The data is encoded and sent to the PlantUML server which generates the picture. There is an online
|
|
||||||
demo server at http://www.plantuml.com/plantuml, but if you (or your users) have sensitive data you
|
|
||||||
can set up your own [PlantUML server](https://plantuml.com/server) instead. To set up PlantUML rendering,
|
|
||||||
copy JavaScript files from https://gitea.com/davidsvantesson/plantuml-code-highlight and put them in your
|
|
||||||
`$GITEA_CUSTOM/public/assets/` folder. Then add the following to `custom/footer.tmpl`:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
$(async () => {
|
|
||||||
if (!$('.language-plantuml').length) return;
|
|
||||||
await Promise.all([
|
|
||||||
$.getScript('https://your-gitea-server.com/assets/deflate.js'),
|
|
||||||
$.getScript('https://your-gitea-server.com/assets/encode.js'),
|
|
||||||
$.getScript('https://your-gitea-server.com/assets/plantuml_codeblock_parse.js'),
|
|
||||||
]);
|
|
||||||
// Replace call with address to your plantuml server
|
|
||||||
parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml");
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
You can then add blocks like the following to your markdown:
|
|
||||||
|
|
||||||
```plantuml
|
|
||||||
Alice -> Bob: Authentication Request
|
|
||||||
Bob --> Alice: Authentication Response
|
|
||||||
|
|
||||||
Alice -> Bob: Another authentication Request
|
|
||||||
Alice <-- Bob: Another authentication Response
|
|
||||||
```
|
|
||||||
|
|
||||||
The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`.
|
|
||||||
|
|
||||||
### Example: STL Preview
|
|
||||||
|
|
||||||
You can display STL file directly in Gitea by adding:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
function lS(src) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
let s = document.createElement("script");
|
|
||||||
s.src = src;
|
|
||||||
s.addEventListener("load", () => {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
document.body.appendChild(s);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($('.view-raw>a[href$=".stl" i]').length) {
|
|
||||||
$("body").append(
|
|
||||||
'<link href="/assets/Madeleine.js/src/css/Madeleine.css" rel="stylesheet">'
|
|
||||||
);
|
|
||||||
Promise.all([
|
|
||||||
lS("/assets/Madeleine.js/src/lib/stats.js"),
|
|
||||||
lS("/assets/Madeleine.js/src/lib/detector.js"),
|
|
||||||
lS("/assets/Madeleine.js/src/lib/three.min.js"),
|
|
||||||
lS("/assets/Madeleine.js/src/Madeleine.js"),
|
|
||||||
]).then(function () {
|
|
||||||
$(".view-raw")
|
|
||||||
.attr("id", "view-raw")
|
|
||||||
.attr("style", "padding: 0;margin-bottom: -10px;");
|
|
||||||
new Madeleine({
|
|
||||||
target: "view-raw",
|
|
||||||
data: $('.view-raw>a[href$=".stl" i]').attr("href"),
|
|
||||||
path: "/assets/Madeleine.js/src",
|
|
||||||
});
|
|
||||||
$('.view-raw>a[href$=".stl"]').remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
to the file `templates/custom/footer.tmpl`
|
|
||||||
|
|
||||||
You also need to download the content of the library [Madeleine.js](https://github.com/beige90/Madeleine.js) and place it under `$GITEA_CUSTOM/public/assets/` folder.
|
|
||||||
|
|
||||||
You should end-up with a folder structure similar to:
|
|
||||||
|
|
||||||
```
|
|
||||||
$GITEA_CUSTOM/templates
|
|
||||||
-- custom
|
|
||||||
`-- footer.tmpl
|
|
||||||
|
|
||||||
$GITEA_CUSTOM/public/assets/
|
|
||||||
-- Madeleine.js
|
|
||||||
|-- LICENSE
|
|
||||||
|-- README.md
|
|
||||||
|-- css
|
|
||||||
| |-- pygment_trac.css
|
|
||||||
| `-- stylesheet.css
|
|
||||||
|-- examples
|
|
||||||
| |-- ajax.html
|
|
||||||
| |-- index.html
|
|
||||||
| `-- upload.html
|
|
||||||
|-- images
|
|
||||||
| |-- bg_hr.png
|
|
||||||
| |-- blacktocat.png
|
|
||||||
| |-- icon_download.png
|
|
||||||
| `-- sprite_download.png
|
|
||||||
|-- models
|
|
||||||
| |-- dino2.stl
|
|
||||||
| |-- ducati.stl
|
|
||||||
| |-- gallardo.stl
|
|
||||||
| |-- lamp.stl
|
|
||||||
| |-- octocat.stl
|
|
||||||
| |-- skull.stl
|
|
||||||
| `-- treefrog.stl
|
|
||||||
`-- src
|
|
||||||
|-- Madeleine.js
|
|
||||||
|-- css
|
|
||||||
| `-- Madeleine.css
|
|
||||||
|-- icons
|
|
||||||
| |-- logo.png
|
|
||||||
| |-- madeleine.eot
|
|
||||||
| |-- madeleine.svg
|
|
||||||
| |-- madeleine.ttf
|
|
||||||
| `-- madeleine.woff
|
|
||||||
`-- lib
|
|
||||||
|-- MadeleineConverter.js
|
|
||||||
|-- MadeleineLoader.js
|
|
||||||
|-- detector.js
|
|
||||||
|-- stats.js
|
|
||||||
`-- three.min.js
|
|
||||||
```
|
|
||||||
|
|
||||||
Then restart Gitea and open a STL file on your Gitea instance.
|
|
||||||
|
|
||||||
## Customizing Gitea mails
|
|
||||||
|
|
||||||
The `$GITEA_CUSTOM/templates/mail` folder allows changing the body of every mail of Gitea.
|
|
||||||
Templates to override can be found in the
|
|
||||||
[`templates/mail`](https://github.com/go-gitea/gitea/tree/main/templates/mail)
|
|
||||||
directory of Gitea source.
|
|
||||||
Override by making a copy of the file under `$GITEA_CUSTOM/templates/mail` using a
|
|
||||||
full path structure matching source.
|
|
||||||
|
|
||||||
Any statement contained inside `{{` and `}}` are Gitea's template
|
|
||||||
syntax and shouldn't be touched without fully understanding these components.
|
|
||||||
|
|
||||||
## Adding Analytics to Gitea
|
|
||||||
|
|
||||||
Google Analytics, Matomo (previously Piwik), and other analytics services can be added to Gitea. To add the tracking code, refer to the `Other additions to the page` section of this document, and add the JavaScript to the `$GITEA_CUSTOM/templates/custom/header.tmpl` file.
|
|
||||||
|
|
||||||
## Customizing gitignores, labels, licenses, locales, and readmes.
|
|
||||||
|
|
||||||
Place custom files in corresponding sub-folder under `custom/options`.
|
|
||||||
|
|
||||||
**NOTE:** The files should not have a file extension, e.g. `Labels` rather than `Labels.txt`
|
|
||||||
|
|
||||||
### gitignores
|
|
||||||
|
|
||||||
To add custom .gitignore, add a file with existing [.gitignore rules](https://git-scm.com/docs/gitignore) in it to `$GITEA_CUSTOM/options/gitignore`
|
|
||||||
|
|
||||||
## Customizing the git configuration
|
|
||||||
|
|
||||||
Starting with Gitea 1.20, you can customize the git configuration via the `git.config` section.
|
|
||||||
|
|
||||||
### Enabling signed git pushes
|
|
||||||
|
|
||||||
To enable signed git pushes, set these two options:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[git.config]
|
|
||||||
receive.advertisePushOptions = true
|
|
||||||
receive.certNonceSeed = <randomstring>
|
|
||||||
```
|
|
||||||
|
|
||||||
`certNonceSeed` should be set to a random string and be kept secret.
|
|
||||||
|
|
||||||
### Labels
|
|
||||||
|
|
||||||
Starting with Gitea 1.19, you can add a file that follows the [YAML label format](https://github.com/go-gitea/gitea/blob/main/options/label/Advanced.yaml) to `$GITEA_CUSTOM/options/label`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
labels:
|
|
||||||
- name: "foo/bar" # name of the label that will appear in the dropdown
|
|
||||||
exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is /
|
|
||||||
color: aabbcc # hex colour coding
|
|
||||||
description: Some label # long description of label intent
|
|
||||||
```
|
|
||||||
|
|
||||||
The [legacy file format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) can still be used following the format below, however we strongly recommend using the newer YAML format instead.
|
|
||||||
|
|
||||||
`#hex-color label name ; label description`
|
|
||||||
|
|
||||||
For more information, see the [labels documentation](usage/labels.md).
|
|
||||||
|
|
||||||
### Licenses
|
|
||||||
|
|
||||||
To add a custom license, add a file with the license text to `$GITEA_CUSTOM/options/license`
|
|
||||||
|
|
||||||
### Locales
|
|
||||||
|
|
||||||
Locales are managed via our [Crowdin](https://crowdin.com/project/gitea).
|
|
||||||
You can override a locale by placing an altered locale file in `$GITEA_CUSTOM/options/locale`.
|
|
||||||
Gitea's default locale files can be found in the [`options/locale`](https://github.com/go-gitea/gitea/tree/main/options/locale) source folder and these should be used as examples for your changes.
|
|
||||||
|
|
||||||
To add a completely new locale, as well as placing the file in the above location, you will need to add the new lang and name to the `[i18n]` section in your `app.ini`. Keep in mind that Gitea will use those settings as **overrides**, so if you want to keep the other languages as well you will need to copy/paste the default values and add your own to them.
|
|
||||||
|
|
||||||
```
|
|
||||||
[i18n]
|
|
||||||
LANGS = en-US,foo-BAR
|
|
||||||
NAMES = English,FooBar
|
|
||||||
```
|
|
||||||
|
|
||||||
The first locale will be used as the default if user browser's language doesn't match any locale in the list.
|
|
||||||
|
|
||||||
Locales may change between versions, so keeping track of your customized locales is highly encouraged.
|
|
||||||
|
|
||||||
### Readmes
|
|
||||||
|
|
||||||
To add a custom Readme, add a markdown formatted file (without an `.md` extension) to `$GITEA_CUSTOM/options/readme`
|
|
||||||
|
|
||||||
**NOTE:** readme templates support **variable expansion**.
|
|
||||||
currently there are `{Name}` (name of repository), `{Description}`, `{CloneURL.SSH}`, `{CloneURL.HTTPS}` and `{OwnerName}`
|
|
||||||
|
|
||||||
### Reactions
|
|
||||||
|
|
||||||
To change reaction emoji's you can set allowed reactions at app.ini
|
|
||||||
|
|
||||||
```
|
|
||||||
[ui]
|
|
||||||
REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes
|
|
||||||
```
|
|
||||||
|
|
||||||
A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gitea.com/issues/8)
|
|
||||||
|
|
||||||
## Customizing the look of Gitea
|
|
||||||
|
|
||||||
The built-in themes are `gitea-light`, `gitea-dark`, and `gitea-auto` (which automatically adapts to OS settings).
|
|
||||||
|
|
||||||
The default theme can be changed via `DEFAULT_THEME` in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`.
|
|
||||||
|
|
||||||
Gitea also has support for user themes, which means every user can select which theme should be used.
|
|
||||||
The list of themes a user can choose from can be configured with the `THEMES` value in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`.
|
|
||||||
|
|
||||||
To make a custom theme available to all users:
|
|
||||||
|
|
||||||
1. Add a CSS file to `$GITEA_CUSTOM/public/assets/css/theme-<theme-name>.css`.
|
|
||||||
The value of `$GITEA_CUSTOM` of your instance can be queried by calling `gitea help` and looking up the value of "CustomPath".
|
|
||||||
2. Add `<theme-name>` to the comma-separated list of setting `THEMES` in `app.ini`
|
|
||||||
|
|
||||||
Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes).
|
|
||||||
|
|
||||||
The default theme sources can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes).
|
|
||||||
|
|
||||||
If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`.
|
|
||||||
This allows Gitea to adjust the Monaco code editor's theme accordingly.
|
|
||||||
|
|
||||||
## Customizing fonts
|
|
||||||
|
|
||||||
Fonts can be customized using CSS variables:
|
|
||||||
|
|
||||||
```css
|
|
||||||
:root {
|
|
||||||
--fonts-proportional: /* custom proportional fonts */ !important;
|
|
||||||
--fonts-monospace: /* custom monospace fonts */ !important;
|
|
||||||
--fonts-emoji: /* custom emoji fonts */ !important;
|
|
||||||
}
|
|
||||||
```
|
|
|
@ -1,91 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-04-15T14:56:00+02:00"
|
|
||||||
title: "自定义 Gitea 配置"
|
|
||||||
slug: "customizing-gitea"
|
|
||||||
sidebar_position: 100
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/customizing-gitea
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "自定义 Gitea 配置"
|
|
||||||
sidebar_position: 100
|
|
||||||
identifier: "customizing-gitea"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 自定义 Gitea 配置
|
|
||||||
|
|
||||||
Gitea 引用 `custom` 目录中的自定义配置文件来覆盖配置、模板等默认配置。
|
|
||||||
|
|
||||||
如果从二进制部署 Gitea ,则所有默认路径都将相对于该 gitea 二进制文件;如果从发行版安装,则可能会将这些路径修改为Linux文件系统标准。Gitea
|
|
||||||
将会自动创建包括 `custom/` 在内的必要应用目录,应用本身的配置存放在
|
|
||||||
`custom/conf/app.ini` 当中。在发行版中可能会以 `/etc/gitea/` 的形式为 `custom` 设置一个符号链接,查看配置详情请移步:
|
|
||||||
|
|
||||||
- [快速备忘单](administration/config-cheat-sheet.md)
|
|
||||||
- [完整配置清单](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini)
|
|
||||||
|
|
||||||
如果您在 binary 同目录下无法找到 `custom` 文件夹,请检查您的 `GITEA_CUSTOM`
|
|
||||||
环境变量配置, 因为它可能被配置到了其他地方(可能被一些启动脚本设置指定了目录)。
|
|
||||||
|
|
||||||
- [环境变量清单](administration/environment-variables.md)
|
|
||||||
|
|
||||||
**注:** 必须完全重启 Gitea 以使配置生效。
|
|
||||||
|
|
||||||
## 使用自定义 /robots.txt
|
|
||||||
|
|
||||||
将 [想要展示的内容](http://www.robotstxt.org/) 存放在 `custom` 目录中的
|
|
||||||
`robots.txt` 文件来让 Gitea 使用自定义的`/robots.txt` (默认:空 404)。
|
|
||||||
|
|
||||||
## 使用自定义的公共文件
|
|
||||||
|
|
||||||
将自定义的公共文件(比如页面和图片)作为 webroot 放在 `custom/public/` 中来让 Gitea 提供这些自定义内容(符号链接将被追踪)。
|
|
||||||
|
|
||||||
举例说明:`image.png` 存放在 `custom/public/assets/`中,那么它可以通过链接 http://gitea.domain.tld/assets/image.png 访问。
|
|
||||||
|
|
||||||
## 修改默认头像
|
|
||||||
|
|
||||||
替换以下目录中的 png 图片: `custom/public/assets/img/avatar\_default.png`
|
|
||||||
|
|
||||||
## 自定义 Gitea 页面
|
|
||||||
|
|
||||||
您可以改变 Gitea `custom/templates` 的每个单页面。您可以在 Gitea 源码的 `templates` 目录中找到用于覆盖的模板文件,应用将根据
|
|
||||||
`custom/templates` 目录下的路径结构进行匹配和覆盖。
|
|
||||||
|
|
||||||
包含在 `{{` 和 `}}` 中的任何语句都是 Gitea 的模板语法,如果您不完全理解这些组件,不建议您对它们进行修改。
|
|
||||||
|
|
||||||
### 添加链接和页签
|
|
||||||
|
|
||||||
如果您只是想添加额外的链接到顶部导航栏或额外的选项卡到存储库视图,您可以将它们放在您 `custom/templates/custom/` 目录下的 `extra_links.tmpl` 和 `extra_tabs.tmpl` 文件中。
|
|
||||||
|
|
||||||
举例说明:假设您需要在网站放置一个静态的“关于”页面,您只需将该页面放在您的
|
|
||||||
"custom/public/"目录下(比如 `custom/public/impressum.html`)并且将它与 `custom/templates/custom/extra_links.tmpl` 链接起来即可。
|
|
||||||
|
|
||||||
这个链接应当使用一个名为“item”的 class 来匹配当前样式,您可以使用 `{{AppSubUrl}}` 来获取 base URL:
|
|
||||||
`<a class="item" href="{{AppSubUrl}}/assets/impressum.html">Impressum</a>`
|
|
||||||
|
|
||||||
同理,您可以将页签添加到 `extra_tabs.tmpl` 中,使用同样的方式来添加页签。它的具体样式需要与
|
|
||||||
`templates/repo/header.tmpl` 中已有的其他选项卡的样式匹配
|
|
||||||
([source in GitHub](https://github.com/go-gitea/gitea/blob/main/templates/repo/header.tmpl))
|
|
||||||
|
|
||||||
### 页面的其他新增内容
|
|
||||||
|
|
||||||
除了 `extra_links.tmpl` 和 `extra_tabs.tmpl`,您可以在您的 `custom/templates/custom/` 目录中存放一些其他有用的模板,例如:
|
|
||||||
|
|
||||||
- `header.tmpl`,在 `<head>` 标记结束之前的模板,例如添加自定义CSS文件
|
|
||||||
- `body_outer_pre.tmpl`,在 `<body>` 标记开始处的模板
|
|
||||||
- `body_inner_pre.tmpl`,在顶部导航栏之前,但在主 container 内部的模板,例如添加一个 `<div class="full height">`
|
|
||||||
- `body_inner_post.tmpl`,在主 container 结束处的模板
|
|
||||||
- `body_outer_post.tmpl`,在底部 `<footer>` 元素之前.
|
|
||||||
- `footer.tmpl`,在 `<body>` 标签结束处的模板,可以在这里填写一些附加的 Javascript 脚本。
|
|
||||||
|
|
||||||
## 自定义 gitignores,labels, licenses, locales 以及 readmes
|
|
||||||
|
|
||||||
将自定义文件放在 `custom/options` 下相应子的文件夹中即可
|
|
||||||
|
|
||||||
## 更改 Gitea 外观
|
|
||||||
|
|
||||||
内置主题是“gitea-light”、“gitea-dark”和“gitea-auto”(自动适应操作系统设置)。
|
|
||||||
|
|
||||||
默认主题可以通过 `app.ini` 的 [ui](administration/config-cheat-sheet.md#ui-ui) 部分中的 `DEFAULT_THEME` 进行更改。
|
|
|
@ -1,86 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-10-15T10:10:00+05:00"
|
|
||||||
title: "Email setup"
|
|
||||||
slug: "email-setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/email-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Email setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
identifier: "email-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Email setup
|
|
||||||
|
|
||||||
Gitea has mailer functionality for sending transactional emails (such as registration confirmation). It can be configured to either use Sendmail (or compatible MTAs like Postfix and msmtp) or directly use SMTP server.
|
|
||||||
|
|
||||||
## Using Sendmail
|
|
||||||
|
|
||||||
Use `sendmail` command as mailer.
|
|
||||||
|
|
||||||
Note: For use in the official Gitea Docker image, please configure with the SMTP version (see the following section).
|
|
||||||
|
|
||||||
Note: For Internet-facing sites consult documentation of your MTA for instructions to send emails over TLS. Also set up SPF, DMARC, and DKIM DNS records to make emails sent be accepted as legitimate by various email providers.
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[mailer]
|
|
||||||
ENABLED = true
|
|
||||||
FROM = gitea@mydomain.com
|
|
||||||
PROTOCOL = sendmail
|
|
||||||
SENDMAIL_PATH = /usr/sbin/sendmail
|
|
||||||
SENDMAIL_ARGS = "--" ; most "sendmail" programs take options, "--" will prevent an email address being interpreted as an option.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using SMTP
|
|
||||||
|
|
||||||
Directly use SMTP server as relay. This option is useful if you don't want to set up MTA on your instance but you have an account at email provider.
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[mailer]
|
|
||||||
ENABLED = true
|
|
||||||
FROM = gitea@mydomain.com
|
|
||||||
PROTOCOL = smtps
|
|
||||||
SMTP_ADDR = mail.mydomain.com
|
|
||||||
SMTP_PORT = 587
|
|
||||||
USER = gitea@mydomain.com
|
|
||||||
PASSWD = `password`
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart Gitea for the configuration changes to take effect.
|
|
||||||
|
|
||||||
To send a test email to validate the settings, go to Gitea > Site Administration > Configuration > SMTP Mailer Configuration.
|
|
||||||
|
|
||||||
For the full list of options check the [Config Cheat Sheet](administration/config-cheat-sheet.md)
|
|
||||||
|
|
||||||
Please note: authentication is only supported when the SMTP server communication is encrypted with TLS or `HOST=localhost`. TLS encryption can be through:
|
|
||||||
|
|
||||||
- STARTTLS (also known as Opportunistic TLS) via port 587. Initial connection is done over cleartext, but then be upgraded over TLS if the server supports it.
|
|
||||||
- SMTPS connection (SMTP over TLS) via the default port 465. Connection to the server use TLS from the beginning.
|
|
||||||
- Forced SMTPS connection with `PROTOCOL=smtps`. (These are both known as Implicit TLS.)
|
|
||||||
This is due to protections imposed by the Go internal libraries against STRIPTLS attacks.
|
|
||||||
|
|
||||||
Note that Implicit TLS is recommended by [RFC8314](https://tools.ietf.org/html/rfc8314#section-3) since 2018.
|
|
||||||
|
|
||||||
### Gmail
|
|
||||||
|
|
||||||
The following configuration should work with GMail's SMTP server:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[mailer]
|
|
||||||
ENABLED = true
|
|
||||||
HOST = smtp.gmail.com:465 ; Remove this line for Gitea >= 1.18.0
|
|
||||||
SMTP_ADDR = smtp.gmail.com
|
|
||||||
SMTP_PORT = 465
|
|
||||||
FROM = example.user@gmail.com
|
|
||||||
USER = example.user
|
|
||||||
PASSWD = `***`
|
|
||||||
PROTOCOL = smtps
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that you'll need to create and use an [App password](https://support.google.com/accounts/answer/185833?hl=en) by enabling 2FA on your Google
|
|
||||||
account. You won't be able to use your Google account password directly.
|
|
|
@ -1,85 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "Email 设置"
|
|
||||||
slug: "email-setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/email-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Email 设置"
|
|
||||||
sidebar_position: 12
|
|
||||||
identifier: "email-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Email 设置
|
|
||||||
|
|
||||||
Gitea 具有邮件功能,用于发送事务性邮件(例如注册确认邮件)。它可以配置为使用 Sendmail(或兼容的 MTA,例如 Postfix 和 msmtp)或直接使用 SMTP 服务器。
|
|
||||||
|
|
||||||
## 使用 Sendmail
|
|
||||||
|
|
||||||
使用 `sendmail` 命令作为邮件传输代理(mailer)。
|
|
||||||
|
|
||||||
注意:对于在官方Gitea Docker镜像中使用,请使用SMTP版本进行配置(请参考下一节)。
|
|
||||||
|
|
||||||
注意:对于面向互联网的网站,请查阅您的 MTA 文档以了解通过TLS发送邮件的说明。同时设置 SPF、DMARC 和 DKIM DNS 记录,以使发送的邮件被各个电子邮件提供商接受为合法邮件。
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[mailer]
|
|
||||||
ENABLED = true
|
|
||||||
FROM = gitea@mydomain.com
|
|
||||||
PROTOCOL = sendmail
|
|
||||||
SENDMAIL_PATH = /usr/sbin/sendmail
|
|
||||||
SENDMAIL_ARGS = "--" ; 大多数 "sendmail" 程序都接受选项,使用 "--" 将防止电子邮件地址被解释为选项。
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用 SMTP
|
|
||||||
|
|
||||||
直接使用 SMTP 服务器作为中继。如果您不想在实例上设置 MTA,但在电子邮件提供商那里有一个帐户,这个选项非常有用。
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[mailer]
|
|
||||||
ENABLED = true
|
|
||||||
FROM = gitea@mydomain.com
|
|
||||||
PROTOCOL = smtps
|
|
||||||
SMTP_ADDR = mail.mydomain.com
|
|
||||||
SMTP_PORT = 587
|
|
||||||
USER = gitea@mydomain.com
|
|
||||||
PASSWD = `password`
|
|
||||||
```
|
|
||||||
|
|
||||||
重启 Gitea 以使配置更改生效。
|
|
||||||
|
|
||||||
要发送测试邮件以验证设置,请转到 Gitea > 站点管理 > 配置 > SMTP 邮件配置。
|
|
||||||
|
|
||||||
有关所有选项的完整列表,请查看[配置速查表](administration/config-cheat-sheet.md)。
|
|
||||||
|
|
||||||
请注意:只有在使用 TLS 或 `HOST=localhost` 加密 SMTP 服务器通信时才支持身份验证。TLS 加密可以通过以下方式进行:
|
|
||||||
|
|
||||||
- 通过端口 587 的 STARTTLS(也称为 Opportunistic TLS)。初始连接是明文的,但如果服务器支持,则可以升级为 TLS。
|
|
||||||
- 通过默认端口 465 的 SMTPS 连接。连接到服务器从一开始就使用 TLS。
|
|
||||||
- 使用 `PROTOCOL=smtps` 进行强制的 SMTPS 连接。(这两种方式都被称为 Implicit TLS)
|
|
||||||
这是由于 Go 内部库对 STRIPTLS 攻击的保护机制。
|
|
||||||
|
|
||||||
请注意,自2018年起,[RFC8314](https://tools.ietf.org/html/rfc8314#section-3) 推荐使用 Implicit TLS。
|
|
||||||
|
|
||||||
### Gmail
|
|
||||||
|
|
||||||
以下配置应该适用于 Gmail 的 SMTP 服务器:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[mailer]
|
|
||||||
ENABLED = true
|
|
||||||
HOST = smtp.gmail.com:465 ; 对于 Gitea >= 1.18.0,删除此行
|
|
||||||
SMTP_ADDR = smtp.gmail.com
|
|
||||||
SMTP_PORT = 465
|
|
||||||
FROM = example.user@gmail.com
|
|
||||||
USER = example.user
|
|
||||||
PASSWD = `***`
|
|
||||||
PROTOCOL = smtps
|
|
||||||
```
|
|
||||||
|
|
||||||
请注意,您需要创建并使用一个 [应用密码](https://support.google.com/accounts/answer/185833?hl=en) 并在您的 Google 帐户上启用 2FA。您将无法直接使用您的 Google 帐户密码。
|
|
|
@ -1,59 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-04-08T11:34:00+02:00"
|
|
||||||
title: "Environment variables"
|
|
||||||
slug: "environment-variables"
|
|
||||||
sidebar_position: 10
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/environment-variables
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Environment variables"
|
|
||||||
sidebar_position: 10
|
|
||||||
identifier: "environment-variables"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Environment variables
|
|
||||||
|
|
||||||
This is an inventory of Gitea environment variables. They change Gitea behaviour.
|
|
||||||
|
|
||||||
Initialize them before Gitea command to be effective, for example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
GITEA_CUSTOM=/home/gitea/custom ./gitea web
|
|
||||||
```
|
|
||||||
|
|
||||||
## From Go language
|
|
||||||
|
|
||||||
As Gitea is written in Go, it uses some variables that influence the behaviour of Go's runtime, such as:
|
|
||||||
|
|
||||||
- `GOMEMLIMIT`
|
|
||||||
- `GOGC`
|
|
||||||
- `GOMAXPROCS`
|
|
||||||
- `GODEBUG`
|
|
||||||
|
|
||||||
For documentation about each of the variables available, refer to the
|
|
||||||
[official Go documentation on runtime environment variables](https://pkg.go.dev/runtime#hdr-Environment_Variables).
|
|
||||||
|
|
||||||
## Gitea files
|
|
||||||
|
|
||||||
- `GITEA_WORK_DIR`: Absolute path of working directory.
|
|
||||||
- `GITEA_CUSTOM`: Gitea uses `WorkPath`/custom folder by default. Use this variable to change _custom_ directory.
|
|
||||||
|
|
||||||
## Operating system specifics
|
|
||||||
|
|
||||||
- `USER`: System user that Gitea will run as. Used for some repository access strings.
|
|
||||||
- `USERNAME`: if no `USER` found, Gitea will use `USERNAME`
|
|
||||||
- `HOME`: User home directory path. The `USERPROFILE` environment variable is used in Windows.
|
|
||||||
|
|
||||||
### Only on Windows
|
|
||||||
|
|
||||||
- `USERPROFILE`: User home directory path. If empty, uses `HOMEDRIVE` + `HOMEPATH`
|
|
||||||
- `HOMEDRIVE`: Main drive path used to access the home directory (C:)
|
|
||||||
- `HOMEPATH`: Home relative path in the given home drive path
|
|
||||||
|
|
||||||
## Miscellaneous
|
|
||||||
|
|
||||||
- `SKIP_MINWINSVC`: If set to 1, do not run as a service on Windows.
|
|
|
@ -1,57 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-04-08T11:34:00+02:00"
|
|
||||||
title: "环境变量清单"
|
|
||||||
slug: "environment-variables"
|
|
||||||
sidebar_position: 10
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/environment-variables
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "环境变量清单"
|
|
||||||
sidebar_position: 10
|
|
||||||
identifier: "environment-variables"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 环境变量清单
|
|
||||||
|
|
||||||
这里是用来控制 Gitea 行为表现的的环境变量清单,您需要在执行如下 Gitea 启动命令前设置它们来确保配置生效:
|
|
||||||
|
|
||||||
```
|
|
||||||
GITEA_CUSTOM=/home/gitea/custom ./gitea web
|
|
||||||
```
|
|
||||||
|
|
||||||
## Go 的配置
|
|
||||||
|
|
||||||
因为 Gitea 使用 Go 语言编写,因此它使用了一些相关的 Go 的配置参数:
|
|
||||||
|
|
||||||
* `GOOS`
|
|
||||||
* `GOARCH`
|
|
||||||
* [`GOPATH`](https://go.dev/cmd/go/#hdr-GOPATH_environment_variable)
|
|
||||||
|
|
||||||
您可以在[官方文档](https://go.dev/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。
|
|
||||||
|
|
||||||
## Gitea 的文件目录
|
|
||||||
|
|
||||||
* `GITEA_WORK_DIR`:工作目录的绝对路径
|
|
||||||
* `GITEA_CUSTOM`:默认情况下 Gitea 使用默认目录 `GITEA_WORK_DIR`/custom,您可以使用这个参数来配置 *custom* 目录
|
|
||||||
* `GOGS_WORK_DIR`: 已废弃,请使用 `GITEA_WORK_DIR` 替代
|
|
||||||
* `GOGS_CUSTOM`: 已废弃,请使用 `GITEA_CUSTOM` 替代
|
|
||||||
|
|
||||||
## 操作系统配置
|
|
||||||
|
|
||||||
* `USER`:Gitea 运行时使用的系统用户,它将作为一些 repository 的访问地址的一部分
|
|
||||||
* `USERNAME`: 如果没有配置 `USER`, Gitea 将使用 `USERNAME`
|
|
||||||
* `HOME`: 用户的 home 目录,在 Windows 中会使用 `USERPROFILE` 环境变量
|
|
||||||
|
|
||||||
### 仅限于 Windows 的配置
|
|
||||||
|
|
||||||
* `USERPROFILE`: 用户的主目录,如果未配置则会使用 `HOMEDRIVE` + `HOMEPATH`
|
|
||||||
* `HOMEDRIVE`: 用于访问 home 目录的主驱动器路径(C盘)
|
|
||||||
* `HOMEPATH`:在指定主驱动器下的 home 目录相对路径
|
|
||||||
|
|
||||||
## Miscellaneous
|
|
||||||
|
|
||||||
* `SKIP_MINWINSVC`:如果设置为 1,在 Windows 上不会以 service 的形式运行。
|
|
|
@ -1,194 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-11-23:00:00+02:00"
|
|
||||||
title: "External renderers"
|
|
||||||
slug: "external-renderers"
|
|
||||||
sidebar_position: 60
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/external-renderers
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "External renderers"
|
|
||||||
sidebar_position: 60
|
|
||||||
identifier: "external-renderers"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Custom files rendering configuration
|
|
||||||
|
|
||||||
Gitea supports custom file renderings (i.e., Jupyter notebooks, asciidoc, etc.) through external binaries,
|
|
||||||
it is just a matter of:
|
|
||||||
|
|
||||||
- installing external binaries
|
|
||||||
- add some configuration to your `app.ini` file
|
|
||||||
- restart your Gitea instance
|
|
||||||
|
|
||||||
This supports rendering of whole files. If you want to render code blocks in markdown you would need to do something with javascript. See some examples on the [Customizing Gitea](administration/customizing-gitea.md) page.
|
|
||||||
|
|
||||||
## Installing external binaries
|
|
||||||
|
|
||||||
In order to get file rendering through external binaries, their associated packages must be installed.
|
|
||||||
If you're using a Docker image, your `Dockerfile` should contain something along this lines:
|
|
||||||
|
|
||||||
```docker
|
|
||||||
FROM gitea/gitea:@version@
|
|
||||||
[...]
|
|
||||||
|
|
||||||
COPY custom/app.ini /data/gitea/conf/app.ini
|
|
||||||
[...]
|
|
||||||
|
|
||||||
RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev py-pip python3-dev py3-pip py3-pyzmq
|
|
||||||
# install any other package you need for your external renderers
|
|
||||||
|
|
||||||
RUN pip3 install --upgrade pip
|
|
||||||
RUN pip3 install -U setuptools
|
|
||||||
RUN pip3 install jupyter docutils
|
|
||||||
# add above any other python package you may need to install
|
|
||||||
```
|
|
||||||
|
|
||||||
## `app.ini` file configuration
|
|
||||||
|
|
||||||
add one `[markup.XXXXX]` section per external renderer on your custom `app.ini`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.asciidoc]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .adoc,.asciidoc
|
|
||||||
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
|
|
||||||
; Input is not a standard input but a file
|
|
||||||
IS_INPUT_FILE = false
|
|
||||||
|
|
||||||
[markup.jupyter]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .ipynb
|
|
||||||
RENDER_COMMAND = "jupyter nbconvert --stdin --stdout --to html --template basic"
|
|
||||||
IS_INPUT_FILE = false
|
|
||||||
|
|
||||||
[markup.restructuredtext]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .rst
|
|
||||||
RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst"
|
|
||||||
IS_INPUT_FILE = false
|
|
||||||
```
|
|
||||||
|
|
||||||
If your external markup relies on additional classes and attributes on the generated HTML elements, you might need to enable custom sanitizer policies. Gitea uses the [`bluemonday`](https://godoc.org/github.com/microcosm-cc/bluemonday) package as our HTML sanitizer. The example below could be used to support server-side [KaTeX](https://katex.org/) rendering output from [`pandoc`](https://pandoc.org/).
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.sanitizer.TeX]
|
|
||||||
; Pandoc renders TeX segments as <span>s with the "math" class, optionally
|
|
||||||
; with "inline" or "display" classes depending on context.
|
|
||||||
; - note this is different from the built-in math support in our markdown parser which uses <code>
|
|
||||||
ELEMENT = span
|
|
||||||
ALLOW_ATTR = class
|
|
||||||
REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+
|
|
||||||
|
|
||||||
[markup.markdown]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .md,.markdown
|
|
||||||
RENDER_COMMAND = pandoc -f markdown -t html --katex
|
|
||||||
```
|
|
||||||
|
|
||||||
You must define `ELEMENT` and `ALLOW_ATTR` in each section.
|
|
||||||
|
|
||||||
To define multiple entries, add a unique alphanumeric suffix (e.g., `[markup.sanitizer.1]` and `[markup.sanitizer.something]`).
|
|
||||||
|
|
||||||
To apply a sanitisation rules only for a specify external renderer they must use the renderer name, e.g. `[markup.sanitizer.asciidoc.rule-1]`, `[markup.sanitizer.<renderer>.rule-1]`.
|
|
||||||
|
|
||||||
**Note**: If the rule is defined above the renderer ini section or the name does not match a renderer it is applied to every renderer.
|
|
||||||
|
|
||||||
Once your configuration changes have been made, restart Gitea to have changes take effect.
|
|
||||||
|
|
||||||
**Note**: Prior to Gitea 1.12 there was a single `markup.sanitiser` section with keys that were redefined for multiple rules, however,
|
|
||||||
there were significant problems with this method of configuration necessitating configuration through multiple sections.
|
|
||||||
|
|
||||||
### Example: HTML
|
|
||||||
|
|
||||||
Render HTML files directly:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.html]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .html,.htm
|
|
||||||
RENDER_COMMAND = cat
|
|
||||||
; Input is not a standard input but a file
|
|
||||||
IS_INPUT_FILE = true
|
|
||||||
|
|
||||||
[markup.sanitizer.html.1]
|
|
||||||
ELEMENT = div
|
|
||||||
ALLOW_ATTR = class
|
|
||||||
|
|
||||||
[markup.sanitizer.html.2]
|
|
||||||
ELEMENT = a
|
|
||||||
ALLOW_ATTR = class
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example: Office DOCX
|
|
||||||
|
|
||||||
Display Office DOCX files with [`pandoc`](https://pandoc.org/):
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.docx]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .docx
|
|
||||||
RENDER_COMMAND = "pandoc --from docx --to html --self-contained --template /path/to/basic.html"
|
|
||||||
|
|
||||||
[markup.sanitizer.docx.img]
|
|
||||||
ALLOW_DATA_URI_IMAGES = true
|
|
||||||
```
|
|
||||||
|
|
||||||
The template file has the following content:
|
|
||||||
|
|
||||||
```
|
|
||||||
$body$
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example: Jupyter Notebook
|
|
||||||
|
|
||||||
Display Jupyter Notebook files with [`nbconvert`](https://github.com/jupyter/nbconvert):
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.jupyter]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .ipynb
|
|
||||||
RENDER_COMMAND = "jupyter-nbconvert --stdin --stdout --to html --template basic"
|
|
||||||
|
|
||||||
[markup.sanitizer.jupyter.img]
|
|
||||||
ALLOW_DATA_URI_IMAGES = true
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customizing CSS
|
|
||||||
|
|
||||||
The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `<div>` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX` is `markdown`). Otherwise you can use these classes to specifically target the contents of your rendered HTML.
|
|
||||||
|
|
||||||
And so you could write some CSS:
|
|
||||||
|
|
||||||
```css
|
|
||||||
.markup.XXXXX html {
|
|
||||||
font-size: 100%;
|
|
||||||
overflow-y: scroll;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markup.XXXXX body {
|
|
||||||
color: #444;
|
|
||||||
font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.7;
|
|
||||||
padding: 1em;
|
|
||||||
margin: auto;
|
|
||||||
max-width: 42em;
|
|
||||||
background: #fefefe;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markup.XXXXX p {
|
|
||||||
color: orangered;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Add your stylesheet to your custom directory e.g `custom/public/assets/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
|
|
||||||
```
|
|
|
@ -1,203 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "外部渲染器"
|
|
||||||
slug: "external-renderers"
|
|
||||||
sidebar_position: 60
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/external-renderers
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "外部渲染器"
|
|
||||||
sidebar_position: 60
|
|
||||||
identifier: "external-renderers"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 自定义文件渲染配置
|
|
||||||
|
|
||||||
Gitea 通过外部二进制文件支持自定义文件渲染(例如 Jupyter notebooks、asciidoc 等),只需要进行以下步骤:
|
|
||||||
|
|
||||||
- 安装外部二进制文件
|
|
||||||
- 在您的 `app.ini` 文件中添加一些配置
|
|
||||||
- 重新启动 Gitea 实例
|
|
||||||
|
|
||||||
此功能支持整个文件的渲染。如果您想要在 Markdown 中渲染代码块,您需要使用 JavaScript 进行一些操作。请参阅 [自定义 Gitea 配置](administration/customizing-gitea.md) 页面上的一些示例。
|
|
||||||
|
|
||||||
## 安装外部二进制文件
|
|
||||||
|
|
||||||
为了通过外部二进制文件进行文件渲染,必须安装它们的关联软件包。
|
|
||||||
如果您正在使用 Docker 镜像,则您的 `Dockerfile` 应该包含以下内容:
|
|
||||||
|
|
||||||
```docker
|
|
||||||
FROM gitea/gitea:@version@
|
|
||||||
[...]
|
|
||||||
|
|
||||||
COPY custom/app.ini /data/gitea/conf/app.ini
|
|
||||||
[...]
|
|
||||||
|
|
||||||
RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev py-pip python3-dev py3-pip py3-pyzmq
|
|
||||||
# 安装其他您需要的外部渲染器的软件包
|
|
||||||
|
|
||||||
RUN pip3 install --upgrade pip
|
|
||||||
RUN pip3 install -U setuptools
|
|
||||||
RUN pip3 install jupyter docutils
|
|
||||||
# 在上面添加您需要安装的任何其他 Python 软件包
|
|
||||||
```
|
|
||||||
|
|
||||||
## `app.ini` 文件配置
|
|
||||||
|
|
||||||
在您的自定义 `app.ini` 文件中为每个外部渲染器添加一个 `[markup.XXXXX]` 部分:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.asciidoc]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .adoc,.asciidoc
|
|
||||||
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
|
|
||||||
; 输入不是标准输入而是文件
|
|
||||||
IS_INPUT_FILE = false
|
|
||||||
|
|
||||||
[markup.jupyter]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .ipynb
|
|
||||||
RENDER_COMMAND = "jupyter nbconvert --stdin --stdout --to html --template basic"
|
|
||||||
IS_INPUT_FILE = false
|
|
||||||
|
|
||||||
[markup.restructuredtext]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .rst
|
|
||||||
RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst"
|
|
||||||
IS_INPUT_FILE = false
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您的外部标记语言依赖于在生成的 HTML 元素上的额外类和属性,您可能需要启用自定义的清理策略。Gitea 使用 [`bluemonday`](https://godoc.org/github.com/microcosm-cc/bluemonday) 包作为我们的 HTML 清理器。下面的示例可以用于支持从 [`pandoc`](https://pandoc.org/) 输出的服务器端 [KaTeX](https://katex.org/) 渲染结果。
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.sanitizer.TeX]
|
|
||||||
; Pandoc 渲染 TeX 段落为带有 "math" 类的 <span> 元素,根据上下文可能还带有 "inline" 或 "display" 类。
|
|
||||||
; - 请注意,这与我们的 Markdown 解析器中内置的数学支持不同,后者使用 <code> 元素。
|
|
||||||
ELEMENT = span
|
|
||||||
ALLOW_ATTR = class
|
|
||||||
REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+
|
|
||||||
|
|
||||||
[markup.markdown]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .md,.markdown
|
|
||||||
RENDER_COMMAND = pandoc -f markdown -t html --katex
|
|
||||||
```
|
|
||||||
|
|
||||||
您必须在每个部分中定义 `ELEMENT` 和 `ALLOW_ATTR`。
|
|
||||||
|
|
||||||
要定义多个条目,请添加唯一的字母数字后缀(例如,`[markup.sanitizer.1]` 和 `[markup.sanitizer.something]`)。
|
|
||||||
|
|
||||||
要仅为特定的外部渲染器应用清理规则,它们必须使用渲染器名称,例如 `[markup.sanitizer.asciidoc.rule-1]`、`[markup.sanitizer.<renderer>.rule-1]`。
|
|
||||||
|
|
||||||
**注意**:如果规则在渲染器 ini 部分之前定义,或者名称与渲染器不匹配,它将应用于所有渲染器。
|
|
||||||
|
|
||||||
完成配置更改后,请重新启动 Gitea 以使更改生效。
|
|
||||||
|
|
||||||
**注意**:在 Gitea 1.12 之前,存在一个名为 `markup.sanitiser` 的单个部分,其中的键被重新定义为多个规则,但是,这种配置方法存在重大问题,需要通过多个部分进行配置。
|
|
||||||
|
|
||||||
### 示例:HTML
|
|
||||||
|
|
||||||
直接渲染 HTML 文件:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.html]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .html,.htm
|
|
||||||
RENDER_COMMAND = cat
|
|
||||||
; 输入不是标准输入,而是文件
|
|
||||||
IS_INPUT_FILE = true
|
|
||||||
|
|
||||||
[markup.sanitizer.html.1]
|
|
||||||
ELEMENT = div
|
|
||||||
ALLOW_ATTR = class
|
|
||||||
|
|
||||||
[markup.sanitizer.html.2]
|
|
||||||
ELEMENT = a
|
|
||||||
ALLOW_ATTR = class
|
|
||||||
```
|
|
||||||
|
|
||||||
请注意:此示例中的配置将允许渲染 HTML 文件,并使用 `cat` 命令将文件内容输出为 HTML。此外,配置中的两个清理规则将允许 `<div>` 和 `<a>` 元素使用 `class` 属性。
|
|
||||||
|
|
||||||
在进行配置更改后,请重新启动 Gitea 以使更改生效。
|
|
||||||
|
|
||||||
### 示例:Office DOCX
|
|
||||||
|
|
||||||
使用 [`pandoc`](https://pandoc.org/) 显示 Office DOCX 文件:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.docx]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .docx
|
|
||||||
RENDER_COMMAND = "pandoc --from docx --to html --self-contained --template /path/to/basic.html"
|
|
||||||
|
|
||||||
[markup.sanitizer.docx.img]
|
|
||||||
ALLOW_DATA_URI_IMAGES = true
|
|
||||||
```
|
|
||||||
|
|
||||||
在此示例中,配置将允许显示 Office DOCX 文件,并使用 `pandoc` 命令将文件转换为 HTML 格式。同时,清理规则中的 `ALLOW_DATA_URI_IMAGES` 设置为 `true`,允许使用 Data URI 格式的图片。
|
|
||||||
|
|
||||||
模板文件的内容如下:
|
|
||||||
|
|
||||||
```
|
|
||||||
$body$
|
|
||||||
```
|
|
||||||
|
|
||||||
### 示例:Jupyter Notebook
|
|
||||||
|
|
||||||
使用 [`nbconvert`](https://github.com/jupyter/nbconvert) 显示 Jupyter Notebook 文件:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[markup.jupyter]
|
|
||||||
ENABLED = true
|
|
||||||
FILE_EXTENSIONS = .ipynb
|
|
||||||
RENDER_COMMAND = "jupyter-nbconvert --stdin --stdout --to html --template basic"
|
|
||||||
|
|
||||||
[markup.sanitizer.jupyter.img]
|
|
||||||
ALLOW_DATA_URI_IMAGES = true
|
|
||||||
```
|
|
||||||
|
|
||||||
在此示例中,配置将允许显示 Jupyter Notebook 文件,并使用 `nbconvert` 命令将文件转换为 HTML 格式。同样,清理规则中的 `ALLOW_DATA_URI_IMAGES` 设置为 `true`,允许使用 Data URI 格式的图片。
|
|
||||||
|
|
||||||
在进行配置更改后,请重新启动 Gitea 以使更改生效。
|
|
||||||
|
|
||||||
## 自定义 CSS
|
|
||||||
|
|
||||||
在 `.ini` 文件中,可以使用 `[markup.XXXXX]` 的格式指定外部渲染器,并且由外部渲染器生成的 HTML 将被包装在一个带有 `markup` 和 `XXXXX` 类的 `<div>` 中。`markup` 类提供了预定义的样式(如果 `XXXXX` 是 `markdown`,则使用 `markdown` 类)。否则,您可以使用这些类来针对渲染的 HTML 内容进行定制样式。
|
|
||||||
|
|
||||||
因此,您可以编写一些 CSS 样式:
|
|
||||||
|
|
||||||
```css
|
|
||||||
.markup.XXXXX html {
|
|
||||||
font-size: 100%;
|
|
||||||
overflow-y: scroll;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-ms-text-size-adjust: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markup.XXXXX body {
|
|
||||||
color: #444;
|
|
||||||
font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.7;
|
|
||||||
padding: 1em;
|
|
||||||
margin: auto;
|
|
||||||
max-width: 42em;
|
|
||||||
background: #fefefe;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markup.XXXXX p {
|
|
||||||
color: orangered;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
将您的样式表添加到自定义目录中,例如 `custom/public/assets/css/my-style-XXXXX.css`,并使用自定义的头文件 `custom/templates/custom/header.tmpl` 进行导入:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link rel="stylesheet" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
|
|
||||||
```
|
|
||||||
|
|
||||||
通过以上步骤,您可以将自定义的 CSS 样式应用到特定的外部渲染器,使其具有所需的样式效果。
|
|
|
@ -1,127 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-05-11T11:00:00+02:00"
|
|
||||||
title: "Fail2ban Setup "
|
|
||||||
slug: "fail2ban-setup"
|
|
||||||
sidebar_position: 16
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/fail2ban-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Fail2ban setup"
|
|
||||||
sidebar_position: 16
|
|
||||||
identifier: "fail2ban-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Fail2ban setup to block users after failed login attempts
|
|
||||||
|
|
||||||
**Remember that fail2ban is powerful and can cause lots of issues if you do it incorrectly, so make
|
|
||||||
sure to test this before relying on it so you don't lock yourself out.**
|
|
||||||
|
|
||||||
Gitea returns an HTTP 200 for bad logins in the web logs, but if you have logging options on in
|
|
||||||
`app.ini`, then you should be able to go off of `log/gitea.log`, which gives you something like this
|
|
||||||
on a bad authentication from the web or CLI using SSH or HTTP respectively:
|
|
||||||
|
|
||||||
```log
|
|
||||||
2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:05:09 modules/ssh/ssh.go:143:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:05:09 modules/ssh/ssh.go:155:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:05:09 modules/ssh/ssh.go:198:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:05:09 modules/ssh/ssh.go:213:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:05:09 modules/ssh/ssh.go:227:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:05:09 modules/ssh/ssh.go:249:sshConnectionFailed() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
(From 1.15 this new message will available and doesn't have any of the false positive results that above messages from publicKeyHandler do. This will only be logged if the user has completely failed authentication.)
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:08:44 ...s/context/context.go:204:HandleText() [E] invalid credentials from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
Add our filter in `/etc/fail2ban/filter.d/gitea.conf`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
# gitea.conf
|
|
||||||
[Definition]
|
|
||||||
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
|
|
||||||
ignoreregex =
|
|
||||||
```
|
|
||||||
|
|
||||||
Add our jail in `/etc/fail2ban/jail.d/gitea.conf`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[gitea]
|
|
||||||
enabled = true
|
|
||||||
filter = gitea
|
|
||||||
logpath = /var/lib/gitea/log/gitea.log
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using Docker, you'll also need to add an additional jail to handle the **FORWARD**
|
|
||||||
chain in **iptables**. Configure it in `/etc/fail2ban/jail.d/gitea-docker.conf`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[gitea-docker]
|
|
||||||
enabled = true
|
|
||||||
filter = gitea
|
|
||||||
logpath = /var/lib/gitea/log/gitea.log
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports[chain="FORWARD"]
|
|
||||||
```
|
|
||||||
|
|
||||||
Then simply run `service fail2ban restart` to apply your changes. You can check to see if
|
|
||||||
fail2ban has accepted your configuration using `service fail2ban status`.
|
|
||||||
|
|
||||||
Make sure and read up on fail2ban and configure it to your needs, this bans someone
|
|
||||||
for **15 minutes** (from all ports) when they fail authentication 10 times in an hour.
|
|
||||||
|
|
||||||
If you run Gitea behind a reverse proxy with Nginx (for example with Docker), you need to add
|
|
||||||
this to your Nginx configuration so that IPs don't show up as 127.0.0.1:
|
|
||||||
|
|
||||||
```
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
```
|
|
||||||
|
|
||||||
The security options in `app.ini` need to be adjusted to allow the interpretation of the headers
|
|
||||||
as well as the list of IP addresses and networks that describe trusted proxy servers
|
|
||||||
(See the [configuration cheat sheet](administration/config-cheat-sheet.md#security-security) for more information).
|
|
||||||
|
|
||||||
```
|
|
||||||
REVERSE_PROXY_LIMIT = 1
|
|
||||||
REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.1/8 ; 172.17.0.0/16 for the docker default network
|
|
||||||
```
|
|
|
@ -1,94 +0,0 @@
|
||||||
---
|
|
||||||
date: "2022-08-01T00:00:00+00:00"
|
|
||||||
title: "设置 Fail2ban"
|
|
||||||
slug: "fail2ban-setup"
|
|
||||||
sidebar_position: 16
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/fail2ban-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "设置 Fail2ban"
|
|
||||||
sidebar_position: 16
|
|
||||||
identifier: "fail2ban-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 使用 Fail2ban 阻止攻击者的暴力登录
|
|
||||||
|
|
||||||
**Fail2ban 检查客户端登录日志,将多次登录失败的客户端识别为攻击者并在一段时间内阻止其访问服务。如果你的实例是公开的,这一点尤其重要。请管理员仔细设置 fail2ban,错误的配置将导致防火墙阻止你访问自己的服务器。**
|
|
||||||
|
|
||||||
Gitea 会在日志文件 `log/gitea.log` 中记录登录失败的 CLI、SSH 或 HTTP 客户端 IP 地址,而你需要将 Gitea 的日志输出模式从默认的 `console` 更改为 `file`。这表示将日志输出到文件,使得 fail2ban 可以定期扫描日志内容。
|
|
||||||
|
|
||||||
当用户的身份验证失败时,日志中会记录此类信息:
|
|
||||||
|
|
||||||
```log
|
|
||||||
2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
```log
|
|
||||||
2020/10/15 16:08:44 [E] invalid credentials from xxx.xxx.xxx.xxx
|
|
||||||
```
|
|
||||||
|
|
||||||
## 设置 Fail2ban
|
|
||||||
|
|
||||||
添加日志过滤器规则到配置文件 `/etc/fail2ban/filter.d/gitea.conf`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[Definition]
|
|
||||||
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
|
|
||||||
ignoreregex =
|
|
||||||
```
|
|
||||||
|
|
||||||
添加监狱规则到配置文件 `/etc/fail2ban/jail.d/gitea.conf`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[gitea]
|
|
||||||
enabled = true
|
|
||||||
filter = gitea
|
|
||||||
logpath = /var/lib/gitea/log/gitea.log
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports
|
|
||||||
```
|
|
||||||
|
|
||||||
如果你的 Gitea 实例运行在 Docker 容器中,并且直接将容器端口暴露到外部网络,
|
|
||||||
你还需要添加 `chain="FORWARD"` 到监狱规则配置文件 `/etc/fail2ban/jail.d/gitea-docker.conf`
|
|
||||||
以适应 Docker 的网络转发规则。但如果你在容器的宿主机上使用 Nginx 反向代理连接到 Gitea 则无需这样配置。
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[gitea-docker]
|
|
||||||
enabled = true
|
|
||||||
filter = gitea
|
|
||||||
logpath = /var/lib/gitea/log/gitea.log
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports[chain="FORWARD"]
|
|
||||||
```
|
|
||||||
|
|
||||||
最后,运行 `systemctl restart fail2ban` 即可应用更改。现在,你可以使用 `systemctl status fail2ban` 检查 fail2ban 运行状态。
|
|
||||||
|
|
||||||
上述规则规定客户端在 1 小时内,如果登录失败的次数达到 10 次,则通过 iptables 锁定该客户端 IP 地址 15 分钟。
|
|
||||||
|
|
||||||
## 设置反向代理
|
|
||||||
|
|
||||||
如果你使用 Nginx 反向代理到 Gitea 实例,你还需要设置 Nginx 的 HTTP 头部值 `X-Real-IP` 将真实的客户端 IP 地址传递给 Gitea。否则 Gitea 程序会将客户端地址错误解析为反向代理服务器的地址,例如回环地址 `127.0.0.1`。
|
|
||||||
|
|
||||||
```
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
```
|
|
||||||
|
|
||||||
额外注意,在 Gitea 的配置文件 `app.ini` 中存在下列默认值:
|
|
||||||
|
|
||||||
```
|
|
||||||
REVERSE_PROXY_LIMIT = 1
|
|
||||||
REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128
|
|
||||||
```
|
|
||||||
|
|
||||||
`REVERSE_PROXY_LIMIT` 限制反向代理服务器的层数,设置为 `0` 表示不使用这些标头。
|
|
||||||
`REVERSE_PROXY_TRUSTED_PROXIES` 表示受信任的反向代理服务器网络地址,
|
|
||||||
经过该网络地址转发来的流量会经过解析 `X-Real-IP` 头部得到真实客户端地址。
|
|
||||||
(参考 [configuration cheat sheet](administration/config-cheat-sheet.md#security-security))
|
|
|
@ -1,32 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-10-06T08:00:00+05:00"
|
|
||||||
title: "Git LFS setup"
|
|
||||||
slug: "git-lfs-setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/git-lfs-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Git LFS setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
identifier: "git-lfs-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Git Large File Storage setup
|
|
||||||
|
|
||||||
To use Gitea's built-in LFS support, you must update the `app.ini` file:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
; Enables git-lfs support. true or false, default is false.
|
|
||||||
LFS_START_SERVER = true
|
|
||||||
|
|
||||||
[lfs]
|
|
||||||
; Where your lfs files reside, default is data/lfs.
|
|
||||||
PATH = /home/gitea/data/lfs
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note**: LFS server support needs at least Git v2.1.2 installed on the server
|
|
|
@ -1,32 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "Git LFS 设置"
|
|
||||||
slug: "git-lfs-setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/git-lfs-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Git LFS 设置"
|
|
||||||
sidebar_position: 12
|
|
||||||
identifier: "git-lfs-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 配置 Git 大文件存储(Large File Storage,LFS)
|
|
||||||
|
|
||||||
要使用 Gitea 内置的 LFS 支持,您需要更新 `app.ini` 文件:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
; 启用 git-lfs 支持。true 或 false,默认为 false。
|
|
||||||
LFS_START_SERVER = true
|
|
||||||
|
|
||||||
[lfs]
|
|
||||||
; 存放 LFS 文件的路径,默认为 data/lfs。
|
|
||||||
PATH = /home/gitea/data/lfs
|
|
||||||
```
|
|
||||||
|
|
||||||
**注意**:LFS 服务器支持需要服务器上安装 Git v2.1.2 以上版本。
|
|
|
@ -1,100 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-06-02T11:00:00+02:00"
|
|
||||||
title: "HTTPS setup"
|
|
||||||
slug: "https-setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/https-setup
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "HTTPS setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
identifier: "https-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# HTTPS setup to encrypt connections to Gitea
|
|
||||||
|
|
||||||
## Using the built-in server
|
|
||||||
|
|
||||||
Before you enable HTTPS, make sure that you have valid SSL/TLS certificates.
|
|
||||||
You could use self-generated certificates for evaluation and testing. Please run `gitea cert --host [HOST]` to generate a self signed certificate.
|
|
||||||
|
|
||||||
If you are using Apache or nginx on the server, it's recommended to check the [reverse proxy guide](administration/reverse-proxies.md).
|
|
||||||
|
|
||||||
To use Gitea's built-in HTTPS support, you must change your `app.ini` file:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
PROTOCOL = https
|
|
||||||
ROOT_URL = https://git.example.com:3000/
|
|
||||||
HTTP_PORT = 3000
|
|
||||||
CERT_FILE = cert.pem
|
|
||||||
KEY_FILE = key.pem
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that if your certificate is signed by a third party certificate authority (i.e. not self-signed), then cert.pem should contain the certificate chain. The server certificate must be the first entry in cert.pem, followed by the intermediaries in order (if any). The root certificate does not have to be included because the connecting client must already have it in order to estalbish the trust relationship.
|
|
||||||
To learn more about the config values, please checkout the [Config Cheat Sheet](administration/config-cheat-sheet.md#server-server).
|
|
||||||
|
|
||||||
For the `CERT_FILE` or `KEY_FILE` field, the file path is relative to the `GITEA_CUSTOM` environment variable when it is a relative path. It can be an absolute path as well.
|
|
||||||
|
|
||||||
### Setting up HTTP redirection
|
|
||||||
|
|
||||||
The Gitea server is only able to listen to one port; to redirect HTTP requests to the HTTPS port, you will need to enable the HTTP redirection service:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
REDIRECT_OTHER_PORT = true
|
|
||||||
; Port the redirection service should listen on
|
|
||||||
PORT_TO_REDIRECT = 3080
|
|
||||||
```
|
|
||||||
|
|
||||||
If you are using Docker, make sure that this port is configured in your `docker-compose.yml` file.
|
|
||||||
|
|
||||||
## Using ACME (Default: Let's Encrypt)
|
|
||||||
|
|
||||||
[ACME](https://tools.ietf.org/html/rfc8555) is a Certificate Authority standard protocol that allows you to automatically request and renew SSL/TLS certificates. [Let's Encrypt](https://letsencrypt.org/) is a free publicly trusted Certificate Authority server using this standard. Only `HTTP-01` and `TLS-ALPN-01` challenges are implemented. In order for ACME challenges to pass and verify your domain ownership, external traffic to the gitea domain on port `80` (`HTTP-01`) or port `443` (`TLS-ALPN-01`) has to be served by the gitea instance. Setting up [HTTP redirection](#setting-up-http-redirection) and port-forwards might be needed for external traffic to route correctly. Normal traffic to port `80` will otherwise be automatically redirected to HTTPS. **You must consent** to the ACME provider's terms of service (default Let's Encrypt's [terms of service](https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf)).
|
|
||||||
|
|
||||||
Minimum setup using the default Let's Encrypt:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
PROTOCOL=https
|
|
||||||
DOMAIN=git.example.com
|
|
||||||
ENABLE_ACME=true
|
|
||||||
ACME_ACCEPTTOS=true
|
|
||||||
ACME_DIRECTORY=https
|
|
||||||
;; Email can be omitted here and provided manually at first run, after which it is cached
|
|
||||||
ACME_EMAIL=email@example.com
|
|
||||||
```
|
|
||||||
|
|
||||||
Minimum setup using a [smallstep CA](https://github.com/smallstep/certificates), refer to [their tutorial](https://smallstep.com/docs/tutorials/acme-challenge) for more information.
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
PROTOCOL=https
|
|
||||||
DOMAIN=git.example.com
|
|
||||||
ENABLE_ACME=true
|
|
||||||
ACME_ACCEPTTOS=true
|
|
||||||
ACME_URL=https://ca.example.com/acme/acme/directory
|
|
||||||
;; Can be omitted if using the system's trust is preferred
|
|
||||||
;ACME_CA_ROOT=/path/to/root_ca.crt
|
|
||||||
ACME_DIRECTORY=https
|
|
||||||
ACME_EMAIL=email@example.com
|
|
||||||
```
|
|
||||||
|
|
||||||
To learn more about the config values, please checkout the [Config Cheat Sheet](administration/config-cheat-sheet.md#server-server).
|
|
||||||
|
|
||||||
## Using a reverse proxy
|
|
||||||
|
|
||||||
Setup up your reverse proxy as shown in the [reverse proxy guide](administration/reverse-proxies.md).
|
|
||||||
|
|
||||||
After that, enable HTTPS by following one of these guides:
|
|
||||||
|
|
||||||
- [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html)
|
|
||||||
- [apache2/httpd](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html)
|
|
||||||
- [caddy](https://caddyserver.com/docs/tls)
|
|
||||||
|
|
||||||
Note: Enabling HTTPS only at the proxy level is referred as [TLS Termination Proxy](https://en.wikipedia.org/wiki/TLS_termination_proxy). The proxy server accepts incoming TLS connections, decrypts the contents, and passes the now unencrypted contents to Gitea. This is normally fine as long as both the proxy and Gitea instances are either on the same machine, or on different machines within private network (with the proxy is exposed to outside network). If your Gitea instance is separated from your proxy over a public network, or if you want full end-to-end encryption, you can also [enable HTTPS support directly in Gitea using built-in server](#using-the-built-in-server) and forward the connections over HTTPS instead.
|
|
|
@ -1,97 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-04-09T11:00:00+02:00"
|
|
||||||
title: "HTTPS配置"
|
|
||||||
slug: "https-setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "HTTPS setup"
|
|
||||||
sidebar_position: 12
|
|
||||||
identifier: "https-setup"
|
|
||||||
---
|
|
||||||
|
|
||||||
# HTTPS setup to encrypt connections to Gitea
|
|
||||||
|
|
||||||
## 使用内置服务器
|
|
||||||
|
|
||||||
在启用HTTPS之前,确保您拥有有效的SSL/TLS证书。
|
|
||||||
建议在测试和评估情况下使用自签名证书,请运行 `gitea cert --host [HOST]` 以生成自签名证书
|
|
||||||
|
|
||||||
如果您在服务器上使用阿帕奇(Apache)或Nginx,建议参考 [反向代理指南](administration/reverse-proxies.md)。
|
|
||||||
|
|
||||||
要使用Gitea内置HTTPS支持,您必须编辑`app.ini`文件。
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
PROTOCOL = https
|
|
||||||
ROOT_URL = https://git.example.com:3000/
|
|
||||||
HTTP_PORT = 3000
|
|
||||||
CERT_FILE = cert.pem
|
|
||||||
KEY_FILE = key.pem
|
|
||||||
```
|
|
||||||
|
|
||||||
请注意,如果您的证书由第三方证书颁发机构签名(即不是自签名的),则 cert.pem 应包含证书链。服务器证书必须是 cert.pem 中的第一个条目,后跟中介(如果有)。不必包含根证书,因为连接客户端必须已经拥有根证书才能建立信任关系。要了解有关配置值的更多信息,请查看 [配置备忘单](administration/config-cheat-sheet#server-server)。
|
|
||||||
|
|
||||||
对于“CERT_FILE”或“KEY_FILE”字段,当文件路径是相对路径时,文件路径相对于“GITEA_CUSTOM”环境变量。它也可以是绝对路径。
|
|
||||||
|
|
||||||
### 设置HTTP重定向
|
|
||||||
|
|
||||||
Gitea服务器仅支持监听一个端口;要重定向HTTP请求致HTTPS端口,您需要启用HTTP重定向服务:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
REDIRECT_OTHER_PORT = true
|
|
||||||
; Port the redirection service should listen on
|
|
||||||
PORT_TO_REDIRECT = 3080
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您使用Docker,确保端口已配置在 `docker-compose.yml` 文件
|
|
||||||
|
|
||||||
## 使用 ACME (默认: Let's Encrypt)
|
|
||||||
|
|
||||||
[ACME](https://tools.ietf.org/html/rfc8555) 是一种证书颁发机构标准协议,允许您自动请求和续订 SSL/TLS 证书。[Let`s Encrypt](https://letsencrypt.org/) 是使用此标准的免费公开信任的证书颁发机构服务器。仅实施“HTTP-01”和“TLS-ALPN-01”挑战。为了使 ACME 质询通过并验证您的域所有权,“80”端口(“HTTP-01”)或“443”端口(“TLS-ALPN-01”)上 gitea 域的外部流量必须由 gitea 实例提供服务。可能需要设置 [HTTP 重定向](#设置http重定向) 和端口转发才能正确路由外部流量。否则,到端口“80”的正常流量将自动重定向到 HTTPS。**您必须同意**ACME提供商的服务条款(默认为Let's Encrypt的 [服务条款](https://letsencrypt.org/documents/LE-SA-v1.2-2017年11月15日.pdf)。
|
|
||||||
|
|
||||||
使用默认 Let's Encrypt 的最小配置如下:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
PROTOCOL=https
|
|
||||||
DOMAIN=git.example.com
|
|
||||||
ENABLE_ACME=true
|
|
||||||
ACME_ACCEPTTOS=true
|
|
||||||
ACME_DIRECTORY=https
|
|
||||||
;; Email can be omitted here and provided manually at first run, after which it is cached
|
|
||||||
ACME_EMAIL=email@example.com
|
|
||||||
```
|
|
||||||
|
|
||||||
小型配置请使用 [smallstep CA](https://github.com/smallstep/certificates), 点击 [教程](https://smallstep.com/docs/tutorials/acme-challenge) 了解更多信息。
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[server]
|
|
||||||
PROTOCOL=https
|
|
||||||
DOMAIN=git.example.com
|
|
||||||
ENABLE_ACME=true
|
|
||||||
ACME_ACCEPTTOS=true
|
|
||||||
ACME_URL=https://ca.example.com/acme/acme/directory
|
|
||||||
;; Can be omitted if using the system's trust is preferred
|
|
||||||
;ACME_CA_ROOT=/path/to/root_ca.crt
|
|
||||||
ACME_DIRECTORY=https
|
|
||||||
ACME_EMAIL=email@example.com
|
|
||||||
```
|
|
||||||
|
|
||||||
要了解关于配置, 请访问 [配置备忘单](administration/config-cheat-sheet.md#server-server)获取更多信息
|
|
||||||
|
|
||||||
## 使用反向代理服务器
|
|
||||||
|
|
||||||
按照 [reverse proxy guide](administration/reverse-proxies.md) 的规则设置你的反向代理服务器
|
|
||||||
|
|
||||||
然后,按照下面的向导启用 HTTPS:
|
|
||||||
|
|
||||||
- [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html)
|
|
||||||
- [apache2/httpd](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html)
|
|
||||||
- [caddy](https://caddyserver.com/docs/tls)
|
|
||||||
|
|
||||||
注意:仅在代理层启用 HTTPS 被称为 [TLS 终止代理](https://en.wikipedia.org/wiki/TLS_termination_proxy)。代理服务器接受传入的 TLS 连接,解密内容,然后将现在未加密的内容传递给 Gitea。只要代理和 Gitea 实例在同一台计算机上或在私有网络中的不同计算机上(代理暴露给外部网络),这通常是可以接受的。如果您的 Gitea 实例与代理隔离在公共网络上,或者如果您想要全端到端的加密,您还可以直接在 Gitea 中 [启用内置服务器的 HTTPS 支持](#使用内置服务器),并将连接转发到 HTTPS 上。
|
|
|
@ -1,294 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-04-02T17:06:00+01:00"
|
|
||||||
title: "Logging Configuration"
|
|
||||||
slug: "logging-config"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/logging-configuration
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Logging Configuration"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "logging-config"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Logging Configuration
|
|
||||||
|
|
||||||
The logging configuration of Gitea mainly consists of 3 types of components:
|
|
||||||
|
|
||||||
- The `[log]` section for general configuration
|
|
||||||
- `[log.<mode-name>]` sections for the configuration of different log writers to output logs, aka: "writer mode", the mode name is also used as "writer name".
|
|
||||||
- The `[log]` section can also contain sub-logger configurations following the key schema `logger.<logger-name>.<CONFIG-KEY>`
|
|
||||||
|
|
||||||
There is a fully functional log output by default, so it is not necessary to define one.
|
|
||||||
|
|
||||||
## Collecting Logs for Help
|
|
||||||
|
|
||||||
To collect logs for help and issue report, see [Support Options](help/support.md).
|
|
||||||
|
|
||||||
## The `[log]` section
|
|
||||||
|
|
||||||
Configuration of logging facilities in Gitea happen in the `[log]` section and its subsections.
|
|
||||||
|
|
||||||
In the top level `[log]` section the following configurations can be placed:
|
|
||||||
|
|
||||||
- `ROOT_PATH`: (Default: **%(GITEA_WORK_DIR)/log**): Base path for log files
|
|
||||||
- `MODE`: (Default: **console**) List of log outputs to use for the Default logger.
|
|
||||||
- `LEVEL`: (Default: **Info**) Least severe log events to persist, case-insensitive. Possible values are: `Trace`, `Debug`, `Info`, `Warn`, `Error`, `Fatal`.
|
|
||||||
- `STACKTRACE_LEVEL`: (Default: **None**) For this and more severe events the stacktrace will be printed upon getting logged.
|
|
||||||
|
|
||||||
And it can contain the following sub-loggers:
|
|
||||||
|
|
||||||
- `logger.router.MODE`: (Default: **,**): List of log outputs to use for the Router logger.
|
|
||||||
- `logger.access.MODE`: (Default: **_empty_**) List of log outputs to use for the Access logger. By default, the access logger is disabled.
|
|
||||||
- `logger.xorm.MODE`: (Default: **,**) List of log outputs to use for the XORM logger.
|
|
||||||
|
|
||||||
Setting a comma (`,`) to sub-logger's mode means making it use the default global `MODE`.
|
|
||||||
|
|
||||||
## Quick samples
|
|
||||||
|
|
||||||
### Default (empty) Configuration
|
|
||||||
|
|
||||||
The empty configuration is equivalent to default:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[log]
|
|
||||||
ROOT_PATH = %(GITEA_WORK_DIR)/log
|
|
||||||
MODE = console
|
|
||||||
LEVEL = Info
|
|
||||||
STACKTRACE_LEVEL = None
|
|
||||||
logger.router.MODE = ,
|
|
||||||
logger.xorm.MODE = ,
|
|
||||||
logger.access.MODE =
|
|
||||||
|
|
||||||
; this is the config options of "console" mode (used by MODE=console above)
|
|
||||||
[log.console]
|
|
||||||
MODE = console
|
|
||||||
FLAGS = stdflags
|
|
||||||
PREFIX =
|
|
||||||
COLORIZE = true
|
|
||||||
```
|
|
||||||
|
|
||||||
This is equivalent to sending all logs to the console, with default Golang log being sent to the console log too.
|
|
||||||
|
|
||||||
This is only a sample, and it is the default, do not need to write it into your configuration file.
|
|
||||||
|
|
||||||
### Disable Router logs and record some access logs to file
|
|
||||||
|
|
||||||
The Router logger is disabled, the access logs (>=Warn) goes into `access.log`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[log]
|
|
||||||
logger.router.MODE =
|
|
||||||
logger.access.MODE = access-file
|
|
||||||
|
|
||||||
[log.access-file]
|
|
||||||
MODE = file
|
|
||||||
LEVEL = Warn
|
|
||||||
FILE_NAME = access.log
|
|
||||||
```
|
|
||||||
|
|
||||||
### Set different log levels for different modes
|
|
||||||
|
|
||||||
Default logs (>=Warn) goes into `gitea.log`, while Error logs goes into `file-error.log`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[log]
|
|
||||||
LEVEL = Warn
|
|
||||||
MODE = file, file-error
|
|
||||||
|
|
||||||
; by default, the "file" mode will record logs to %(log.ROOT_PATH)/gitea.log, so we don't need to set it
|
|
||||||
; [log.file]
|
|
||||||
; by default, the MODE (actually it's the output writer of this logger) is taken from the section name, so we don't need to set it either
|
|
||||||
; MODE = file
|
|
||||||
|
|
||||||
[log.file-error]
|
|
||||||
MODE = file
|
|
||||||
LEVEL = Error
|
|
||||||
FILE_NAME = file-error.log
|
|
||||||
```
|
|
||||||
|
|
||||||
## Log outputs (mode and writer)
|
|
||||||
|
|
||||||
Gitea provides the following log output writers:
|
|
||||||
|
|
||||||
- `console` - Log to `stdout` (or `stderr` if it is set in the config)
|
|
||||||
- `file` - Log to a file
|
|
||||||
- `conn` - Log to a socket (network or unix)
|
|
||||||
|
|
||||||
### Common configuration
|
|
||||||
|
|
||||||
Certain configuration is common to all modes of log output:
|
|
||||||
|
|
||||||
- `MODE` is the mode of the log output writer. It will default to the mode name in the ini section. Thus `[log.console]` will default to `MODE = console`.
|
|
||||||
- `LEVEL` is the lowest level that this output will log.
|
|
||||||
- `STACKTRACE_LEVEL` is the lowest level that this output will print a stacktrace.
|
|
||||||
- `COLORIZE` will default to `true` for `console` as described, otherwise it will default to `false`.
|
|
||||||
|
|
||||||
#### `EXPRESSION`
|
|
||||||
|
|
||||||
`EXPRESSION` represents a regular expression that log events must match to be logged by the output writer.
|
|
||||||
Either the log message, (with colors removed), must match or the `longfilename:linenumber:functionname` must match.
|
|
||||||
NB: the whole message or string doesn't need to completely match.
|
|
||||||
|
|
||||||
Please note this expression will be run in the writer's goroutine but not the logging event goroutine.
|
|
||||||
|
|
||||||
#### `FLAGS`
|
|
||||||
|
|
||||||
`FLAGS` represents the preceding logging context information that is
|
|
||||||
printed before each message. It is a comma-separated string set. The order of values does not matter.
|
|
||||||
|
|
||||||
It defaults to `stdflags` (= `date,time,medfile,shortfuncname,levelinitial`)
|
|
||||||
|
|
||||||
Possible values are:
|
|
||||||
|
|
||||||
- `none` or `,` - No flags.
|
|
||||||
- `date` - the date in the local time zone: `2009/01/23`.
|
|
||||||
- `time` - the time in the local time zone: `01:23:23`.
|
|
||||||
- `microseconds` - microsecond resolution: `01:23:23.123123`. Assumes time.
|
|
||||||
- `longfile` - full file name and line number: `/a/b/c/d.go:23`.
|
|
||||||
- `shortfile` - final file name element and line number: `d.go:23`.
|
|
||||||
- `funcname` - function name of the caller: `runtime.Caller()`.
|
|
||||||
- `shortfuncname` - last part of the function name. Overrides `funcname`.
|
|
||||||
- `utc` - if date or time is set, use UTC rather than the local time zone.
|
|
||||||
- `levelinitial` - initial character of the provided level in brackets eg. `[I]` for info.
|
|
||||||
- `level` - level in brackets `[INFO]`.
|
|
||||||
- `gopid` - the Goroutine-PID of the context.
|
|
||||||
- `medfile` - last 20 characters of the filename - equivalent to `shortfile,longfile`.
|
|
||||||
- `stdflags` - equivalent to `date,time,medfile,shortfuncname,levelinitial`.
|
|
||||||
|
|
||||||
### Console mode
|
|
||||||
|
|
||||||
In this mode the logger will forward log messages to the stdout and
|
|
||||||
stderr streams attached to the Gitea process.
|
|
||||||
|
|
||||||
For loggers in console mode, `COLORIZE` will default to `true` if not
|
|
||||||
on windows, or the Windows terminal can be set into ANSI mode or is a
|
|
||||||
cygwin or Msys pipe.
|
|
||||||
|
|
||||||
Settings:
|
|
||||||
|
|
||||||
- `STDERR`: **false**: Whether the logger should print to `stderr` instead of `stdout`.
|
|
||||||
|
|
||||||
### File mode
|
|
||||||
|
|
||||||
In this mode the logger will save log messages to a file.
|
|
||||||
|
|
||||||
Settings:
|
|
||||||
|
|
||||||
- `FILE_NAME`: The file to write the log events to, relative to `ROOT_PATH`, Default to `%(ROOT_PATH)/gitea.log`. Exception: access log will default to `%(ROOT_PATH)/access.log`.
|
|
||||||
- `MAX_SIZE_SHIFT`: **28**: Maximum size shift of a single file. 28 represents 256Mb. For details see below.
|
|
||||||
- `LOG_ROTATE` **true**: Whether to rotate the log files. TODO: if false, will it delete instead on daily rotate, or do nothing?.
|
|
||||||
- `DAILY_ROTATE`: **true**: Whether to rotate logs daily.
|
|
||||||
- `MAX_DAYS`: **7**: Delete rotated log files after this number of days.
|
|
||||||
- `COMPRESS`: **true**: Whether to compress old log files by default with gzip.
|
|
||||||
- `COMPRESSION_LEVEL`: **-1**: Compression level. For details see below.
|
|
||||||
|
|
||||||
`MAX_SIZE_SHIFT` defines the maximum size of a file by left shifting 1 the given number of times (`1 << x`).
|
|
||||||
The exact behavior at the time of v1.17.3 can be seen [here](https://github.com/go-gitea/gitea/blob/v1.17.3/modules/setting/log.go#L185).
|
|
||||||
|
|
||||||
The useful values of `COMPRESSION_LEVEL` are from 1 to (and including) 9, where higher numbers mean better compression.
|
|
||||||
Beware that better compression might come with higher resource usage.
|
|
||||||
Must be preceded with a `-` sign.
|
|
||||||
|
|
||||||
### Conn mode
|
|
||||||
|
|
||||||
In this mode the logger will send log messages over a network socket.
|
|
||||||
|
|
||||||
Settings:
|
|
||||||
|
|
||||||
- `ADDR`: **:7020**: Sets the address to connect to.
|
|
||||||
- `PROTOCOL`: **tcp**: Set the protocol, either "tcp", "unix" or "udp".
|
|
||||||
- `RECONNECT`: **false**: Try to reconnect when connection is lost.
|
|
||||||
- `RECONNECT_ON_MSG`: **false**: Reconnect host for every single message.
|
|
||||||
|
|
||||||
### The "Router" logger
|
|
||||||
|
|
||||||
The Router logger logs the following message types when Gitea's route handlers work:
|
|
||||||
|
|
||||||
- `started` messages will be logged at TRACE level
|
|
||||||
- `polling`/`completed` routers will be logged at INFO. Exception: "/assets" static resource requests are also logged at TRACE.
|
|
||||||
- `slow` routers will be logged at WARN
|
|
||||||
- `failed` routers will be logged at WARN
|
|
||||||
|
|
||||||
### The "XORM" logger
|
|
||||||
|
|
||||||
To make XORM outputs SQL logs, the `LOG_SQL` in `[database]` section should also be set to `true`.
|
|
||||||
|
|
||||||
### The "Access" logger
|
|
||||||
|
|
||||||
The Access logger is a new logger since Gitea 1.9. It provides a NCSA
|
|
||||||
Common Log compliant log format. It's highly configurable but caution
|
|
||||||
should be taken when changing its template. The main benefit of this
|
|
||||||
logger is that Gitea can now log accesses in a standard log format so
|
|
||||||
standard tools may be used.
|
|
||||||
|
|
||||||
You can enable this logger using `logger.access.MODE = ...`.
|
|
||||||
|
|
||||||
If desired the format of the Access logger can be changed by changing
|
|
||||||
the value of the `ACCESS_LOG_TEMPLATE`.
|
|
||||||
|
|
||||||
Please note, the access logger will log at `INFO` level, setting the
|
|
||||||
`LEVEL` of this logger to `WARN` or above will result in no access logs.
|
|
||||||
|
|
||||||
#### The ACCESS_LOG_TEMPLATE
|
|
||||||
|
|
||||||
This value represents a go template. Its default value is
|
|
||||||
|
|
||||||
```tmpl
|
|
||||||
{{.Ctx.RemoteHost}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}" "{{.Ctx.Req.UserAgent}}"`
|
|
||||||
```
|
|
||||||
|
|
||||||
The template is passed following options:
|
|
||||||
|
|
||||||
- `Ctx` is the `context.Context`
|
|
||||||
- `Identity` is the `SignedUserName` or `"-"` if the user is not logged in
|
|
||||||
- `Start` is the start time of the request
|
|
||||||
- `ResponseWriter` is the `http.ResponseWriter`
|
|
||||||
|
|
||||||
Caution must be taken when changing this template as it runs outside of
|
|
||||||
the standard panic recovery trap. The template should also be as simple
|
|
||||||
as it runs for every request.
|
|
||||||
|
|
||||||
## Releasing-and-Reopening, Pausing and Resuming logging
|
|
||||||
|
|
||||||
If you are running on Unix you may wish to release-and-reopen logs in order to use `logrotate` or other tools.
|
|
||||||
It is possible force Gitea to release and reopen it's logging files and connections by sending `SIGUSR1` to the
|
|
||||||
running process, or running `gitea manager logging release-and-reopen`.
|
|
||||||
|
|
||||||
Alternatively, you may wish to pause and resume logging - this can be accomplished through the use of the
|
|
||||||
`gitea manager logging pause` and `gitea manager logging resume` commands. Please note that whilst logging
|
|
||||||
is paused log events below INFO level will not be stored and only a limited number of events will be stored.
|
|
||||||
Logging may block, albeit temporarily, slowing Gitea considerably whilst paused - therefore it is
|
|
||||||
recommended that pausing only done for a very short period of time.
|
|
||||||
|
|
||||||
## Adding and removing logging whilst Gitea is running
|
|
||||||
|
|
||||||
It is possible to add and remove logging whilst Gitea is running using the `gitea manager logging add` and `remove` subcommands.
|
|
||||||
This functionality can only adjust running log systems and cannot be used to start the access or router loggers if they
|
|
||||||
were not already initialized. If you wish to start these systems you are advised to adjust the app.ini and (gracefully) restart
|
|
||||||
the Gitea service.
|
|
||||||
|
|
||||||
The main intention of these commands is to easily add a temporary logger to investigate problems on running systems where a restart
|
|
||||||
may cause the issue to disappear.
|
|
||||||
|
|
||||||
## Using `logrotate` instead of built-in log rotation
|
|
||||||
|
|
||||||
Gitea includes built-in log rotation, which should be enough for most deployments. However, if you instead want to use the `logrotate` utility:
|
|
||||||
|
|
||||||
- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`.
|
|
||||||
- Install `logrotate`.
|
|
||||||
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details.
|
|
||||||
In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself,
|
|
||||||
or run `gitea manager logging release-and-reopen` (with the appropriate environment).
|
|
||||||
Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
|
|
||||||
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
|
|
||||||
- If you are using docker and are running from outside the container you can use
|
|
||||||
`docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'`
|
|
||||||
or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the Gitea process itself.
|
|
||||||
|
|
||||||
The next `logrotate` jobs will include your configurations, so no restart is needed.
|
|
||||||
You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`.
|
|
|
@ -1,272 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "日志配置"
|
|
||||||
slug: "logging-config"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/logging-configuration
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "日志配置"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "logging-config"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 日志配置
|
|
||||||
|
|
||||||
Gitea 的日志配置主要由以下三种类型的组件组成:
|
|
||||||
|
|
||||||
- `[log]` 部分用于一般配置
|
|
||||||
- `[log.<mode-name>]` 部分用于配置不同的日志输出方式,也称为 "writer mode",模式名称同时也作为 "writer name"
|
|
||||||
- `[log]` 部分还可以包含遵循 `logger.<logger-name>.<CONFIG-KEY>` 模式的子日志记录器的配置
|
|
||||||
|
|
||||||
默认情况下,已经有一个完全功能的日志输出,因此不需要重新定义。
|
|
||||||
|
|
||||||
## 收集日志以获取帮助
|
|
||||||
|
|
||||||
要收集日志以获取帮助和报告问题,请参阅 [需要帮助](help/support.md)。
|
|
||||||
|
|
||||||
## `[log]` 部分
|
|
||||||
|
|
||||||
在 Gitea 中,日志设施的配置在 `[log]` 部分及其子部分。
|
|
||||||
|
|
||||||
在顶层的 `[log]` 部分,可以放置以下配置项:
|
|
||||||
|
|
||||||
- `ROOT_PATH`:(默认值:**%(GITEA_WORK_DIR)/log**):日志文件的基本路径。
|
|
||||||
- `MODE`:(默认值:**console**):要用于默认日志记录器的日志输出列表。
|
|
||||||
- `LEVEL`:(默认值:**Info**):要持久化的最严重的日志事件,不区分大小写。可能的值为:`Trace`、`Debug`、`Info`、`Warn`、`Error`、`Fatal`。
|
|
||||||
- `STACKTRACE_LEVEL`:(默认值:**None**):对于此类及更严重的事件,将在记录时打印堆栈跟踪。
|
|
||||||
|
|
||||||
它还可以包含以下子日志记录器:
|
|
||||||
|
|
||||||
- `logger.router.MODE`:(默认值:**,**):用于路由器日志记录器的日志输出列表。
|
|
||||||
- `logger.access.MODE`:(默认值:**_empty_**):用于访问日志记录器的日志输出列表。默认情况下,访问日志记录器被禁用。
|
|
||||||
- `logger.xorm.MODE`:(默认值:**,**):用于 XORM 日志记录器的日志输出列表。
|
|
||||||
|
|
||||||
将子日志记录器的模式设置为逗号(`,`)表示使用默认的全局 `MODE`。
|
|
||||||
|
|
||||||
## 快速示例
|
|
||||||
|
|
||||||
### 默认(空)配置
|
|
||||||
|
|
||||||
空配置等同于默认配置:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[log]
|
|
||||||
ROOT_PATH = %(GITEA_WORK_DIR)/log
|
|
||||||
MODE = console
|
|
||||||
LEVEL = Info
|
|
||||||
STACKTRACE_LEVEL = None
|
|
||||||
logger.router.MODE = ,
|
|
||||||
logger.xorm.MODE = ,
|
|
||||||
logger.access.MODE =
|
|
||||||
|
|
||||||
; 这是“控制台”模式的配置选项(由上面的 MODE=console 使用)
|
|
||||||
[log.console]
|
|
||||||
MODE = console
|
|
||||||
FLAGS = stdflags
|
|
||||||
PREFIX =
|
|
||||||
COLORIZE = true
|
|
||||||
```
|
|
||||||
|
|
||||||
这等同于将所有日志发送到控制台,并将默认的 Golang 日志也发送到控制台日志中。
|
|
||||||
|
|
||||||
这只是一个示例,默认情况下不需要将其写入配置文件中。
|
|
||||||
|
|
||||||
### 禁用路由日志并将一些访问日志记录到文件中
|
|
||||||
|
|
||||||
禁用路由日志,将访问日志(>=Warn)记录到 `access.log` 中:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[log]
|
|
||||||
logger.router.MODE =
|
|
||||||
logger.access.MODE = access-file
|
|
||||||
|
|
||||||
[log.access-file]
|
|
||||||
MODE = file
|
|
||||||
LEVEL = Warn
|
|
||||||
FILE_NAME = access.log
|
|
||||||
```
|
|
||||||
|
|
||||||
### 为不同的模式设置不同的日志级别
|
|
||||||
|
|
||||||
将默认日志(>=Warn)记录到 `gitea.log` 中,将错误日志记录到 `file-error.log` 中:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[log]
|
|
||||||
LEVEL = Warn
|
|
||||||
MODE = file, file-error
|
|
||||||
|
|
||||||
; 默认情况下,"file" 模式会将日志记录到 %(log.ROOT_PATH)/gitea.log,因此我们不需要设置它
|
|
||||||
; [log.file]
|
|
||||||
|
|
||||||
[log.file-error]
|
|
||||||
LEVEL = Error
|
|
||||||
FILE_NAME = file-error.log
|
|
||||||
```
|
|
||||||
|
|
||||||
## 日志输出(模式和写入器)
|
|
||||||
|
|
||||||
Gitea 提供以下日志写入器:
|
|
||||||
|
|
||||||
- `console` - 输出日志到 `stdout`(或 `stderr`,如果已在配置中设置)
|
|
||||||
- `file` - 输出日志到文件
|
|
||||||
- `conn` - 输出日志到套接字(网络或 Unix 套接字)
|
|
||||||
|
|
||||||
### 公共配置
|
|
||||||
|
|
||||||
某些配置适用于所有日志输出模式:
|
|
||||||
|
|
||||||
- `MODE` 是日志输出写入器的模式。它将默认为 ini 部分的模式名称。因此,`[log.console]` 将默认为 `MODE = console`。
|
|
||||||
- `LEVEL` 是此输出将记录的最低日志级别。
|
|
||||||
- `STACKTRACE_LEVEL` 是此输出将打印堆栈跟踪的最低日志级别。
|
|
||||||
- `COLORIZE` 对于 `console`,默认为 `true`,否则默认为 `false`。
|
|
||||||
|
|
||||||
#### `EXPRESSION`
|
|
||||||
|
|
||||||
`EXPRESSION` 表示日志事件必须匹配才能被输出写入器记录的正则表达式。
|
|
||||||
日志消息(去除颜色)或 `longfilename:linenumber:functionname` 必须匹配其中之一。
|
|
||||||
注意:整个消息或字符串不需要完全匹配。
|
|
||||||
|
|
||||||
请注意,此表达式将在写入器的 goroutine 中运行,而不是在日志事件的 goroutine 中运行。
|
|
||||||
|
|
||||||
#### `FLAGS`
|
|
||||||
|
|
||||||
`FLAGS` 表示在每条消息之前打印的前置日志上下文信息。
|
|
||||||
它是一个逗号分隔的字符串集。值的顺序无关紧要。
|
|
||||||
|
|
||||||
默认值为 `stdflags`(= `date,time,medfile,shortfuncname,levelinitial`)。
|
|
||||||
|
|
||||||
可能的值为:
|
|
||||||
|
|
||||||
- `none` 或 `,` - 无标志。
|
|
||||||
- `date` - 当地时区的日期:`2009/01/23`。
|
|
||||||
- `time` - 当地时区的时间:`01:23:23`。
|
|
||||||
- `microseconds` - 微秒精度:`01:23:23.123123`。假定有时间。
|
|
||||||
- `longfile` - 完整的文件名和行号:`/a/b/c/d.go:23`。
|
|
||||||
- `shortfile` - 文件名的最后一个部分和行号:`d.go:23`。
|
|
||||||
- `funcname` - 调用者的函数名:`runtime.Caller()`。
|
|
||||||
- `shortfuncname` - 函数名的最后一部分。覆盖 `funcname`。
|
|
||||||
- `utc` - 如果设置了日期或时间,则使用 UTC 而不是本地时区。
|
|
||||||
- `levelinitial` - 提供的级别的初始字符,放在方括号内,例如 `[I]` 表示 info。
|
|
||||||
- `level` - 在方括号内的级别,例如 `[INFO]`。
|
|
||||||
- `gopid` - 上下文的 Goroutine-PID。
|
|
||||||
- `medfile` - 文件名的最后 20 个字符 - 相当于 `shortfile,longfile`。
|
|
||||||
- `stdflags` - 相当于 `date,time,medfile,shortfuncname,levelinitial`。
|
|
||||||
|
|
||||||
### Console 模式
|
|
||||||
|
|
||||||
在此模式下,日志记录器将将日志消息转发到 Gitea 进程附加的 stdout 和 stderr 流。
|
|
||||||
|
|
||||||
对于 console 模式的日志记录器,如果不在 Windows 上,或者 Windows 终端可以设置为 ANSI 模式,或者是 cygwin 或 Msys 管道,则 `COLORIZE` 默认为 `true`。
|
|
||||||
|
|
||||||
设置:
|
|
||||||
|
|
||||||
- `STDERR`:**false**:日志记录器是否应将日志打印到 `stderr` 而不是 `stdout`。
|
|
||||||
|
|
||||||
### File 模式
|
|
||||||
|
|
||||||
在此模式下,日志记录器将将日志消息保存到文件中。
|
|
||||||
|
|
||||||
设置:
|
|
||||||
|
|
||||||
- `FILE_NAME`:要将日志事件写入的文件,相对于 `ROOT_PATH`,默认为 `%(ROOT_PATH)/gitea.log`。异常情况:访问日志默认为 `%(ROOT_PATH)/access.log`。
|
|
||||||
- `MAX_SIZE_SHIFT`:**28**:单个文件的最大大小位移。28 表示 256Mb。详细信息见下文。
|
|
||||||
- `LOG_ROTATE` **true**:是否轮转日志文件。
|
|
||||||
- `DAILY_ROTATE`:**true**:是否每天旋转日志。
|
|
||||||
- `MAX_DAYS`:**7**:在此天数之后删除旋转的日志文件。
|
|
||||||
- `COMPRESS`:**true**:默认情况下是否使用 gzip 压缩旧的日志文件。
|
|
||||||
- `COMPRESSION_LEVEL`:**-1**:压缩级别。详细信息见下文。
|
|
||||||
|
|
||||||
`MAX_SIZE_SHIFT` 通过将给定次数左移 1 (`1 << x`) 来定义文件的最大大小。
|
|
||||||
在 v1.17.3 版本时的确切行为可以在[这里](https://github.com/go-gitea/gitea/blob/v1.17.3/modules/setting/log.go#L185)中查看。
|
|
||||||
|
|
||||||
`COMPRESSION_LEVEL` 的有用值范围从 1 到(包括)9,其中较高的数字表示更好的压缩。
|
|
||||||
请注意,更好的压缩可能会带来更高的资源使用。
|
|
||||||
必须在前面加上 `-` 符号。
|
|
||||||
|
|
||||||
### Conn 模式
|
|
||||||
|
|
||||||
在此模式下,日志记录器将通过网络套接字发送日志消息。
|
|
||||||
|
|
||||||
设置:
|
|
||||||
|
|
||||||
- `ADDR`:**:7020**:设置要连接的地址。
|
|
||||||
- `PROTOCOL`:**tcp**:设置协议,可以是 "tcp"、"unix" 或 "udp"。
|
|
||||||
- `RECONNECT`:**false**:在连接丢失时尝试重新连接。
|
|
||||||
- `RECONNECT_ON_MSG`:**false**:为每条消息重新连接主机。
|
|
||||||
|
|
||||||
### "Router" 日志记录器
|
|
||||||
|
|
||||||
当 Gitea 的路由处理程序工作时,Router 日志记录器记录以下消息类型:
|
|
||||||
|
|
||||||
- `started` 消息将以 TRACE 级别记录
|
|
||||||
- `polling`/`completed` 路由将以 INFO 级别记录。异常情况:"/assets" 静态资源请求也会以 TRACE 级别记录。
|
|
||||||
- `slow` 路由将以 WARN 级别记录
|
|
||||||
- `failed` 路由将以 WARN 级别记录
|
|
||||||
|
|
||||||
### "XORM" 日志记录器
|
|
||||||
|
|
||||||
为了使 XORM 输出 SQL 日志,还应将 `[database]` 部分中的 `LOG_SQL` 设置为 `true`。
|
|
||||||
|
|
||||||
### "Access" 日志记录器
|
|
||||||
|
|
||||||
"Access" 日志记录器是自 Gitea 1.9 版本以来的新日志记录器。它提供了符合 NCSA Common Log 标准的日志格式。虽然它具有高度可配置性,但在更改其模板时应谨慎。此日志记录器的主要好处是,Gitea 现在可以使用标准日志格式记录访问日志,因此可以使用标准工具进行分析。
|
|
||||||
|
|
||||||
您可以通过使用 `logger.access.MODE = ...` 来启用此日志记录器。
|
|
||||||
|
|
||||||
如果需要,可以通过更改 `ACCESS_LOG_TEMPLATE` 的值来更改 "Access" 日志记录器的格式。
|
|
||||||
|
|
||||||
请注意,访问日志记录器将以 `INFO` 级别记录,将此日志记录器的 `LEVEL` 设置为 `WARN` 或更高级别将导致不记录访问日志。
|
|
||||||
|
|
||||||
#### ACCESS_LOG_TEMPLATE
|
|
||||||
|
|
||||||
此值表示一个 Go 模板。其默认值为
|
|
||||||
|
|
||||||
```tmpl
|
|
||||||
{{.Ctx.RemoteHost}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}" "{{.Ctx.Req.UserAgent}}"`
|
|
||||||
```
|
|
||||||
|
|
||||||
模板接收以下选项:
|
|
||||||
|
|
||||||
- `Ctx` 是 `context.Context`
|
|
||||||
- `Identity` 是 `SignedUserName`,如果用户未登录,则为 "-"
|
|
||||||
- `Start` 是请求的开始时间
|
|
||||||
- `ResponseWriter` 是 `http.ResponseWriter`
|
|
||||||
|
|
||||||
更改此模板时必须小心,因为它在标准的 panic 恢复陷阱之外运行。此模板应该尽可能简单,因为它会为每个请求运行一次。
|
|
||||||
|
|
||||||
## 释放和重新打开、暂停和恢复日志记录
|
|
||||||
|
|
||||||
如果您在 Unix 上运行,您可能希望释放和重新打开日志以使用 `logrotate` 或其他工具。
|
|
||||||
可以通过向运行中的进程发送 `SIGUSR1` 信号或运行 `gitea manager logging release-and-reopen` 命令来强制 Gitea 释放并重新打开其日志文件和连接。
|
|
||||||
|
|
||||||
或者,您可能希望暂停和恢复日志记录 - 可以通过使用 `gitea manager logging pause` 和 `gitea manager logging resume` 命令来实现。请注意,当日志记录暂停时,低于 INFO 级别的日志事件将不会存储,并且只会存储有限数量的事件。在暂停时,日志记录可能会阻塞,尽管是暂时性的,但会大大减慢 Gitea 的运行速度,因此建议仅暂停很短的时间。
|
|
||||||
|
|
||||||
### 在 Gitea 运行时添加和删除日志记录
|
|
||||||
|
|
||||||
可以使用 `gitea manager logging add` 和 `remove` 子命令在 Gitea 运行时添加和删除日志记录。
|
|
||||||
此功能只能调整正在运行的日志系统,不能用于启动未初始化的访问或路由日志记录器。如果您希望启动这些系统,建议调整 app.ini 并(优雅地)重新启动 Gitea 服务。
|
|
||||||
|
|
||||||
这些命令的主要目的是在运行中的系统上轻松添加临时日志记录器,以便调查问题,因为重新启动可能会导致问题消失。
|
|
||||||
|
|
||||||
## 使用 `logrotate` 而不是内置的日志轮转
|
|
||||||
|
|
||||||
Gitea 包含内置的日志轮转功能,对于大多数部署来说应该已经足够了。但是,如果您想使用 `logrotate` 工具:
|
|
||||||
|
|
||||||
- 在 `app.ini` 中将 `LOG_ROTATE` 设置为 `false`,禁用内置的日志轮转。
|
|
||||||
- 安装 `logrotate`。
|
|
||||||
- 根据部署要求配置 `logrotate`,有关配置语法细节,请参阅 `man 8 logrotate`。
|
|
||||||
在 `postrotate/endscript` 块中通过 `kill -USR1` 或 `kill -10` 向 `gitea` 进程本身发送 `USR1` 信号,
|
|
||||||
或者运行 `gitea manager logging release-and-reopen`(使用适当的环境设置)。
|
|
||||||
确保配置适用于由 Gitea 日志记录器生成的所有文件,如上述部分所述。
|
|
||||||
- 始终使用 `logrotate /etc/logrotate.conf --debug` 来测试您的配置。
|
|
||||||
- 如果您正在使用 Docker 并从容器外部运行,您可以使用
|
|
||||||
`docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'`
|
|
||||||
或 `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'`,或直接向 Gitea 进程本身发送 `USR1` 信号。
|
|
||||||
|
|
||||||
下一个 `logrotate` 作业将包括您的配置,因此不需要重新启动。
|
|
||||||
您还可以立即使用 `logrotate /etc/logrotate.conf --force` 重新加载 `logrotate`。
|
|
|
@ -1,278 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-10-23T17:00:00-03:00"
|
|
||||||
title: "Mail templates"
|
|
||||||
slug: "mail-templates"
|
|
||||||
sidebar_position: 45
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/mail-templates
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Mail templates"
|
|
||||||
sidebar_position: 45
|
|
||||||
identifier: "mail-templates"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Mail templates
|
|
||||||
|
|
||||||
To craft the e-mail subject and contents for certain operations, Gitea can be customized by using templates. The templates
|
|
||||||
for these functions are located under the [`custom` directory](administration/customizing-gitea.md).
|
|
||||||
Gitea has an internal template that serves as default in case there's no custom alternative.
|
|
||||||
|
|
||||||
Custom templates are loaded when Gitea starts. Changes made to them are not recognized until Gitea is restarted again.
|
|
||||||
|
|
||||||
## Mail notifications supporting templates
|
|
||||||
|
|
||||||
Currently, the following notification events make use of templates:
|
|
||||||
|
|
||||||
| Action name | Usage |
|
|
||||||
| ----------- | ------------------------------------------------------------------------------------------------------------ |
|
|
||||||
| `new` | A new issue or pull request was created. |
|
|
||||||
| `comment` | A new comment was created in an existing issue or pull request. |
|
|
||||||
| `close` | An issue or pull request was closed. |
|
|
||||||
| `reopen` | An issue or pull request was reopened. |
|
|
||||||
| `review` | The head comment of a review in a pull request. |
|
|
||||||
| `approve` | The head comment of a approving review for a pull request. |
|
|
||||||
| `reject` | The head comment of a review requesting changes for a pull request. |
|
|
||||||
| `code` | A single comment on the code of a pull request. |
|
|
||||||
| `assigned` | User was assigned to an issue or pull request. |
|
|
||||||
| `default` | Any action not included in the above categories, or when the corresponding category template is not present. |
|
|
||||||
|
|
||||||
The path for the template of a particular message type is:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
custom/templates/mail/{action type}/{action name}.tmpl
|
|
||||||
```
|
|
||||||
|
|
||||||
Where `{action type}` is one of `issue` or `pull` (for pull requests), and `{action name}` is one of the names listed above.
|
|
||||||
|
|
||||||
For example, the specific template for a mail regarding a comment in a pull request is:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
custom/templates/mail/pull/comment.tmpl
|
|
||||||
```
|
|
||||||
|
|
||||||
However, creating templates for each and every action type/name combination is not required.
|
|
||||||
A fallback system is used to choose the appropriate template for an event. The _first existing_
|
|
||||||
template on this list is used:
|
|
||||||
|
|
||||||
- The specific template for the desired **action type** and **action name**.
|
|
||||||
- The template for action type `issue` and the desired **action name**.
|
|
||||||
- The template for the desired **action type**, action name `default`.
|
|
||||||
- The template for action type `issue`, action name `default`.
|
|
||||||
|
|
||||||
The only mandatory template is action type `issue`, action name `default`, which is already embedded in Gitea
|
|
||||||
unless it's overridden by the user in the `custom` directory.
|
|
||||||
|
|
||||||
## Template syntax
|
|
||||||
|
|
||||||
Mail templates are UTF-8 encoded text files that need to follow one of the following formats:
|
|
||||||
|
|
||||||
```
|
|
||||||
Text and macros for the subject line
|
|
||||||
------------
|
|
||||||
Text and macros for the mail body
|
|
||||||
```
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
```
|
|
||||||
Text and macros for the mail body
|
|
||||||
```
|
|
||||||
|
|
||||||
Specifying a _subject_ section is optional (and therefore also the dash line separator). When used, the separator between
|
|
||||||
_subject_ and _mail body_ templates requires at least three dashes; no other characters are allowed in the separator line.
|
|
||||||
|
|
||||||
_Subject_ and _mail body_ are parsed by [Golang's template engine](https://go.dev/pkg/text/template/) and
|
|
||||||
are provided with a _metadata context_ assembled for each notification. The context contains the following elements:
|
|
||||||
|
|
||||||
| Name | Type | Available | Usage |
|
|
||||||
| ------------------ | ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `.FallbackSubject` | string | Always | A default subject line. See Below. |
|
|
||||||
| `.Subject` | string | Only in body | The _subject_, once resolved. |
|
|
||||||
| `.Body` | string | Always | The message of the issue, pull request or comment, parsed from Markdown into HTML and sanitized. Do not confuse with the _mail body_. |
|
|
||||||
| `.Link` | string | Always | The address of the originating issue, pull request or comment. |
|
|
||||||
| `.Issue` | models.Issue | Always | The issue (or pull request) originating the notification. To get data specific to a pull request (e.g. `HasMerged`), `.Issue.PullRequest` can be used, but care should be taken as this field will be `nil` if the issue is _not_ a pull request. |
|
|
||||||
| `.Comment` | models.Comment | If applicable | If the notification is from a comment added to an issue or pull request, this will contain the information about the comment. |
|
|
||||||
| `.IsPull` | bool | Always | `true` if the mail notification is associated with a pull request (i.e. `.Issue.PullRequest` is not `nil`). |
|
|
||||||
| `.Repo` | string | Always | Name of the repository, including owner name (e.g. `mike/stuff`) |
|
|
||||||
| `.User` | models.User | Always | Owner of the repository from which the event originated. To get the user name (e.g. `mike`),`.User.Name` can be used. |
|
|
||||||
| `.Doer` | models.User | Always | User that executed the action triggering the notification event. To get the user name (e.g. `rhonda`), `.Doer.Name` can be used. |
|
|
||||||
| `.IsMention` | bool | Always | `true` if this notification was only generated because the user was mentioned in the comment, while not being subscribed to the source. It will be `false` if the recipient was subscribed to the issue or repository. |
|
|
||||||
| `.SubjectPrefix` | string | Always | `Re: ` if the notification is about other than issue or pull request creation; otherwise an empty string. |
|
|
||||||
| `.ActionType` | string | Always | `"issue"` or `"pull"`. Will correspond to the actual _action type_ independently of which template was selected. |
|
|
||||||
| `.ActionName` | string | Always | It will be one of the action types described above (`new`, `comment`, etc.), and will correspond to the actual _action name_ independently of which template was selected. |
|
|
||||||
| `.ReviewComments` | []models.Comment | Always | List of code comments in a review. The comment text will be in `.RenderedContent` and the referenced code will be in `.Patch`. |
|
|
||||||
|
|
||||||
All names are case sensitive.
|
|
||||||
|
|
||||||
### The _subject_ part of the template
|
|
||||||
|
|
||||||
The template engine used for the mail _subject_ is golang's [`text/template`](https://go.dev/pkg/text/template/).
|
|
||||||
Please refer to the linked documentation for details about its syntax.
|
|
||||||
|
|
||||||
The _subject_ is built using the following steps:
|
|
||||||
|
|
||||||
- A template is selected according to the type of notification and to what templates are present.
|
|
||||||
- The template is parsed and resolved (e.g. `{{.Issue.Index}}` is converted to the number of the issue
|
|
||||||
or pull request).
|
|
||||||
- All space-like characters (e.g. `TAB`, `LF`, etc.) are converted to normal spaces.
|
|
||||||
- All leading, trailing and redundant spaces are removed.
|
|
||||||
- The string is truncated to its first 256 runes (characters).
|
|
||||||
|
|
||||||
If the end result is an empty string, **or** no subject template was available (i.e. the selected template
|
|
||||||
did not include a subject part), Gitea's **internal default** will be used.
|
|
||||||
|
|
||||||
The internal default (fallback) subject is the equivalent of:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
{{.SubjectPrefix}}[{{.Repo}}] {{.Issue.Title}} (#{{.Issue.Index}})
|
|
||||||
```
|
|
||||||
|
|
||||||
For example: `Re: [mike/stuff] New color palette (#38)`
|
|
||||||
|
|
||||||
Gitea's default subject can also be found in the template _metadata_ as `.FallbackSubject` from any of
|
|
||||||
the two templates, even if a valid subject template is present.
|
|
||||||
|
|
||||||
### The _mail body_ part of the template
|
|
||||||
|
|
||||||
The template engine used for the _mail body_ is golang's [`html/template`](https://go.dev/pkg/html/template/).
|
|
||||||
Please refer to the linked documentation for details about its syntax.
|
|
||||||
|
|
||||||
The _mail body_ is parsed after the mail subject, so there is an additional _metadata_ field which is
|
|
||||||
the actual rendered subject, after all considerations.
|
|
||||||
|
|
||||||
The expected result is HTML (including structural elements like`<html>`, `<body>`, etc.). Styling
|
|
||||||
through `<style>` blocks, `class` and `style` attributes is possible. However, `html/template`
|
|
||||||
does some [automatic escaping](https://go.dev/pkg/html/template/#hdr-Contexts) that should be considered.
|
|
||||||
|
|
||||||
Attachments (such as images or external style sheets) are not supported. However, other templates can
|
|
||||||
be referenced too, for example to provide the contents of a `<style>` element in a centralized fashion.
|
|
||||||
The external template must be placed under `custom/mail` and referenced relative to that directory.
|
|
||||||
For example, `custom/mail/styles/base.tmpl` can be included using `{{template styles/base}}`.
|
|
||||||
|
|
||||||
The mail is sent with `Content-Type: multipart/alternative`, so the body is sent in both HTML
|
|
||||||
and text formats. The latter is obtained by stripping the HTML markup.
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
How a mail is rendered is directly dependent on the capabilities of the mail application. Many mail
|
|
||||||
clients don't even support HTML, so they show the text version included in the generated mail.
|
|
||||||
|
|
||||||
If the template fails to render, it will be noticed only at the moment the mail is sent.
|
|
||||||
A default subject is used if the subject template fails, and whatever was rendered successfully
|
|
||||||
from the _mail body_ is used, disregarding the rest.
|
|
||||||
|
|
||||||
Please check [Gitea's logs](administration/logging-config.md) for error messages in case of trouble.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
`custom/templates/mail/issue/default.tmpl`:
|
|
||||||
|
|
||||||
```html
|
|
||||||
[{{.Repo}}] @{{.Doer.Name}}
|
|
||||||
{{if eq .ActionName "new"}}
|
|
||||||
created
|
|
||||||
{{else if eq .ActionName "comment"}}
|
|
||||||
commented on
|
|
||||||
{{else if eq .ActionName "close"}}
|
|
||||||
closed
|
|
||||||
{{else if eq .ActionName "reopen"}}
|
|
||||||
reopened
|
|
||||||
{{else}}
|
|
||||||
updated
|
|
||||||
{{end}}
|
|
||||||
{{if eq .ActionType "issue"}}
|
|
||||||
issue
|
|
||||||
{{else}}
|
|
||||||
pull request
|
|
||||||
{{end}}
|
|
||||||
#{{.Issue.Index}}: {{.Issue.Title}}
|
|
||||||
------------
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<title>{{.Subject}}</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
{{if .IsMention}}
|
|
||||||
<p>
|
|
||||||
You are receiving this because @{{.Doer.Name}} mentioned you.
|
|
||||||
</p>
|
|
||||||
{{end}}
|
|
||||||
<p>
|
|
||||||
<p>
|
|
||||||
<a href="{{AppUrl}}/{{.Doer.LowerName}}">@{{.Doer.Name}}</a>
|
|
||||||
{{if not (eq .Doer.FullName "")}}
|
|
||||||
({{.Doer.FullName}})
|
|
||||||
{{end}}
|
|
||||||
{{if eq .ActionName "new"}}
|
|
||||||
created
|
|
||||||
{{else if eq .ActionName "close"}}
|
|
||||||
closed
|
|
||||||
{{else if eq .ActionName "reopen"}}
|
|
||||||
reopened
|
|
||||||
{{else}}
|
|
||||||
updated
|
|
||||||
{{end}}
|
|
||||||
<a href="{{.Link}}">{{.Repo}}#{{.Issue.Index}}</a>.
|
|
||||||
</p>
|
|
||||||
{{if not (eq .Body "")}}
|
|
||||||
<h3>Message content</h3>
|
|
||||||
<hr>
|
|
||||||
{{.Body}}
|
|
||||||
{{end}}
|
|
||||||
</p>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
<a href="{{.Link}}">View it on Gitea</a>.
|
|
||||||
</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
This template produces something along these lines:
|
|
||||||
|
|
||||||
### Subject
|
|
||||||
|
|
||||||
> [mike/stuff] @rhonda commented on pull request #38: New color palette
|
|
||||||
|
|
||||||
### Mail body
|
|
||||||
|
|
||||||
> [@rhonda](#) (Rhonda Myers) updated [mike/stuff#38](#).
|
|
||||||
>
|
|
||||||
> #### Message content
|
|
||||||
>
|
|
||||||
> \_********************************\_********************************
|
|
||||||
>
|
|
||||||
> Mike, I think we should tone down the blues a little.
|
|
||||||
> \_********************************\_********************************
|
|
||||||
>
|
|
||||||
> [View it on Gitea](#).
|
|
||||||
|
|
||||||
## Advanced
|
|
||||||
|
|
||||||
The template system contains several functions that can be used to further process and format
|
|
||||||
the messages. Here's a list of some of them:
|
|
||||||
|
|
||||||
| Name | Parameters | Available | Usage |
|
|
||||||
| ---------------- | ----------- | --------- | ------------------------------------------------------------------- |
|
|
||||||
| `AppUrl` | - | Any | Gitea's URL |
|
|
||||||
| `AppName` | - | Any | Set from `app.ini`, usually "Gitea" |
|
|
||||||
| `AppDomain` | - | Any | Gitea's host name |
|
|
||||||
| `EllipsisString` | string, int | Any | Truncates a string to the specified length; adds ellipsis as needed |
|
|
||||||
| `SanitizeHTML` | string | Body only | Sanitizes text by removing any dangerous HTML tags from it |
|
|
||||||
| `SafeHTML` | string | Body only | Takes the input as HTML, can be used for outputing raw HTML content |
|
|
||||||
|
|
||||||
These are _functions_, not metadata, so they have to be used:
|
|
||||||
|
|
||||||
```html
|
|
||||||
Like this: {{SanitizeHTML "Escape<my>text"}}
|
|
||||||
Or this: {{"Escape<my>text" | SanitizeHTML}}
|
|
||||||
Or this: {{AppUrl}}
|
|
||||||
But not like this: {{.AppUrl}}
|
|
||||||
```
|
|
|
@ -1,261 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "邮件模板"
|
|
||||||
slug: "mail-templates"
|
|
||||||
sidebar_position: 45
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/mail-templates
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "邮件模板"
|
|
||||||
sidebar_position: 45
|
|
||||||
identifier: "mail-templates"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 邮件模板
|
|
||||||
|
|
||||||
为了定制特定操作的电子邮件主题和内容,可以使用模板来自定义 Gitea。这些功能的模板位于 [`custom` 目录](administration/customizing-gitea.md) 下。
|
|
||||||
如果没有自定义的替代方案,Gitea 将使用内部模板作为默认模板。
|
|
||||||
|
|
||||||
自定义模板在 Gitea 启动时加载。对它们的更改在 Gitea 重新启动之前不会被识别。
|
|
||||||
|
|
||||||
## 支持模板的邮件通知
|
|
||||||
|
|
||||||
目前,以下通知事件使用模板:
|
|
||||||
|
|
||||||
| 操作名称 | 用途 |
|
|
||||||
| ----------- | ------------------------------------------------------------------------------------------------------------ |
|
|
||||||
| `new` | 创建了新的工单或合并请求。 |
|
|
||||||
| `comment` | 在现有工单或合并请求中创建了新的评论。 |
|
|
||||||
| `close` | 关闭了工单或合并请求。 |
|
|
||||||
| `reopen` | 重新打开了工单或合并请求。 |
|
|
||||||
| `review` | 在合并请求中进行审查的首要评论。 |
|
|
||||||
| `approve` | 对合并请求进行批准的首要评论。 |
|
|
||||||
| `reject` | 对合并请求提出更改请求的审查的首要评论。 |
|
|
||||||
| `code` | 关于合并请求的代码的单个评论。 |
|
|
||||||
| `assigned` | 用户被分配到工单或合并请求。 |
|
|
||||||
| `default` | 未包括在上述类别中的任何操作,或者当对应类别的模板不存在时使用的模板。 |
|
|
||||||
|
|
||||||
特定消息类型的模板路径为:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
custom/templates/mail/{操作类型}/{操作名称}.tmpl
|
|
||||||
```
|
|
||||||
|
|
||||||
其中 `{操作类型}` 是 `issue` 或 `pull`(针对合并请求),`{操作名称}` 是上述列出的操作名称之一。
|
|
||||||
|
|
||||||
例如,有关合并请求中的评论的电子邮件的特定模板是:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
custom/templates/mail/pull/comment.tmpl
|
|
||||||
```
|
|
||||||
|
|
||||||
然而,并不需要为每个操作类型/名称组合创建模板。
|
|
||||||
使用回退系统来选择适当的模板。在此列表中,将使用 _第一个存在的_ 模板:
|
|
||||||
|
|
||||||
- 所需**操作类型**和**操作名称**的特定模板。
|
|
||||||
- 操作类型为 `issue` 和所需**操作名称**的模板。
|
|
||||||
- 所需**操作类型**和操作名称为 `default` 的模板。
|
|
||||||
- 操作类型为` issue` 和操作名称为 `default` 的模板。
|
|
||||||
|
|
||||||
唯一必需的模板是操作类型为 `issue` 操作名称为 `default` 的模板,除非用户在 `custom` 目录中覆盖了它。
|
|
||||||
|
|
||||||
## 模板语法
|
|
||||||
|
|
||||||
邮件模板是 UTF-8 编码的文本文件,需要遵循以下格式之一:
|
|
||||||
|
|
||||||
```
|
|
||||||
用于主题行的文本和宏
|
|
||||||
------------
|
|
||||||
用于邮件正文的文本和宏
|
|
||||||
```
|
|
||||||
|
|
||||||
或者
|
|
||||||
|
|
||||||
```
|
|
||||||
用于邮件正文的文本和宏
|
|
||||||
```
|
|
||||||
|
|
||||||
指定 _主题_ 部分是可选的(因此也是虚线分隔符)。在使用时,_主题_ 和 _邮件正文_ 模板之间的分隔符需要至少三个虚线;分隔符行中不允许使用其他字符。
|
|
||||||
|
|
||||||
_主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://go.dev/pkg/text/template/) 解析,并提供了为每个通知组装的 _元数据上下文_。上下文包含以下元素:
|
|
||||||
|
|
||||||
| 名称 | 类型 | 可用性 | 用途 |
|
|
||||||
| -------------------- | ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| `.FallbackSubject` | string | 始终可用 | 默认主题行。参见下文。 |
|
|
||||||
| `.Subject` | string | 仅在正文中可用 | 解析后的 _主题_。 |
|
|
||||||
| `.Body` | string | 始终可用 | 工单、合并请求或评论的消息,从 Markdown 解析为 HTML 并进行了清理。请勿与 _邮件正文_ 混淆。 |
|
|
||||||
| `.Link` | string | 始终可用 | 源工单、合并请求或评论的地址。 |
|
|
||||||
| `.Issue` | models.Issue | 始终可用 | 产生通知的工单(或合并请求)。要获取特定于合并请求的数据(例如 `HasMerged`),可以使用 `.Issue.PullRequest`,但需要注意,如果工单 _不是_ 合并请求,则该字段将为 `nil`。 |
|
|
||||||
| `.Comment` | models.Comment | 如果适用 | 如果通知是针对添加到工单或合并请求的评论,则其中包含有关评论的信息。 |
|
|
||||||
| `.IsPull` | bool | 始终可用 | 如果邮件通知与合并请求关联(即 `.Issue.PullRequest` 不为 `nil` ),则为 `true`。 |
|
|
||||||
| `.Repo` | string | 始终可用 | 仓库的名称,包括所有者名称(例如 `mike/stuff`) |
|
|
||||||
| `.User` | models.User | 始终可用 | 事件来源仓库的所有者。要获取用户名(例如 `mike`),可以使用 `.User.Name`。 |
|
|
||||||
| `.Doer` | models.User | 始终可用 | 执行触发通知事件的操作的用户。要获取用户名(例如 `rhonda`),可以使用 `.Doer.Name`。 |
|
|
||||||
| `.IsMention` | bool | 始终可用 | 如果此通知仅是因为在评论中提到了用户而生成的,并且收件人未订阅源,则为 `true`。如果收件人已订阅工单或仓库,则为 `false`。 |
|
|
||||||
| `.SubjectPrefix` | string | 始终可用 | 如果通知是关于除工单或合并请求创建之外的其他内容,则为 `Re:`;否则为空字符串。 |
|
|
||||||
| `.ActionType` | string | 始终可用 | `"issue"` 或 `"pull"`。它将与实际的 _操作类型_ 对应,与选择的模板无关。 |
|
|
||||||
| `.ActionName` | string | 始终可用 | 它将是上述操作类型之一(`new` ,`comment` 等),并与选择的模板对应。 |
|
|
||||||
| `.ReviewComments` | []models.Comment | 始终可用 | 审查中的代码评论列表。评论文本将在 `.RenderedContent` 中,引用的代码将在 `.Patch` 中。 |
|
|
||||||
|
|
||||||
所有名称区分大小写。
|
|
||||||
|
|
||||||
### 模板中的主题部分
|
|
||||||
|
|
||||||
用于邮件主题的模板引擎是 Golang 的 [`text/template`](https://go.dev/pkg/text/template/)。
|
|
||||||
有关语法的详细信息,请参阅链接的文档。
|
|
||||||
|
|
||||||
主题构建的步骤如下:
|
|
||||||
|
|
||||||
- 根据通知类型和可用的模板选择一个模板。
|
|
||||||
- 解析并解析模板(例如,将 `{{.Issue.Index}}` 转换为工单或合并请求的编号)。
|
|
||||||
- 将所有空格字符(例如 `TAB`,`LF` 等)转换为普通空格。
|
|
||||||
- 删除所有前导、尾随和多余的空格。
|
|
||||||
- 将字符串截断为前 256 个字母(字符)。
|
|
||||||
|
|
||||||
如果最终结果为空字符串,**或者**没有可用的主题模板(即所选模板不包含主题部分),将使用Gitea的**内部默认值**。
|
|
||||||
|
|
||||||
内部默认(回退)主题相当于:
|
|
||||||
|
|
||||||
```
|
|
||||||
{{.SubjectPrefix}}[{{.Repo}}] {{.Issue.Title}} (#{{.Issue.Index}})
|
|
||||||
```
|
|
||||||
|
|
||||||
例如:`Re: [mike/stuff] New color palette (#38)`
|
|
||||||
|
|
||||||
即使存在有效的主题模板,Gitea的默认主题也可以在模板的元数据中作为 `.FallbackSubject` 找到。
|
|
||||||
|
|
||||||
### 模板中的邮件正文部分
|
|
||||||
|
|
||||||
用于邮件正文的模板引擎是 Golang 的 [`html/template`](https://go.dev/pkg/html/template/)。
|
|
||||||
有关语法的详细信息,请参阅链接的文档。
|
|
||||||
|
|
||||||
邮件正文在邮件主题之后进行解析,因此还有一个额外的 _元数据_ 字段,即在考虑所有情况之后实际呈现的主题。
|
|
||||||
|
|
||||||
期望的结果是 HTML(包括结构元素,如`<html>`,`<body>`等)。可以通过 `<style>` 块、`class` 和 `style` 属性进行样式设置。但是,`html/template` 会进行一些 [自动转义](https://go.dev/pkg/html/template/#hdr-Contexts),需要考虑这一点。
|
|
||||||
|
|
||||||
不支持附件(例如图像或外部样式表)。但是,也可以引用其他模板,例如以集中方式提供 `<style>` 元素的内容。外部模板必须放置在 `custom/mail` 下,并相对于该目录引用。例如,可以使用 `{{template styles/base}}` 包含 `custom/mail/styles/base.tmpl`。
|
|
||||||
|
|
||||||
邮件以 `Content-Type: multipart/alternative` 发送,因此正文以 HTML 和文本格式发送。通过剥离 HTML 标记来获取文本版本。
|
|
||||||
|
|
||||||
## 故障排除
|
|
||||||
|
|
||||||
邮件的呈现方式直接取决于邮件应用程序的功能。许多邮件客户端甚至不支持 HTML,因此显示生成邮件中包含的文本版本。
|
|
||||||
|
|
||||||
如果模板无法呈现,则只有在发送邮件时才会注意到。
|
|
||||||
如果主题模板失败,将使用默认主题,如果从 _邮件正文_ 中成功呈现了任何内容,则将使用该内容,忽略其他内容。
|
|
||||||
|
|
||||||
如果遇到问题,请检查 [Gitea的日志](administration/logging-config.md) 以获取错误消息。
|
|
||||||
|
|
||||||
## 示例
|
|
||||||
|
|
||||||
`custom/templates/mail/issue/default.tmpl`:
|
|
||||||
|
|
||||||
```html
|
|
||||||
[{{.Repo}}] @{{.Doer.Name}}
|
|
||||||
{{if eq .ActionName "new"}}
|
|
||||||
创建了
|
|
||||||
{{else if eq .ActionName "comment"}}
|
|
||||||
评论了
|
|
||||||
{{else if eq .ActionName "close"}}
|
|
||||||
关闭了
|
|
||||||
{{else if eq .ActionName "reopen"}}
|
|
||||||
重新打开了
|
|
||||||
{{else}}
|
|
||||||
更新了
|
|
||||||
{{end}}
|
|
||||||
{{if eq .ActionType "issue"}}
|
|
||||||
工单
|
|
||||||
{{else}}
|
|
||||||
合并请求
|
|
||||||
{{end}}
|
|
||||||
#{{.Issue.Index}}: {{.Issue.Title}}
|
|
||||||
------------
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<title>{{.Subject}}</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
{{if .IsMention}}
|
|
||||||
<p>
|
|
||||||
您收到此邮件是因为 @{{.Doer.Name}} 提到了您。
|
|
||||||
</p>
|
|
||||||
{{end}}
|
|
||||||
<p>
|
|
||||||
<p>
|
|
||||||
<a href="{{AppUrl}}/{{.Doer.LowerName}}">@{{.Doer.Name}}</a>
|
|
||||||
{{if not (eq .Doer.FullName "")}}
|
|
||||||
({{.Doer.FullName}})
|
|
||||||
{{end}}
|
|
||||||
{{if eq .ActionName "new"}}
|
|
||||||
创建了
|
|
||||||
{{else if eq .ActionName "close"}}
|
|
||||||
关闭了
|
|
||||||
{{else if eq .ActionName "reopen"}}
|
|
||||||
重新打开了
|
|
||||||
{{else}}
|
|
||||||
更新了
|
|
||||||
{{end}}
|
|
||||||
<a href="{{.Link}}">{{.Repo}}#{{.Issue.Index}}</a>。
|
|
||||||
</p>
|
|
||||||
{{if not (eq .Body "")}}
|
|
||||||
<h3>消息内容:</h3>
|
|
||||||
<hr>
|
|
||||||
{{.Body}}
|
|
||||||
{{end}}
|
|
||||||
</p>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
<a href="{{.Link}}">在 Gitea 上查看</a>。
|
|
||||||
</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
该模板将生成以下内容:
|
|
||||||
|
|
||||||
### 主题
|
|
||||||
|
|
||||||
> [mike/stuff] @rhonda 在合并请求 #38 上进行了评论:New color palette
|
|
||||||
|
|
||||||
### 邮件正文
|
|
||||||
|
|
||||||
> [@rhonda](#)(Rhonda Myers)更新了 [mike/stuff#38](#)。
|
|
||||||
>
|
|
||||||
> #### 消息内容
|
|
||||||
>
|
|
||||||
> \_********************************\_********************************
|
|
||||||
>
|
|
||||||
> Mike, I think we should tone down the blues a little.
|
|
||||||
>
|
|
||||||
> \_********************************\_********************************
|
|
||||||
>
|
|
||||||
> [在 Gitea 上查看](#)。
|
|
||||||
|
|
||||||
## 高级用法
|
|
||||||
|
|
||||||
模板系统包含一些函数,可用于进一步处理和格式化消息。以下是其中一些函数的列表:
|
|
||||||
|
|
||||||
| 函数名 | 参数 | 可用于 | 用法 |
|
|
||||||
|------------------| ----------- | ------------ | ------------------------------ |
|
|
||||||
| `AppUrl` | - | 任何地方 | Gitea 的 URL |
|
|
||||||
| `AppName` | - | 任何地方 | 从 `app.ini` 中设置,通常为 "Gitea" |
|
|
||||||
| `AppDomain` | - | 任何地方 | Gitea 的主机名 |
|
|
||||||
| `EllipsisString` | string, int | 任何地方 | 将字符串截断为指定长度;根据需要添加省略号 |
|
|
||||||
| `SanitizeHTML` | string | 仅正文部分 | 通过删除其中的危险 HTML 标签对文本进行清理 |
|
|
||||||
| `SafeHTML` | string | 仅正文部分 | 将输入作为 HTML 处理;可用于输出原始的 HTML 内容 |
|
|
||||||
|
|
||||||
这些都是 _函数_,而不是元数据,因此必须按以下方式使用:
|
|
||||||
|
|
||||||
```html
|
|
||||||
像这样使用: {{SanitizeHTML "Escape<my>text"}}
|
|
||||||
或者这样使用: {{"Escape<my>text" | SanitizeHTML}}
|
|
||||||
或者这样使用: {{AppUrl}}
|
|
||||||
但不要像这样使用: {{.AppUrl}}
|
|
||||||
```
|
|
|
@ -1,65 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-09-06T01:35:00-03:00"
|
|
||||||
title: "Repository indexer"
|
|
||||||
slug: "repo-indexer"
|
|
||||||
sidebar_position: 45
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/repo-indexer
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Repository indexer"
|
|
||||||
sidebar_position: 45
|
|
||||||
identifier: "repo-indexer"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Repository indexer
|
|
||||||
|
|
||||||
## Builtin repository code search without indexer
|
|
||||||
|
|
||||||
Users could do repository-level code search without setting up a repository indexer.
|
|
||||||
The builtin code search is based on the `git grep` command, which is fast and efficient for small repositories.
|
|
||||||
Better code search support could be achieved by setting up the repository indexer.
|
|
||||||
|
|
||||||
## Setting up the repository indexer
|
|
||||||
|
|
||||||
Gitea can search through the files of the repositories by enabling this function in your [`app.ini`](administration/config-cheat-sheet.md):
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[indexer]
|
|
||||||
; ...
|
|
||||||
REPO_INDEXER_ENABLED = true
|
|
||||||
REPO_INDEXER_PATH = indexers/repos.bleve
|
|
||||||
MAX_FILE_SIZE = 1048576
|
|
||||||
REPO_INDEXER_INCLUDE =
|
|
||||||
REPO_INDEXER_EXCLUDE = resources/bin/**
|
|
||||||
```
|
|
||||||
|
|
||||||
Please bear in mind that indexing the contents can consume a lot of system resources, especially when the index is created for the first time or globally updated (e.g. after upgrading Gitea).
|
|
||||||
|
|
||||||
### Choosing the files for indexing by size
|
|
||||||
|
|
||||||
The `MAX_FILE_SIZE` option will make the indexer skip all files larger than the specified value.
|
|
||||||
|
|
||||||
### Choosing the files for indexing by path
|
|
||||||
|
|
||||||
Gitea applies glob pattern matching from the [`gobwas/glob` library](https://github.com/gobwas/glob) to choose which files will be included in the index.
|
|
||||||
|
|
||||||
Limiting the list of files prevents the indexes from becoming polluted with derived or irrelevant files (e.g. lss, sym, map, etc.), so the search results are more relevant. It can also help reduce the index size.
|
|
||||||
|
|
||||||
`REPO_INDEXER_EXCLUDE_VENDORED` (default: true) excludes vendored files from index.
|
|
||||||
|
|
||||||
`REPO_INDEXER_INCLUDE` (default: empty) is a comma separated list of glob patterns to **include** in the index. An empty list means "_include all files_".
|
|
||||||
`REPO_INDEXER_EXCLUDE` (default: empty) is a comma separated list of glob patterns to **exclude** from the index. Files that match this list will not be indexed. `REPO_INDEXER_EXCLUDE` takes precedence over `REPO_INDEXER_INCLUDE`.
|
|
||||||
|
|
||||||
Pattern matching works as follows:
|
|
||||||
|
|
||||||
- To match all files with a `.txt` extension no matter what directory, use `**.txt`.
|
|
||||||
- To match all files with a `.txt` extension _only at the root level of the repository_, use `*.txt`.
|
|
||||||
- To match all files inside `resources/bin` and below, use `resources/bin/**`.
|
|
||||||
- To match all files _immediately inside_ `resources/bin`, use `resources/bin/*`.
|
|
||||||
- To match all files named `Makefile`, use `**Makefile`.
|
|
||||||
- Matching a directory has no effect; the pattern `resources/bin` will not include/exclude files inside that directory; `resources/bin/**` will.
|
|
||||||
- All files and patterns are normalized to lower case, so `**Makefile`, `**makefile` and `**MAKEFILE` are equivalent.
|
|
|
@ -1,59 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "仓库索引器"
|
|
||||||
slug: "repo-indexer"
|
|
||||||
sidebar_position: 45
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/repo-indexer
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "仓库索引器"
|
|
||||||
sidebar_position: 45
|
|
||||||
identifier: "repo-indexer"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 仓库索引器
|
|
||||||
|
|
||||||
## 设置仓库索引器
|
|
||||||
|
|
||||||
通过在您的 [`app.ini`](administration/config-cheat-sheet.md) 中启用此功能,Gitea 可以通过仓库的文件进行搜索:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[indexer]
|
|
||||||
; ...
|
|
||||||
REPO_INDEXER_ENABLED = true
|
|
||||||
REPO_INDEXER_PATH = indexers/repos.bleve
|
|
||||||
MAX_FILE_SIZE = 1048576
|
|
||||||
REPO_INDEXER_INCLUDE =
|
|
||||||
REPO_INDEXER_EXCLUDE = resources/bin/**
|
|
||||||
```
|
|
||||||
|
|
||||||
请记住,索引内容可能会消耗大量系统资源,特别是在首次创建索引或全局更新索引时(例如升级 Gitea 之后)。
|
|
||||||
|
|
||||||
### 按大小选择要索引的文件
|
|
||||||
|
|
||||||
`MAX_FILE_SIZE` 选项将使索引器跳过所有大于指定值的文件。
|
|
||||||
|
|
||||||
### 按路径选择要索引的文件
|
|
||||||
|
|
||||||
Gitea使用 [`gobwas/glob` 库](https://github.com/gobwas/glob) 中的 glob 模式匹配来选择要包含在索引中的文件。
|
|
||||||
|
|
||||||
限制文件列表可以防止索引被派生或无关的文件(例如 lss、sym、map 等)污染,从而使搜索结果更相关。这还有助于减小索引的大小。
|
|
||||||
|
|
||||||
`REPO_INDEXER_EXCLUDE_VENDORED`(默认值为 true)将排除供应商文件不包含在索引中。
|
|
||||||
|
|
||||||
`REPO_INDEXER_INCLUDE`(默认值为空)是一个逗号分隔的 glob 模式列表,用于在索引中**包含**的文件。空列表表示“_包含所有文件_”。
|
|
||||||
`REPO_INDEXER_EXCLUDE`(默认值为空)是一个逗号分隔的 glob 模式列表,用于从索引中**排除**的文件。与该列表匹配的文件将不会被索引。`REPO_INDEXER_EXCLUDE` 优先于 `REPO_INDEXER_INCLUDE`。
|
|
||||||
|
|
||||||
模式匹配工作方式如下:
|
|
||||||
|
|
||||||
- 要匹配所有带有 `.txt` 扩展名的文件,无论在哪个目录中,请使用 `**.txt`。
|
|
||||||
- 要匹配仅在仓库的根级别中具有 `.txt` 扩展名的所有文件,请使用 `*.txt`。
|
|
||||||
- 要匹配 `resources/bin` 目录及其子目录中的所有文件,请使用 `resources/bin/**`。
|
|
||||||
- 要匹配位于 `resources/bin` 目录下的所有文件,请使用 `resources/bin/*`。
|
|
||||||
- 要匹配所有名为 `Makefile` 的文件,请使用 `**Makefile`。
|
|
||||||
- 匹配目录没有效果;模式 `resources/bin` 不会包含/排除该目录中的文件;`resources/bin/**` 会。
|
|
||||||
- 所有文件和模式都规范化为小写,因此 `**Makefile`、`**makefile` 和 `**MAKEFILE` 是等效的。
|
|
|
@ -1,389 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-05-22T11:00:00+00:00"
|
|
||||||
title: "Reverse Proxies"
|
|
||||||
slug: "reverse-proxies"
|
|
||||||
sidebar_position: 16
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/reverse-proxies
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Reverse Proxies"
|
|
||||||
sidebar_position: 16
|
|
||||||
identifier: "reverse-proxies"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Reverse Proxies
|
|
||||||
|
|
||||||
## Nginx
|
|
||||||
|
|
||||||
If you want Nginx to serve your Gitea instance, add the following `server` section to the `http` section of `nginx.conf`:
|
|
||||||
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name git.example.com;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
client_max_body_size 512M;
|
|
||||||
proxy_pass http://localhost:3000;
|
|
||||||
proxy_set_header Connection $http_connection;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Resolving Error: 413 Request Entity Too Large
|
|
||||||
|
|
||||||
This error indicates nginx is configured to restrict the file upload size,
|
|
||||||
it affects attachment uploading, form posting, package uploading and LFS pushing, etc.
|
|
||||||
You can fine tune the `client_max_body_size` option according to [nginx document](http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size).
|
|
||||||
|
|
||||||
## Nginx with a sub-path
|
|
||||||
|
|
||||||
In case you already have a site, and you want Gitea to share the domain name, you can setup Nginx to serve Gitea under a sub-path by adding the following `server` section inside the `http` section of `nginx.conf`:
|
|
||||||
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name git.example.com;
|
|
||||||
|
|
||||||
# Note: Trailing slash
|
|
||||||
location /gitea/ {
|
|
||||||
client_max_body_size 512M;
|
|
||||||
|
|
||||||
# make nginx use unescaped URI, keep "%2F" as is
|
|
||||||
rewrite ^ $request_uri;
|
|
||||||
rewrite ^/gitea(/.*) $1 break;
|
|
||||||
proxy_pass http://127.0.0.1:3000$uri;
|
|
||||||
|
|
||||||
# other common HTTP headers, see the "Nginx" config section above
|
|
||||||
proxy_set_header ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Then you **MUST** set something like `[server] ROOT_URL = http://git.example.com/git/` correctly in your configuration.
|
|
||||||
|
|
||||||
## Nginx and serve static resources directly
|
|
||||||
|
|
||||||
We can tune the performance in splitting requests into categories static and dynamic.
|
|
||||||
|
|
||||||
CSS files, JavaScript files, images and web fonts are static content.
|
|
||||||
The front page, a repository view or issue list is dynamic content.
|
|
||||||
|
|
||||||
Nginx can serve static resources directly and proxy only the dynamic requests to Gitea.
|
|
||||||
Nginx is optimized for serving static content, while the proxying of large responses might be the opposite of that
|
|
||||||
(see [https://serverfault.com/q/587386](https://serverfault.com/q/587386)).
|
|
||||||
|
|
||||||
Download a snapshot of the Gitea source repository to `/path/to/gitea/`.
|
|
||||||
After this, run `make frontend` in the repository directory to generate the static resources. We are only interested in the `public/` directory for this task, so you can delete the rest.
|
|
||||||
(You will need to have [Node with npm](https://nodejs.org/en/download/) and `make` installed to generate the static resources)
|
|
||||||
|
|
||||||
Depending on the scale of your user base, you might want to split the traffic to two distinct servers,
|
|
||||||
or use a cdn for the static files.
|
|
||||||
|
|
||||||
### Single node and single domain
|
|
||||||
|
|
||||||
Set `[server] STATIC_URL_PREFIX = /_/static` in your configuration.
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name git.example.com;
|
|
||||||
|
|
||||||
location /_/static/assets/ {
|
|
||||||
alias /path/to/gitea/public/;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://localhost:3000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Two nodes and two domains
|
|
||||||
|
|
||||||
Set `[server] STATIC_URL_PREFIX = http://cdn.example.com/gitea` in your configuration.
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
# application server running Gitea
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name git.example.com;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://localhost:3000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
# static content delivery server
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name cdn.example.com;
|
|
||||||
|
|
||||||
location /gitea/ {
|
|
||||||
alias /path/to/gitea/public/;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Apache HTTPD
|
|
||||||
|
|
||||||
If you want Apache HTTPD to serve your Gitea instance, you can add the following to your Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu):
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
<VirtualHost *:80>
|
|
||||||
...
|
|
||||||
ProxyPreserveHost On
|
|
||||||
ProxyRequests off
|
|
||||||
AllowEncodedSlashes NoDecode
|
|
||||||
ProxyPass / http://localhost:3000/ nocanon
|
|
||||||
</VirtualHost>
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`.
|
|
||||||
|
|
||||||
If you wish to use Let's Encrypt with webroot validation, add the line `ProxyPass /.well-known !` before `ProxyPass` to disable proxying these requests to Gitea.
|
|
||||||
|
|
||||||
## Apache HTTPD with a sub-path
|
|
||||||
|
|
||||||
In case you already have a site, and you want Gitea to share the domain name, you can setup Apache HTTPD to serve Gitea under a sub-path by adding the following to you Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu):
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
<VirtualHost *:80>
|
|
||||||
...
|
|
||||||
<Proxy *>
|
|
||||||
Order allow,deny
|
|
||||||
Allow from all
|
|
||||||
</Proxy>
|
|
||||||
AllowEncodedSlashes NoDecode
|
|
||||||
# Note: no trailing slash after either /git or port
|
|
||||||
ProxyPass /git http://localhost:3000 nocanon
|
|
||||||
</VirtualHost>
|
|
||||||
```
|
|
||||||
|
|
||||||
Then you **MUST** set something like `[server] ROOT_URL = http://git.example.com/git/` correctly in your configuration.
|
|
||||||
|
|
||||||
Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`.
|
|
||||||
|
|
||||||
## Caddy
|
|
||||||
|
|
||||||
If you want Caddy to serve your Gitea instance, you can add the following server block to your Caddyfile:
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
git.example.com {
|
|
||||||
reverse_proxy localhost:3000
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Caddy with a sub-path
|
|
||||||
|
|
||||||
In case you already have a site, and you want Gitea to share the domain name, you can setup Caddy to serve Gitea under a sub-path by adding the following to your server block in your Caddyfile:
|
|
||||||
|
|
||||||
```apacheconf
|
|
||||||
git.example.com {
|
|
||||||
route /git/* {
|
|
||||||
uri strip_prefix /git
|
|
||||||
reverse_proxy localhost:3000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.
|
|
||||||
|
|
||||||
## IIS
|
|
||||||
|
|
||||||
If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite as reverse proxy.
|
|
||||||
|
|
||||||
1. Setup an empty website in IIS, named let's say, `Gitea Proxy`.
|
|
||||||
2. Follow the first two steps in [Microsoft's Technical Community Guide to Setup IIS with URL Rewrite](https://techcommunity.microsoft.com/t5/iis-support-blog/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world/ba-p/846222#M343). That is:
|
|
||||||
|
|
||||||
- Install Application Request Routing (ARR for short) either by using the Microsoft Web Platform Installer 5.1 (WebPI) or downloading the extension from [IIS.net](https://www.iis.net/downloads/microsoft/application-request-routing)
|
|
||||||
- Once the module is installed in IIS, you will see a new Icon in the IIS Administration Console called URL Rewrite.
|
|
||||||
- Open the IIS Manager Console and click on the `Gitea Proxy` Website from the tree view on the left. Select and double click the URL Rewrite Icon from the middle pane to load the URL Rewrite interface.
|
|
||||||
- Choose the `Add Rule` action from the right pane of the management console and select the `Reverse Proxy Rule` from the `Inbound and Outbound Rules` category.
|
|
||||||
- In the Inbound Rules section, set the server name to be the host that Gitea is running on with its port. e.g. if you are running Gitea on the localhost with port 3000, the following should work: `127.0.0.1:3000`
|
|
||||||
- Enable SSL Offloading
|
|
||||||
- In the Outbound Rules, ensure `Rewrite the domain names of the links in HTTP response` is set and set the `From:` field as above and the `To:` to your external hostname, say: `git.example.com`
|
|
||||||
- Now edit the `web.config` for your website to match the following: (changing `127.0.0.1:3000` and `git.example.com` as appropriate)
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration>
|
|
||||||
<system.web>
|
|
||||||
<httpRuntime requestPathInvalidCharacters="" />
|
|
||||||
</system.web>
|
|
||||||
<system.webServer>
|
|
||||||
<security>
|
|
||||||
<requestFiltering>
|
|
||||||
<hiddenSegments>
|
|
||||||
<clear />
|
|
||||||
</hiddenSegments>
|
|
||||||
<denyUrlSequences>
|
|
||||||
<clear />
|
|
||||||
</denyUrlSequences>
|
|
||||||
<fileExtensions allowUnlisted="true">
|
|
||||||
<clear />
|
|
||||||
</fileExtensions>
|
|
||||||
</requestFiltering>
|
|
||||||
</security>
|
|
||||||
<rewrite>
|
|
||||||
<rules useOriginalURLEncoding="false">
|
|
||||||
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
|
|
||||||
<match url="(.*)" />
|
|
||||||
<action type="Rewrite" url="http://127.0.0.1:3000{UNENCODED_URL}" />
|
|
||||||
<serverVariables>
|
|
||||||
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" />
|
|
||||||
<set name="HTTP_ACCEPT_ENCODING" value="" />
|
|
||||||
</serverVariables>
|
|
||||||
</rule>
|
|
||||||
</rules>
|
|
||||||
<outboundRules>
|
|
||||||
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
|
|
||||||
<!-- set the pattern correctly here - if you only want to accept http or https -->
|
|
||||||
<!-- change the pattern and the action value as appropriate -->
|
|
||||||
<match filterByTags="A, Form, Img" pattern="^http(s)?://127.0.0.1:3000/(.*)" />
|
|
||||||
<action type="Rewrite" value="http{R:1}://git.example.com/{R:2}" />
|
|
||||||
</rule>
|
|
||||||
<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
|
|
||||||
<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
|
|
||||||
<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
|
|
||||||
</rule>
|
|
||||||
<preConditions>
|
|
||||||
<preCondition name="ResponseIsHtml1">
|
|
||||||
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
|
|
||||||
</preCondition>
|
|
||||||
<preCondition name="NeedsRestoringAcceptEncoding">
|
|
||||||
<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />
|
|
||||||
</preCondition>
|
|
||||||
</preConditions>
|
|
||||||
</outboundRules>
|
|
||||||
</rewrite>
|
|
||||||
<urlCompression doDynamicCompression="true" />
|
|
||||||
<handlers>
|
|
||||||
<clear />
|
|
||||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
|
|
||||||
</handlers>
|
|
||||||
<!-- Map all extensions to the same MIME type, so all files can be
|
|
||||||
downloaded. -->
|
|
||||||
<staticContent>
|
|
||||||
<clear />
|
|
||||||
<mimeMap fileExtension="*" mimeType="application/octet-stream" />
|
|
||||||
</staticContent>
|
|
||||||
</system.webServer>
|
|
||||||
</configuration>
|
|
||||||
```
|
|
||||||
|
|
||||||
## HAProxy
|
|
||||||
|
|
||||||
If you want HAProxy to serve your Gitea instance, you can add the following to your HAProxy configuration
|
|
||||||
|
|
||||||
add an acl in the frontend section to redirect calls to gitea.example.com to the correct backend
|
|
||||||
|
|
||||||
```
|
|
||||||
frontend http-in
|
|
||||||
...
|
|
||||||
acl acl_gitea hdr(host) -i gitea.example.com
|
|
||||||
use_backend gitea if acl_gitea
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
add the previously defined backend section
|
|
||||||
|
|
||||||
```
|
|
||||||
backend gitea
|
|
||||||
server localhost:3000 check
|
|
||||||
```
|
|
||||||
|
|
||||||
If you redirect the http content to https, the configuration work the same way, just remember that the connection between HAProxy and Gitea will be done via http so you do not have to enable https in Gitea's configuration.
|
|
||||||
|
|
||||||
## HAProxy with a sub-path
|
|
||||||
|
|
||||||
In case you already have a site, and you want Gitea to share the domain name, you can setup HAProxy to serve Gitea under a sub-path by adding the following to you HAProxy configuration:
|
|
||||||
|
|
||||||
```
|
|
||||||
frontend http-in
|
|
||||||
...
|
|
||||||
acl acl_gitea path_beg /gitea
|
|
||||||
use_backend gitea if acl_gitea
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
With that configuration http://example.com/gitea/ will redirect to your Gitea instance.
|
|
||||||
|
|
||||||
then for the backend section
|
|
||||||
|
|
||||||
```
|
|
||||||
backend gitea
|
|
||||||
http-request replace-path /gitea\/?(.*) \/\1
|
|
||||||
server localhost:3000 check
|
|
||||||
```
|
|
||||||
|
|
||||||
The added http-request will automatically add a trailing slash if needed and internally remove /gitea from the path to allow it to work correctly with Gitea by setting properly http://example.com/gitea as the root.
|
|
||||||
|
|
||||||
Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration.
|
|
||||||
|
|
||||||
## Traefik
|
|
||||||
|
|
||||||
If you want traefik to serve your Gitea instance, you can add the following label section to your `docker-compose.yaml` (Assuming the provider is docker).
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
gitea:
|
|
||||||
image: gitea/gitea
|
|
||||||
...
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.gitea.rule=Host(`example.com`)"
|
|
||||||
- "traefik.http.services.gitea-websecure.loadbalancer.server.port=3000"
|
|
||||||
```
|
|
||||||
|
|
||||||
This config assumes that you are handling HTTPS on the traefik side and using HTTP between Gitea and traefik.
|
|
||||||
|
|
||||||
## Traefik with a sub-path
|
|
||||||
|
|
||||||
In case you already have a site, and you want Gitea to share the domain name, you can setup Traefik to serve Gitea under a sub-path by adding the following to your `docker-compose.yaml` (Assuming the provider is docker) :
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
gitea:
|
|
||||||
image: gitea/gitea
|
|
||||||
...
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.gitea.rule=Host(`example.com`) && PathPrefix(`/gitea`)"
|
|
||||||
- "traefik.http.services.gitea-websecure.loadbalancer.server.port=3000"
|
|
||||||
- "traefik.http.middlewares.gitea-stripprefix.stripprefix.prefixes=/gitea"
|
|
||||||
- "traefik.http.routers.gitea.middlewares=gitea-stripprefix"
|
|
||||||
```
|
|
||||||
|
|
||||||
This config assumes that you are handling HTTPS on the traefik side and using HTTP between Gitea and traefik.
|
|
||||||
|
|
||||||
Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration.
|
|
||||||
|
|
||||||
## General sub-path configuration
|
|
||||||
|
|
||||||
Usually it's not recommended to put Gitea in a sub-path, it's not widely used and may have some issues in rare cases.
|
|
||||||
|
|
||||||
If you really need to do so, to make Gitea works with sub-path (eg: `http://example.com/gitea/`), here are the requirements:
|
|
||||||
|
|
||||||
1. Set `[server] ROOT_URL = http://example.com/gitea/` in your `app.ini` file.
|
|
||||||
2. Make the reverse-proxy pass `http://example.com/gitea/foo` to `http://gitea-server:3000/foo`.
|
|
||||||
3. Make sure the reverse-proxy not decode the URI, the request `http://example.com/gitea/a%2Fb` should be passed as `http://gitea-server:3000/a%2Fb`.
|
|
||||||
|
|
||||||
## Docker / Container Registry
|
|
||||||
|
|
||||||
The container registry uses a fixed sub-path `/v2` which can't be changed.
|
|
||||||
Even if you deploy Gitea with a different sub-path, `/v2` will be used by the `docker` client.
|
|
||||||
Therefore you may need to add an additional route to your reverse proxy configuration.
|
|
|
@ -1,136 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-05-22T11:00:00+00:00"
|
|
||||||
title: "反向代理"
|
|
||||||
slug: "reverse-proxies"
|
|
||||||
sidebar_position: 16
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/reverse-proxies
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "反向代理"
|
|
||||||
sidebar_position: 16
|
|
||||||
identifier: "reverse-proxies"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 反向代理
|
|
||||||
|
|
||||||
## 使用 Nginx 作为反向代理服务
|
|
||||||
|
|
||||||
如果您想使用 Nginx 作为 Gitea 的反向代理服务,您可以参照以下 `nginx.conf` 配置中 `server` 的 `http` 部分:
|
|
||||||
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name git.example.com;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://localhost:3000;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用 Nginx 作为反向代理服务并将 Gitea 路由至一个子路径
|
|
||||||
|
|
||||||
如果您已经有一个域名并且想与 Gitea 共享该域名,您可以增加以下 `nginx.conf` 配置中 `server` 的 `http` 部分,为 Gitea 添加路由规则:
|
|
||||||
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name git.example.com;
|
|
||||||
|
|
||||||
# 注意: /git/ 最后需要有一个路径符号
|
|
||||||
location /git/ {
|
|
||||||
# 注意: 反向代理后端 URL 的最后需要有一个路径符号
|
|
||||||
proxy_pass http://localhost:3000/;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
然后您**必须**在 Gitea 的配置文件中正确的添加类似 `[server] ROOT_URL = http://git.example.com/git/` 的配置项。
|
|
||||||
|
|
||||||
## 使用 Apache HTTPD 作为反向代理服务
|
|
||||||
|
|
||||||
如果您想使用 Apache HTTPD 作为 Gitea 的反向代理服务,您可以为您的 Apache HTTPD 作如下配置(在 Ubuntu 中,配置文件通常在 `/etc/apache2/httpd.conf` 目录下):
|
|
||||||
|
|
||||||
```
|
|
||||||
<VirtualHost *:80>
|
|
||||||
...
|
|
||||||
ProxyPreserveHost On
|
|
||||||
ProxyRequests off
|
|
||||||
AllowEncodedSlashes NoDecode
|
|
||||||
ProxyPass / http://localhost:3000/ nocanon
|
|
||||||
</VirtualHost>
|
|
||||||
```
|
|
||||||
|
|
||||||
注:必须启用以下 Apache HTTPD 组件:`proxy`, `proxy_http`
|
|
||||||
|
|
||||||
## 使用 Apache HTTPD 作为反向代理服务并将 Gitea 路由至一个子路径
|
|
||||||
|
|
||||||
如果您已经有一个域名并且想与 Gitea 共享该域名,您可以增加以下配置为 Gitea 添加路由规则(在 Ubuntu 中,配置文件通常在 `/etc/apache2/httpd.conf` 目录下):
|
|
||||||
|
|
||||||
```
|
|
||||||
<VirtualHost *:80>
|
|
||||||
...
|
|
||||||
<Proxy *>
|
|
||||||
Order allow,deny
|
|
||||||
Allow from all
|
|
||||||
</Proxy>
|
|
||||||
AllowEncodedSlashes NoDecode
|
|
||||||
# 注意: 路径和 URL 后面都不要写路径符号 '/'
|
|
||||||
ProxyPass /git http://localhost:3000 nocanon
|
|
||||||
</VirtualHost>
|
|
||||||
```
|
|
||||||
|
|
||||||
然后您**必须**在 Gitea 的配置文件中正确的添加类似 `[server] ROOT_URL = http://git.example.com/git/` 的配置项。
|
|
||||||
|
|
||||||
注:必须启用以下 Apache HTTPD 组件:`proxy`, `proxy_http`
|
|
||||||
|
|
||||||
## 使用 Caddy 作为反向代理服务
|
|
||||||
|
|
||||||
如果您想使用 Caddy 作为 Gitea 的反向代理服务,您可以在 `Caddyfile` 中添加如下配置:
|
|
||||||
|
|
||||||
```
|
|
||||||
git.example.com {
|
|
||||||
proxy / http://localhost:3000
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用 Caddy 作为反向代理服务并将 Gitea 路由至一个子路径
|
|
||||||
|
|
||||||
如果您已经有一个域名并且想与 Gitea 共享该域名,您可以在您的 `Caddyfile` 文件中增加以下配置,为 Gitea 添加路由规则:
|
|
||||||
|
|
||||||
```
|
|
||||||
git.example.com {
|
|
||||||
# 注意: 路径 /git/ 最后需要有路径符号
|
|
||||||
proxy /git/ http://localhost:3000
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
然后您**必须**在 Gitea 的配置文件中正确的添加类似 `[server] ROOT_URL = http://git.example.com/git/` 的配置项。
|
|
||||||
|
|
||||||
## 使用 Traefik 作为反向代理服务
|
|
||||||
|
|
||||||
如果您想使用 traefik 作为 Gitea 的反向代理服务,您可以在 `docker-compose.yaml` 中添加 label 部分(假设使用 docker 作为 traefik 的 provider):
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
gitea:
|
|
||||||
image: gitea/gitea
|
|
||||||
...
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.gitea.rule=Host(`example.com`)"
|
|
||||||
- "traefik.http.services.gitea-websecure.loadbalancer.server.port=3000"
|
|
||||||
```
|
|
||||||
|
|
||||||
这份配置假设您使用 traefik 来处理 HTTPS 服务,并在其和 Gitea 之间使用 HTTP 进行通信。
|
|
|
@ -1,40 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-12-31T13:55:00+05:00"
|
|
||||||
title: "Search Engines Indexation"
|
|
||||||
slug: "search-engines-indexation"
|
|
||||||
sidebar_position: 60
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/search-engines-indexation
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "Search Engines Indexation"
|
|
||||||
sidebar_position: 60
|
|
||||||
identifier: "search-engines-indexation"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Search engines indexation of your Gitea installation
|
|
||||||
|
|
||||||
By default your Gitea installation will be indexed by search engines.
|
|
||||||
If you don't want your repository to be visible for search engines read further.
|
|
||||||
|
|
||||||
## Block search engines indexation using robots.txt
|
|
||||||
|
|
||||||
To make Gitea serve a custom `robots.txt` (default: empty 404) for top level installations,
|
|
||||||
create a file with path `public/robots.txt` in the [`custom` folder or `CustomPath`](administration/customizing-gitea.md)
|
|
||||||
|
|
||||||
Examples on how to configure the `robots.txt` can be found at [https://moz.com/learn/seo/robotstxt](https://moz.com/learn/seo/robotstxt).
|
|
||||||
|
|
||||||
```txt
|
|
||||||
User-agent: *
|
|
||||||
Disallow: /
|
|
||||||
```
|
|
||||||
|
|
||||||
If you installed Gitea in a subdirectory, you will need to create or edit the `robots.txt` in the top level directory.
|
|
||||||
|
|
||||||
```txt
|
|
||||||
User-agent: *
|
|
||||||
Disallow: /gitea/
|
|
||||||
```
|
|
|
@ -1,39 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "搜索引擎索引"
|
|
||||||
slug: "search-engines-indexation"
|
|
||||||
sidebar_position: 60
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/search-engines-indexation
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "搜索引擎索引"
|
|
||||||
sidebar_position: 60
|
|
||||||
identifier: "search-engines-indexation"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Gitea 安装的搜索引擎索引
|
|
||||||
|
|
||||||
默认情况下,您的 Gitea 安装将被搜索引擎索引。
|
|
||||||
如果您不希望您的仓库对搜索引擎可见,请进一步阅读。
|
|
||||||
|
|
||||||
## 使用 robots.txt 阻止搜索引擎索引
|
|
||||||
|
|
||||||
为了使 Gitea 为顶级安装提供自定义的`robots.txt`(默认为空的 404),请在 [`custom`文件夹或`CustomPath`](administration/customizing-gitea.md)中创建一个名为 `public/robots.txt` 的文件。
|
|
||||||
|
|
||||||
有关如何配置 `robots.txt` 的示例,请参考 [https://moz.com/learn/seo/robotstxt](https://moz.com/learn/seo/robotstxt)。
|
|
||||||
|
|
||||||
```txt
|
|
||||||
User-agent: *
|
|
||||||
Disallow: /
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您将Gitea安装在子目录中,则需要在顶级目录中创建或编辑 `robots.txt`。
|
|
||||||
|
|
||||||
```txt
|
|
||||||
User-agent: *
|
|
||||||
Disallow: /gitea/
|
|
||||||
```
|
|
|
@ -1,175 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-08-17T10:20:00+01:00"
|
|
||||||
title: "GPG Commit Signatures"
|
|
||||||
slug: "signing"
|
|
||||||
sidebar_position: 50
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/signing
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "GPG Commit Signatures"
|
|
||||||
sidebar_position: 50
|
|
||||||
identifier: "signing"
|
|
||||||
---
|
|
||||||
|
|
||||||
# GPG Commit Signatures
|
|
||||||
|
|
||||||
Gitea will verify GPG commit signatures in the provided tree by
|
|
||||||
checking if the commits are signed by a key within the Gitea database,
|
|
||||||
or if the commit matches the default key for Git.
|
|
||||||
|
|
||||||
Keys are not checked to determine if they have expired or revoked.
|
|
||||||
Keys are also not checked with keyservers.
|
|
||||||
|
|
||||||
A commit will be marked with a grey unlocked icon if no key can be
|
|
||||||
found to verify it. If a commit is marked with a red unlocked icon,
|
|
||||||
it is reported to be signed with a key with an id.
|
|
||||||
|
|
||||||
Please note: The signer of a commit does not have to be an author or
|
|
||||||
committer of a commit.
|
|
||||||
|
|
||||||
This functionality requires Git >= 1.7.9 but for full functionality
|
|
||||||
this requires Git >= 2.0.0.
|
|
||||||
|
|
||||||
## Automatic Signing
|
|
||||||
|
|
||||||
There are a number of places where Gitea will generate commits itself:
|
|
||||||
|
|
||||||
- Repository Initialisation
|
|
||||||
- Wiki Changes
|
|
||||||
- CRUD actions using the editor or the API
|
|
||||||
- Merges from Pull Requests
|
|
||||||
|
|
||||||
Depending on configuration and server trust you may want Gitea to
|
|
||||||
sign these commits.
|
|
||||||
|
|
||||||
## Installing and generating a GPG key for Gitea
|
|
||||||
|
|
||||||
It is up to a server administrator to determine how best to install
|
|
||||||
a signing key. Gitea generates all its commits using the server `git`
|
|
||||||
command at present - and therefore the server `gpg` will be used for
|
|
||||||
signing (if configured.) Administrators should review best-practices
|
|
||||||
for GPG - in particular it is probably advisable to only install a
|
|
||||||
signing secret subkey without the master signing and certifying secret
|
|
||||||
key.
|
|
||||||
|
|
||||||
## General Configuration
|
|
||||||
|
|
||||||
Gitea's configuration for signing can be found with the
|
|
||||||
`[repository.signing]` section of `app.ini`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
...
|
|
||||||
[repository.signing]
|
|
||||||
SIGNING_KEY = default
|
|
||||||
SIGNING_NAME =
|
|
||||||
SIGNING_EMAIL =
|
|
||||||
INITIAL_COMMIT = always
|
|
||||||
CRUD_ACTIONS = pubkey, twofa, parentsigned
|
|
||||||
WIKI = never
|
|
||||||
MERGES = pubkey, twofa, basesigned, commitssigned
|
|
||||||
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
### `SIGNING_KEY`
|
|
||||||
|
|
||||||
The first option to discuss is the `SIGNING_KEY`. There are three main
|
|
||||||
options:
|
|
||||||
|
|
||||||
- `none` - this prevents Gitea from signing any commits
|
|
||||||
- `default` - Gitea will default to the key configured within `git config`
|
|
||||||
- `KEYID` - Gitea will sign commits with the gpg key with the ID
|
|
||||||
`KEYID`. In this case you should provide a `SIGNING_NAME` and
|
|
||||||
`SIGNING_EMAIL` to be displayed for this key.
|
|
||||||
|
|
||||||
The `default` option will interrogate `git config` for
|
|
||||||
`commit.gpgsign` option - if this is set, then it will use the results
|
|
||||||
of the `user.signingkey`, `user.name` and `user.email` as appropriate.
|
|
||||||
|
|
||||||
Please note: by adjusting Git's `config` file within Gitea's
|
|
||||||
repositories, `SIGNING_KEY=default` could be used to provide different
|
|
||||||
signing keys on a per-repository basis. However, this is clearly not an
|
|
||||||
ideal UI and therefore subject to change.
|
|
||||||
|
|
||||||
**Since 1.17**, Gitea runs git in its own home directory `[git].HOME_PATH` (default to `%(APP_DATA_PATH)/home`)
|
|
||||||
and uses its own config `{[git].HOME_PATH}/.gitconfig`.
|
|
||||||
If you have your own customized git config for Gitea, you should set these configs in system git config (aka `/etc/gitconfig`)
|
|
||||||
or the Gitea internal git config `{[git].HOME_PATH}/.gitconfig`.
|
|
||||||
Related home files for git command (like `.gnupg`) should also be put in Gitea's git home directory `[git].HOME_PATH`.
|
|
||||||
If you like to keep the `.gnupg` directory outside of `{[git].HOME_PATH}/`, consider setting the `$GNUPGHOME` environment variable to your preferred location.
|
|
||||||
|
|
||||||
### `INITIAL_COMMIT`
|
|
||||||
|
|
||||||
This option determines whether Gitea should sign the initial commit
|
|
||||||
when creating a repository. The possible values are:
|
|
||||||
|
|
||||||
- `never`: Never sign
|
|
||||||
- `pubkey`: Only sign if the user has a public key
|
|
||||||
- `twofa`: Only sign if the user logs in with two factor authentication
|
|
||||||
- `always`: Always sign
|
|
||||||
|
|
||||||
Options other than `never` and `always` can be combined as a comma
|
|
||||||
separated list. The commit will be signed if all selected options are true.
|
|
||||||
|
|
||||||
### `WIKI`
|
|
||||||
|
|
||||||
This options determines if Gitea should sign commits to the Wiki.
|
|
||||||
The possible values are:
|
|
||||||
|
|
||||||
- `never`: Never sign
|
|
||||||
- `pubkey`: Only sign if the user has a public key
|
|
||||||
- `twofa`: Only sign if the user logs in with two-factor authentication
|
|
||||||
- `parentsigned`: Only sign if the parent commit is signed.
|
|
||||||
- `always`: Always sign
|
|
||||||
|
|
||||||
Options other than `never` and `always` can be combined as a comma
|
|
||||||
separated list. The commit will be signed if all selected options are true.
|
|
||||||
|
|
||||||
### `CRUD_ACTIONS`
|
|
||||||
|
|
||||||
This option determines if Gitea should sign commits from the web
|
|
||||||
editor or API CRUD actions. The possible values are:
|
|
||||||
|
|
||||||
- `never`: Never sign
|
|
||||||
- `pubkey`: Only sign if the user has a public key
|
|
||||||
- `twofa`: Only sign if the user logs in with two-factor authentication
|
|
||||||
- `parentsigned`: Only sign if the parent commit is signed.
|
|
||||||
- `always`: Always sign
|
|
||||||
|
|
||||||
Options other than `never` and `always` can be combined as a comma
|
|
||||||
separated list. The change will be signed if all selected options are true.
|
|
||||||
|
|
||||||
### `MERGES`
|
|
||||||
|
|
||||||
This option determines if Gitea should sign merge commits from PRs.
|
|
||||||
The possible options are:
|
|
||||||
|
|
||||||
- `never`: Never sign
|
|
||||||
- `pubkey`: Only sign if the user has a public key
|
|
||||||
- `twofa`: Only sign if the user logs in with two-factor authentication
|
|
||||||
- `basesigned`: Only sign if the parent commit in the base repo is signed.
|
|
||||||
- `headsigned`: Only sign if the head commit in the head branch is signed.
|
|
||||||
- `commitssigned`: Only sign if all the commits in the head branch to the merge point are signed.
|
|
||||||
- `approved`: Only sign approved merges to a protected branch.
|
|
||||||
- `always`: Always sign
|
|
||||||
|
|
||||||
Options other than `never` and `always` can be combined as a comma
|
|
||||||
separated list. The merge will be signed if all selected options are true.
|
|
||||||
|
|
||||||
## Obtaining the Public Key of the Signing Key
|
|
||||||
|
|
||||||
The public key used to sign Gitea's commits can be obtained from the API at:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
/api/v1/signing-key.gpg
|
|
||||||
```
|
|
||||||
|
|
||||||
In cases where there is a repository specific key this can be obtained from:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
/api/v1/repos/:username/:reponame/signing-key.gpg
|
|
||||||
```
|
|
|
@ -1,142 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-23T09:00:00+08:00"
|
|
||||||
title: "GPG 提交签名"
|
|
||||||
slug: "signing"
|
|
||||||
sidebar_position: 50
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/signing
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "administration"
|
|
||||||
name: "GPG 提交签名"
|
|
||||||
sidebar_position: 50
|
|
||||||
identifier: "signing"
|
|
||||||
---
|
|
||||||
|
|
||||||
# GPG 提交签名
|
|
||||||
|
|
||||||
Gitea 将通过检查提交是否由 Gitea 数据库中的密钥签名,或者提交是否与 Git 的默认密钥匹配,来验证提供的树中的 GPG 提交签名。
|
|
||||||
|
|
||||||
密钥不会被检查以确定它们是否已过期或撤销。密钥也不会与密钥服务器进行检查。
|
|
||||||
|
|
||||||
如果找不到用于验证提交的密钥,提交将被标记为灰色的未锁定图标。如果提交被标记为红色的未锁定图标,则表示它使用带有 ID 的密钥签名。
|
|
||||||
|
|
||||||
请注意:提交的签署者不必是提交的作者或提交者。
|
|
||||||
|
|
||||||
此功能要求 Git >= 1.7.9,但要实现全部功能,需要 Git >= 2.0.0。
|
|
||||||
|
|
||||||
## 自动签名
|
|
||||||
|
|
||||||
有许多地方 Gitea 会生成提交:
|
|
||||||
|
|
||||||
- 仓库初始化
|
|
||||||
- Wiki 更改
|
|
||||||
- 使用编辑器或 API 进行的 CRUD 操作
|
|
||||||
- 从合并请求进行合并
|
|
||||||
|
|
||||||
根据配置和服务器信任,您可能希望 Gitea 对这些提交进行签名。
|
|
||||||
|
|
||||||
## 安装和生成 Gitea 的 GPG 密钥
|
|
||||||
|
|
||||||
如何安装签名密钥由服务器管理员决定。Gitea 目前使用服务器的 `git` 命令生成所有提交,因此将使用服务器的 `gpg` 进行签名(如果配置了)。管理员应该审查 GPG 的最佳实践 - 特别是可能建议仅安装签名的子密钥,而不是主签名和认证的密钥。
|
|
||||||
|
|
||||||
## 通用配置
|
|
||||||
|
|
||||||
Gitea 的签名配置可以在 `app.ini` 的 `[repository.signing]` 部分找到:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
...
|
|
||||||
[repository.signing]
|
|
||||||
SIGNING_KEY = default
|
|
||||||
SIGNING_NAME =
|
|
||||||
SIGNING_EMAIL =
|
|
||||||
INITIAL_COMMIT = always
|
|
||||||
CRUD_ACTIONS = pubkey, twofa, parentsigned
|
|
||||||
WIKI = never
|
|
||||||
MERGES = pubkey, twofa, basesigned, commitssigned
|
|
||||||
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
### `SIGNING_KEY`
|
|
||||||
|
|
||||||
首先讨论的选项是 `SIGNING_KEY`。有三个主要选项:
|
|
||||||
|
|
||||||
- `none` - 这将阻止 Gitea 对任何提交进行签名
|
|
||||||
- `default` - Gitea 将使用 `git config` 中配置的默认密钥
|
|
||||||
- `KEYID` - Gitea 将使用具有 ID `KEYID` 的 GPG 密钥对提交进行签名。在这种情况下,您应该提供 `SIGNING_NAME` 和 `SIGNING_EMAIL`,以便显示此密钥的信息。
|
|
||||||
|
|
||||||
`default` 选项将读取 `git config` 中的 `commit.gpgsign` 选项 - 如果设置了该选项,它将使用 `user.signingkey`、`user.name` 和 `user.email` 的结果。
|
|
||||||
|
|
||||||
请注意:通过在 Gitea 的仓库中调整 Git 的 `config` 文件,可以使用 `SIGNING_KEY=default` 为每个仓库提供不同的签名密钥。然而,这显然不是一个理想的用户界面,因此可能会发生更改。
|
|
||||||
|
|
||||||
**自 1.17 起**,Gitea 在自己的主目录 `[git].HOME_PATH`(默认为 `%(APP_DATA_PATH)/home`)中运行 git,并使用自己的配置文件 `{[git].HOME_PATH}/.gitconfig`。
|
|
||||||
如果您有自己定制的 Gitea git 配置,您应该将这些配置设置在系统 git 配置文件中(例如 `/etc/gitconfig`)或者 Gitea 的内部 git 配置文件 `{[git].HOME_PATH}/.gitconfig` 中。
|
|
||||||
与 git 命令相关的主目录文件(如 `.gnupg`)也应该放在 Gitea 的 git 主目录 `[git].HOME_PATH` 中。
|
|
||||||
如果您希望将 `.gnupg` 目录放在 `{[git].HOME_PATH}/` 之外的位置,请考虑设置 `$GNUPGHOME` 环境变量为您首选的位置。
|
|
||||||
|
|
||||||
### `INITIAL_COMMIT`
|
|
||||||
|
|
||||||
此选项确定在创建仓库时,Gitea 是否应该对初始提交进行签名。可能的取值有:
|
|
||||||
|
|
||||||
- `never`:从不签名
|
|
||||||
- `pubkey`:仅在用户拥有公钥时进行签名
|
|
||||||
- `twofa`:仅在用户使用 2FA 登录时进行签名
|
|
||||||
- `always`:始终签名
|
|
||||||
|
|
||||||
除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则提交将被签名。
|
|
||||||
|
|
||||||
### `WIKI`
|
|
||||||
|
|
||||||
此选项确定 Gitea 是否应该对 Wiki 的提交进行签名。可能的取值有:
|
|
||||||
|
|
||||||
- `never`:从不签名
|
|
||||||
- `pubkey`:仅在用户拥有公钥时进行签名
|
|
||||||
- `twofa`:仅在用户使用 2FA 登录时进行签名
|
|
||||||
- `parentsigned`:仅在父提交已签名时进行签名。
|
|
||||||
- `always`:始终签名
|
|
||||||
|
|
||||||
除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则提交将被签名。
|
|
||||||
|
|
||||||
### `CRUD_ACTIONS`
|
|
||||||
|
|
||||||
此选项确定 Gitea 是否应该对 Web 编辑器或 API CRUD 操作的提交进行签名。可能的取值有:
|
|
||||||
|
|
||||||
- `never`:从不签名
|
|
||||||
- `pubkey`:仅在用户拥有公钥时进行签名
|
|
||||||
- `twofa`:仅在用户使用 2FA 登录时进行签名
|
|
||||||
- `parentsigned`:仅在父提交已签名时进行签名。
|
|
||||||
- `always`:始终签名
|
|
||||||
|
|
||||||
除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则更改将被签名。
|
|
||||||
|
|
||||||
### `MERGES`
|
|
||||||
|
|
||||||
此选项确定 Gitea 是否应该对 PR 的合并提交进行签名。可能的选项有:
|
|
||||||
|
|
||||||
- `never`:从不签名
|
|
||||||
- `pubkey`:仅在用户拥有公钥时进行签名
|
|
||||||
- `twofa`:仅在用户使用 2FA 登录时进行签名
|
|
||||||
- `basesigned`:仅在基础仓库中的父提交已签名时进行签名。
|
|
||||||
- `headsigned`:仅在头分支中的头提交已签名时进行签名。
|
|
||||||
- `commitssigned`:仅在头分支中的所有提交到合并点的提交都已签名时进行签名。
|
|
||||||
- `approved`:仅对已批准的合并到受保护分支的提交进行签名。
|
|
||||||
- `always`:始终签名
|
|
||||||
|
|
||||||
除了 `never` 和 `always` 之外的选项可以组合为逗号分隔的列表。如果所有选择的选项都为 true,则合并将被签名。
|
|
||||||
|
|
||||||
## 获取签名密钥的公钥
|
|
||||||
|
|
||||||
用于签署 Gitea 提交的公钥可以通过 API 获取:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
/api/v1/signing-key.gpg
|
|
||||||
```
|
|
||||||
|
|
||||||
在存在特定于仓库的密钥的情况下,可以通过以下方式获取:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
/api/v1/repos/:username/:reponame/signing-key.gpg
|
|
||||||
```
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2021-01-22T00:00:00+02:00"
|
|
||||||
title: "Contributing"
|
|
||||||
slug: "contributing"
|
|
||||||
sidebar_position: 35
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "Contributing"
|
|
||||||
sidebar_position: 50
|
|
||||||
identifier: "contributing"
|
|
||||||
---
|
|
|
@ -1,124 +0,0 @@
|
||||||
---
|
|
||||||
date: "2021-11-01T23:41:00+08:00"
|
|
||||||
title: "Guidelines for Backend Development"
|
|
||||||
slug: "guidelines-backend"
|
|
||||||
sidebar_position: 20
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/guidelines-backend
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "Guidelines for Backend"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "guidelines-backend"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Guidelines for Backend Development
|
|
||||||
|
|
||||||
## Background
|
|
||||||
|
|
||||||
Gitea uses Golang as the backend programming language. It uses many third-party packages and also write some itself.
|
|
||||||
For example, Gitea uses [Chi](https://github.com/go-chi/chi) as basic web framework. [Xorm](https://xorm.io) is an ORM framework that is used to interact with the database.
|
|
||||||
So it's very important to manage these packages. Please take the below guidelines before you start to write backend code.
|
|
||||||
|
|
||||||
## Package Design Guideline
|
|
||||||
|
|
||||||
### Packages List
|
|
||||||
|
|
||||||
To maintain understandable code and avoid circular dependencies it is important to have a good code structure. The Gitea backend is divided into the following parts:
|
|
||||||
|
|
||||||
- `build`: Scripts to help build Gitea.
|
|
||||||
- `cmd`: All Gitea actual sub commands includes web, doctor, serv, hooks, admin and etc. `web` will start the web service. `serv` and `hooks` will be invoked by Git or OpenSSH. Other sub commands could help to maintain Gitea.
|
|
||||||
- `tests`: Common test utility functions
|
|
||||||
- `tests/integration`: Integration tests, to test back-end regressions
|
|
||||||
- `tests/e2e`: E2e tests, to test front-end and back-end compatibility and visual regressions.
|
|
||||||
- `models`: Contains the data structures used by xorm to construct database tables. It also contains functions to query and update the database. Dependencies to other Gitea code should be avoided. You can make exceptions in cases such as logging.
|
|
||||||
- `models/db`: Basic database operations. All other `models/xxx` packages should depend on this package. The `GetEngine` function should only be invoked from `models/`.
|
|
||||||
- `models/fixtures`: Sample data used in unit tests and integration tests. One `yml` file means one table which will be loaded into database when beginning the tests.
|
|
||||||
- `models/migrations`: Stores database migrations between versions. PRs that change a database structure **MUST** also have a migration step.
|
|
||||||
- `modules`: Different modules to handle specific functionality in Gitea. Work in Progress: Some of them should be moved to `services`, in particular those that depend on models because they rely on the database.
|
|
||||||
- `modules/setting`: Store all system configurations read from ini files and has been referenced by everywhere. But they should be used as function parameters when possible.
|
|
||||||
- `modules/git`: Package to interactive with `Git` command line or Gogit package.
|
|
||||||
- `public`: Compiled frontend files (javascript, images, css, etc.)
|
|
||||||
- `routers`: Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) must not depend on routers.
|
|
||||||
- `routers/api` Contains routers for `/api/v1` aims to handle RESTful API requests.
|
|
||||||
- `routers/install` Could only respond when system is in INSTALL mode (INSTALL_LOCK=false).
|
|
||||||
- `routers/private` will only be invoked by internal sub commands, especially `serv` and `hooks`.
|
|
||||||
- `routers/web` will handle HTTP requests from web browsers or Git SMART HTTP protocols.
|
|
||||||
- `services`: Support functions for common routing operations or command executions. Uses `models` and `modules` to handle the requests.
|
|
||||||
- `templates`: Golang templates for generating the html output.
|
|
||||||
|
|
||||||
### Package Dependencies
|
|
||||||
|
|
||||||
Since Golang doesn't support import cycles, we have to decide the package dependencies carefully. There are some levels between those packages. Below is the ideal package dependencies direction.
|
|
||||||
|
|
||||||
`cmd` -> `routers` -> `services` -> `models` -> `modules`
|
|
||||||
|
|
||||||
From left to right, left packages could depend on right packages, but right packages MUST not depend on left packages. The sub packages on the same level could depend on according this level's rules.
|
|
||||||
|
|
||||||
**NOTICE**
|
|
||||||
|
|
||||||
Why do we need database transactions outside of `models`? And how?
|
|
||||||
Some actions should allow for rollback when database record insertion/update/deletion failed.
|
|
||||||
So services must be allowed to create a database transaction. Here is some example,
|
|
||||||
|
|
||||||
```go
|
|
||||||
// services/repository/repository.go
|
|
||||||
func CreateXXXX() error {
|
|
||||||
return db.WithTx(func(ctx context.Context) error {
|
|
||||||
// do something, if err is returned, it will rollback automatically
|
|
||||||
if err := issues.UpdateIssue(ctx, repoID); err != nil {
|
|
||||||
// ...
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
You should **not** use `db.GetEngine(ctx)` in `services` directly, but just write a function under `models/`.
|
|
||||||
If the function will be used in the transaction, just let `context.Context` as the function's first parameter.
|
|
||||||
|
|
||||||
```go
|
|
||||||
// models/issues/issue.go
|
|
||||||
func UpdateIssue(ctx context.Context, repoID int64) error {
|
|
||||||
e := db.GetEngine(ctx)
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Package Name
|
|
||||||
|
|
||||||
For the top level package, use a plural as package name, i.e. `services`, `models`, for sub packages, use singular,
|
|
||||||
i.e. `services/user`, `models/repository`.
|
|
||||||
|
|
||||||
### Import Alias
|
|
||||||
|
|
||||||
Since there are some packages which use the same package name, it is possible that you find packages like `modules/user`, `models/user`, and `services/user`. When these packages are imported in one Go file, it's difficult to know which package we are using and if it's a variable name or an import name. So, we always recommend to use import aliases. To differ from package variables which are commonly in camelCase, just use **snake_case** for import aliases.
|
|
||||||
i.e. `import user_service "code.gitea.io/gitea/services/user"`
|
|
||||||
|
|
||||||
### Implementing `io.Closer`
|
|
||||||
|
|
||||||
If a type implements `io.Closer`, calling `Close` multiple times must not fail or `panic` but return an error or `nil`.
|
|
||||||
|
|
||||||
### Important Gotchas
|
|
||||||
|
|
||||||
- Never write `x.Update(exemplar)` without an explicit `WHERE` clause:
|
|
||||||
- This will cause all rows in the table to be updated with the non-zero values of the exemplar - including IDs.
|
|
||||||
- You should usually write `x.ID(id).Update(exemplar)`.
|
|
||||||
- If during a migration you are inserting into a table using `x.Insert(exemplar)` where the ID is preset:
|
|
||||||
- You will need to ``SET IDENTITY_INSERT `table` ON`` for the MSSQL variant (the migration will fail otherwise)
|
|
||||||
- However, you will also need to update the id sequence for postgres - the migration will silently pass here but later insertions will fail:
|
|
||||||
``SELECT setval('table_name_id_seq', COALESCE((SELECT MAX(id)+1 FROM `table_name`), 1), false)``
|
|
||||||
|
|
||||||
### Future Tasks
|
|
||||||
|
|
||||||
Currently, we are creating some refactors to do the following things:
|
|
||||||
|
|
||||||
- Correct that codes which doesn't follow the rules.
|
|
||||||
- There are too many files in `models`, so we are moving some of them into a sub package `models/xxx`.
|
|
||||||
- Some `modules` sub packages should be moved to `services` because they depend on `models`.
|
|
|
@ -1,119 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-25T23:41:00+08:00"
|
|
||||||
title: "后端开发指南"
|
|
||||||
slug: "guidelines-backend"
|
|
||||||
sidebar_position: 20
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/guidelines-backend
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "后端开发指南"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "guidelines-backend"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 后端开发指南
|
|
||||||
|
|
||||||
## 背景
|
|
||||||
|
|
||||||
Gitea使用Golang作为后端编程语言。它使用了许多第三方包,并且自己也编写了一些包。
|
|
||||||
例如,Gitea使用[Chi](https://github.com/go-chi/chi)作为基本的Web框架。[Xorm](https://xorm.io)是一个用于与数据库交互的ORM框架。
|
|
||||||
因此,管理这些包非常重要。在开始编写后端代码之前,请参考以下准则。
|
|
||||||
|
|
||||||
## 包设计准则
|
|
||||||
|
|
||||||
### 包列表
|
|
||||||
|
|
||||||
为了保持易于理解的代码并避免循环依赖,拥有良好的代码结构是很重要的。Gitea后端分为以下几个部分:
|
|
||||||
|
|
||||||
- `build`:帮助构建Gitea的脚本。
|
|
||||||
- `cmd`:包含所有Gitea的实际子命令,包括web、doctor、serv、hooks、admin等。`web`将启动Web服务。`serv`和`hooks`将被Git或OpenSSH调用。其他子命令可以帮助维护Gitea。
|
|
||||||
- `tests`:常用的测试函数
|
|
||||||
- `tests/integration`:集成测试,用于测试后端回归。
|
|
||||||
- `tests/e2e`:端到端测试,用于测试前端和后端的兼容性和视觉回归。
|
|
||||||
- `models`:包含由xorm用于构建数据库表的数据结构。它还包含查询和更新数据库的函数。应避免与其他Gitea代码的依赖关系。在某些情况下,比如日志记录时可以例外。
|
|
||||||
- `models/db`:基本的数据库操作。所有其他`models/xxx`包都应依赖于此包。`GetEngine`函数只能从models/中调用。
|
|
||||||
- `models/fixtures`:单元测试和集成测试中使用的示例数据。一个`yml`文件表示一个将在测试开始时加载到数据库中的表。
|
|
||||||
- `models/migrations`:存储不同版本之间的数据库迁移。修改数据库结构的PR**必须**包含一个迁移步骤。
|
|
||||||
- `modules`:在Gitea中处理特定功能的不同模块。工作正在进行中:其中一些模块应该移到`services`中,特别是那些依赖于models的模块,因为它们依赖于数据库。
|
|
||||||
- `modules/setting`:存储从ini文件中读取的所有系统配置,并在各处引用。但是在可能的情况下,应将其作为函数参数使用。
|
|
||||||
- `modules/git`:用于与`Git`命令行或Gogit包交互的包。
|
|
||||||
- `public`:编译后的前端文件(JavaScript、图像、CSS等)
|
|
||||||
- `routers`:处理服务器请求。由于它使用其他Gitea包来处理请求,因此其他包(models、modules或services)不能依赖于routers。
|
|
||||||
- `routers/api`:包含`/api/v1`相关路由,用于处理RESTful API请求。
|
|
||||||
- `routers/install`:只能在系统处于安装模式(INSTALL_LOCK=false)时响应。
|
|
||||||
- `routers/private`:仅由内部子命令调用,特别是`serv`和`hooks`。
|
|
||||||
- `routers/web`:处理来自Web浏览器或Git SMART HTTP协议的HTTP请求。
|
|
||||||
- `services`:用于常见路由操作或命令执行的支持函数。使用`models`和`modules`来处理请求。
|
|
||||||
- `templates`:用于生成HTML输出的Golang模板。
|
|
||||||
|
|
||||||
### 包依赖关系
|
|
||||||
|
|
||||||
由于Golang不支持导入循环,我们必须仔细决定包之间的依赖关系。这些包之间有一些级别。以下是理想的包依赖关系方向。
|
|
||||||
|
|
||||||
`cmd` -> `routers` -> `services` -> `models` -> `modules`
|
|
||||||
|
|
||||||
从左到右,左侧的包可以依赖于右侧的包,但右侧的包不能依赖于左侧的包。在同一级别的子包中,可以根据该级别的规则进行依赖。
|
|
||||||
|
|
||||||
**注意事项**
|
|
||||||
|
|
||||||
为什么我们需要在`models`之外使用数据库事务?以及如何使用?
|
|
||||||
某些操作在数据库记录插入/更新/删除失败时应该允许回滚。
|
|
||||||
因此,服务必须能够创建数据库事务。以下是一些示例:
|
|
||||||
|
|
||||||
```go
|
|
||||||
// services/repository/repository.go
|
|
||||||
func CreateXXXX() error {
|
|
||||||
return db.WithTx(func(ctx context.Context) error {
|
|
||||||
// do something, if err is returned, it will rollback automatically
|
|
||||||
if err := issues.UpdateIssue(ctx, repoID); err != nil {
|
|
||||||
// ...
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
在`services`中**不应该**直接使用`db.GetEngine(ctx)`,而是应该在`models/`下编写一个函数。
|
|
||||||
如果该函数将在事务中使用,请将`context.Context`作为函数的第一个参数。
|
|
||||||
|
|
||||||
```go
|
|
||||||
// models/issues/issue.go
|
|
||||||
func UpdateIssue(ctx context.Context, repoID int64) error {
|
|
||||||
e := db.GetEngine(ctx)
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 包名称
|
|
||||||
|
|
||||||
对于顶层包,请使用复数作为包名,例如`services`、`models`,对于子包,请使用单数,例如`services/user`、`models/repository`。
|
|
||||||
|
|
||||||
### 导入别名
|
|
||||||
|
|
||||||
由于有一些使用相同包名的包,例如`modules/user`、`models/user`和`services/user`,当这些包在一个Go文件中被导入时,很难知道我们使用的是哪个包以及它是变量名还是导入名。因此,我们始终建议使用导入别名。为了与常见的驼峰命名法的包变量区分开,建议使用**snake_case**作为导入别名的命名规则。
|
|
||||||
例如:`import user_service "code.gitea.io/gitea/services/user"`
|
|
||||||
|
|
||||||
### 重要注意事项
|
|
||||||
|
|
||||||
- 永远不要写成`x.Update(exemplar)`,而没有明确的`WHERE`子句:
|
|
||||||
- 这将导致表中的所有行都被使用exemplar的非零值进行更新,包括ID。
|
|
||||||
- 通常应该写成`x.ID(id).Update(exemplar)`。
|
|
||||||
- 如果在迁移过程中使用`x.Insert(exemplar)`向表中插入记录,而ID是预设的:
|
|
||||||
- 对于MSSQL变体,你将需要执行``SET IDENTITY_INSERT `table` ON``(否则迁移将失败)
|
|
||||||
- 对于PostgreSQL,你还需要更新ID序列,否则迁移将悄无声息地通过,但后续的插入将失败:
|
|
||||||
``SELECT setval('table_name_id_seq', COALESCE((SELECT MAX(id)+1 FROM `table_name`), 1), false)``
|
|
||||||
|
|
||||||
### 未来的任务
|
|
||||||
|
|
||||||
目前,我们正在进行一些重构,以完成以下任务:
|
|
||||||
|
|
||||||
- 纠正不符合规则的代码。
|
|
||||||
- `models`中的文件太多了,所以我们正在将其中的一些移动到子包`models/xxx`中。
|
|
||||||
- 由于它们依赖于`models`,因此应将某些`modules`子包移动到`services`中。
|
|
|
@ -1,149 +0,0 @@
|
||||||
---
|
|
||||||
date: "2021-10-13T16:00:00+02:00"
|
|
||||||
title: "Guidelines for Frontend Development"
|
|
||||||
slug: "guidelines-frontend"
|
|
||||||
sidebar_position: 30
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/guidelines-frontend
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "Guidelines for Frontend"
|
|
||||||
sidebar_position: 30
|
|
||||||
identifier: "guidelines-frontend"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Guidelines for Frontend Development
|
|
||||||
|
|
||||||
## Background
|
|
||||||
|
|
||||||
Gitea uses [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend.
|
|
||||||
|
|
||||||
The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template).
|
|
||||||
|
|
||||||
The source files can be found in the following directories:
|
|
||||||
|
|
||||||
* **CSS styles:** `web_src/css/`
|
|
||||||
* **JavaScript files:** `web_src/js/`
|
|
||||||
* **Vue components:** `web_src/js/components/`
|
|
||||||
* **Go HTML templates:** `templates/`
|
|
||||||
|
|
||||||
## General Guidelines
|
|
||||||
|
|
||||||
We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) and [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)
|
|
||||||
|
|
||||||
### Gitea specific guidelines:
|
|
||||||
|
|
||||||
1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories.
|
|
||||||
2. HTML ids and classes should use kebab-case, it's preferred to contain 2-3 feature related keywords.
|
|
||||||
3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript.
|
|
||||||
4. CSS styling for classes provided by frameworks should not be overwritten. Always use new class names with 2-3 feature related keywords to overwrite framework styles. Gitea's helper CSS classes in `helpers.less` could be helpful.
|
|
||||||
5. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`, but do not expose whole models to the frontend to avoid leaking sensitive data.
|
|
||||||
6. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue3.
|
|
||||||
7. Clarify variable types, prefer `elem.disabled = true` instead of `elem.setAttribute('disabled', 'anything')`, prefer `$el.prop('checked', var === 'yes')` instead of `$el.prop('checked', var)`.
|
|
||||||
8. Use semantic elements, prefer `<button class="ui button">` instead of `<div class="ui button">`.
|
|
||||||
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
|
|
||||||
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
|
|
||||||
11. Custom event names are recommended to use `ce-` prefix.
|
|
||||||
12. Prefer using Tailwind CSS which is available via `tw-` prefix, e.g. `tw-relative`. Gitea's helper CSS classes use `gt-` prefix (`gt-word-break`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
|
|
||||||
13. Avoid inline scripts & styles as much as possible, it's recommended to put JS code into JS files and use CSS classes. If inline scripts & styles are unavoidable, explain the reason why it can't be avoided.
|
|
||||||
|
|
||||||
### Accessibility / ARIA
|
|
||||||
|
|
||||||
In history, Gitea heavily uses Fomantic UI which is not an accessibility-friendly framework.
|
|
||||||
Gitea uses some patches to make Fomantic UI more accessible (see `aria.md` and related JS files),
|
|
||||||
but there are still many problems which need a lot of work and time to fix.
|
|
||||||
|
|
||||||
### Framework Usage
|
|
||||||
|
|
||||||
Mixing different frameworks together is discouraged, it makes the code difficult to be maintained.
|
|
||||||
A JavaScript module should follow one major framework and follow the framework's best practice.
|
|
||||||
|
|
||||||
Recommended implementations:
|
|
||||||
|
|
||||||
* Vue + Vanilla JS
|
|
||||||
* Fomantic-UI (jQuery)
|
|
||||||
* htmx (partial page reloads for otherwise static components)
|
|
||||||
* Vanilla JS
|
|
||||||
|
|
||||||
Discouraged implementations:
|
|
||||||
|
|
||||||
* Vue + Fomantic-UI (jQuery)
|
|
||||||
* jQuery + Vanilla JS
|
|
||||||
* htmx + any other framework which requires heavy JS code, or unnecessary features like htmx scripting (`hx-on`)
|
|
||||||
|
|
||||||
To make UI consistent, Vue components can use Fomantic-UI CSS classes.
|
|
||||||
We use htmx for simple interactions. You can see an example for simple interactions where htmx should be used in this [PR](https://github.com/go-gitea/gitea/pull/28908). Do not use htmx if you require more advanced reactivity, use another framework (Vue/Vanilla JS).
|
|
||||||
Although mixing different frameworks is discouraged,
|
|
||||||
it should also work if the mixing is necessary and the code is well-designed and maintainable.
|
|
||||||
|
|
||||||
### `async` Functions
|
|
||||||
|
|
||||||
Only mark a function as `async` if and only if there are `await` calls
|
|
||||||
or `Promise` returns inside the function.
|
|
||||||
|
|
||||||
It's not recommended to use `async` event listeners, which may lead to problems.
|
|
||||||
The reason is that the code after await is executed outside the event dispatch.
|
|
||||||
Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
|
|
||||||
|
|
||||||
If an event listener must be `async`, the `e.preventDefault()` should be before any `await`,
|
|
||||||
it's recommended to put it at the beginning of the function.
|
|
||||||
|
|
||||||
If we want to call an `async` function in a non-async context,
|
|
||||||
it's recommended to use `const _promise = asyncFoo()` to tell readers
|
|
||||||
that this is done by purpose, we want to call the async function and ignore the Promise.
|
|
||||||
Some lint rules and IDEs also have warnings if the returned Promise is not handled.
|
|
||||||
|
|
||||||
### Fetching data
|
|
||||||
|
|
||||||
To fetch data, use the wrapper functions `GET`, `POST` etc. from `modules/fetch.js`. They
|
|
||||||
accept a `data` option for the content, will automatically set CSRF token and return a
|
|
||||||
Promise for a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
||||||
|
|
||||||
### HTML Attributes and `dataset`
|
|
||||||
|
|
||||||
The usage of `dataset` is forbidden, its camel-casing behaviour makes it hard to grep for attributes.
|
|
||||||
However, there are still some special cases, so the current guideline is:
|
|
||||||
|
|
||||||
* For legacy code:
|
|
||||||
* `$.data()` should be refactored to `$.attr()`.
|
|
||||||
* `$.data()` can be used to bind some non-string data to elements in rare cases, but it is highly discouraged.
|
|
||||||
|
|
||||||
* For new code:
|
|
||||||
* `node.dataset` should not be used, use `node.getAttribute` instead.
|
|
||||||
* never bind any user data to a DOM node, use a suitable design pattern to describe the relation between node and data.
|
|
||||||
|
|
||||||
### Show/Hide Elements
|
|
||||||
|
|
||||||
* Vue components are recommended to use `v-if` and `v-show` to show/hide elements.
|
|
||||||
* Go template code should use `.tw-hidden` and `showElem()/hideElem()/toggleElem()`, see more details in `.tw-hidden`'s comment.
|
|
||||||
|
|
||||||
### Styles and Attributes in Go HTML Template
|
|
||||||
|
|
||||||
It's recommended to use:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="gt-name1 gt-name2 {{if .IsFoo}}gt-foo{{end}}" {{if .IsFoo}}data-foo{{end}}></div>
|
|
||||||
```
|
|
||||||
|
|
||||||
instead of:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="gt-name1 gt-name2{{if .IsFoo}} gt-foo{{end}}"{{if .IsFoo}} data-foo{{end}}></div>
|
|
||||||
```
|
|
||||||
|
|
||||||
to make the code more readable.
|
|
||||||
|
|
||||||
### Legacy Code
|
|
||||||
|
|
||||||
A lot of legacy code already existed before this document's written. It's recommended to refactor legacy code to follow the guidelines.
|
|
||||||
|
|
||||||
### Vue3 and JSX
|
|
||||||
|
|
||||||
Gitea is using Vue3 now. We decided not to introduce JSX to keep the HTML and the JavaScript code separated.
|
|
||||||
|
|
||||||
### UI Examples
|
|
||||||
|
|
||||||
Gitea uses some self-made UI elements and customizes others to integrate them better into the general UI approach. When running Gitea in development mode (`RUN_MODE=dev`), a page with some standardized UI examples is available under `http(s)://your-gitea-url:port/devtest`.
|
|
|
@ -1,148 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-25T16:00:00+02:00"
|
|
||||||
title: "前端开发指南"
|
|
||||||
slug: "guidelines-frontend"
|
|
||||||
sidebar_position: 20
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/guidelines-frontend
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "前端开发指南"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "guidelines-frontend"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 前端开发指南
|
|
||||||
|
|
||||||
## 背景
|
|
||||||
|
|
||||||
Gitea 在其前端中使用[Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html)(基于[jQuery](https://api.jquery.com))和 [Vue3](https://vuejs.org/)。
|
|
||||||
|
|
||||||
HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
|
|
||||||
|
|
||||||
源文件可以在以下目录中找到:
|
|
||||||
|
|
||||||
* **CSS 样式**: `web_src/css/`
|
|
||||||
* **JavaScript 文件**: `web_src/js/`
|
|
||||||
* **Vue 组件**: `web_src/js/components/`
|
|
||||||
* **Go HTML 模板**: `templates/`
|
|
||||||
|
|
||||||
## 通用准则
|
|
||||||
|
|
||||||
我们推荐使用[Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html)和[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)。
|
|
||||||
|
|
||||||
## Gitea 特定准则
|
|
||||||
|
|
||||||
1. 每个功能(Fomantic-UI/jQuery 模块)应放在单独的文件/目录中。
|
|
||||||
2. HTML 的 id 和 class 应使用 kebab-case,最好包含2-3个与功能相关的关键词。
|
|
||||||
3. 在 JavaScript 中使用的 HTML 的 id 和 class 应在整个项目中是唯一的,并且应包含2-3个与功能相关的关键词。建议在仅在 JavaScript 中使用的 class 中使用 `js-` 前缀。
|
|
||||||
4. 不应覆盖框架提供的 class 的 CSS 样式。始终使用具有2-3个与功能相关的关键词的新 class 名称来覆盖框架样式。Gitea 中的帮助 CSS 类在 `helpers.less` 中。
|
|
||||||
5. 后端可以通过使用`ctx.PageData["myModuleData"] = map[]{}`将复杂数据传递给前端,但不要将整个模型暴露给前端,以避免泄露敏感数据。
|
|
||||||
6. 简单页面和与 SEO 相关的页面使用 Go HTML 模板渲染生成静态的 Fomantic-UI HTML 输出。复杂页面可以使用 Vue3。
|
|
||||||
7. 明确变量类型,优先使用`elem.disabled = true`而不是`elem.setAttribute('disabled', 'anything')`,优先使用`$el.prop('checked', var === 'yes')`而不是`$el.prop('checked', var)`。
|
|
||||||
8. 使用语义化元素,优先使用`<button class="ui button">`而不是`<div class="ui button">`。
|
|
||||||
9. 避免在 CSS 中使用不必要的`!important`,如果无法避免,添加注释解释为什么需要它。
|
|
||||||
10. 避免在一个事件监听器中混合不同的事件,优先为每个事件使用独立的事件监听器。
|
|
||||||
11. 推荐使用自定义事件名称前缀`ce-`。
|
|
||||||
12. 建议使用 Tailwind CSS,它可以通过 `tw-` 前缀获得,例如 `tw-relative`. Gitea 自身的助手类 CSS 使用 `gt-` 前缀(`gt-word-break`),Gitea 自身的私有框架级 CSS 类使用 `g-` 前缀(`g-modal-confirm`)。
|
|
||||||
13. 尽量避免内联脚本和样式,建议将JS代码放入JS文件中并使用CSS类。如果内联脚本和样式不可避免,请解释无法避免的原因。
|
|
||||||
|
|
||||||
### 可访问性 / ARIA
|
|
||||||
|
|
||||||
在历史上,Gitea大量使用了可访问性不友好的框架 Fomantic UI。
|
|
||||||
Gitea使用一些补丁使Fomantic UI更具可访问性(参见`aria.js`和`aria.md`),
|
|
||||||
但仍然存在许多问题需要大量的工作和时间来修复。
|
|
||||||
|
|
||||||
### 框架使用
|
|
||||||
|
|
||||||
不建议混合使用不同的框架,这会使代码难以维护。
|
|
||||||
一个 JavaScript 模块应遵循一个主要框架,并遵循该框架的最佳实践。
|
|
||||||
|
|
||||||
推荐的实现方式:
|
|
||||||
|
|
||||||
* Vue + Vanilla JS
|
|
||||||
* Fomantic-UI(jQuery)
|
|
||||||
* htmx (部分页面重新加载其他静态组件)
|
|
||||||
* Vanilla JS
|
|
||||||
|
|
||||||
不推荐的实现方式:
|
|
||||||
|
|
||||||
* Vue + Fomantic-UI(jQuery)
|
|
||||||
* jQuery + Vanilla JS
|
|
||||||
* htmx + 任何其他需要大量 JavaScript 代码或不必要的功能,如 htmx 脚本 (`hx-on`)
|
|
||||||
|
|
||||||
为了保持界面一致,Vue 组件可以使用 Fomantic-UI 的 CSS 类。
|
|
||||||
尽管不建议混合使用不同的框架,
|
|
||||||
我们使用 htmx 进行简单的交互。您可以在此 [PR](https://github.com/go-gitea/gitea/pull/28908) 中查看一个简单交互的示例,其中应使用 htmx。如果您需要更高级的反应性,请不要使用 htmx,请使用其他框架(Vue/Vanilla JS)。
|
|
||||||
但如果混合使用是必要的,并且代码设计良好且易于维护,也可以工作。
|
|
||||||
|
|
||||||
### `async` 函数
|
|
||||||
|
|
||||||
只有当函数内部存在`await`调用或返回`Promise`时,才将函数标记为`async`。
|
|
||||||
|
|
||||||
不建议使用`async`事件监听器,这可能会导致问题。
|
|
||||||
原因是`await`后的代码在事件分发之外执行。
|
|
||||||
参考:https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
|
|
||||||
|
|
||||||
如果一个事件监听器必须是`async`,应在任何`await`之前使用`e.preventDefault()`,
|
|
||||||
建议将其放在函数的开头。
|
|
||||||
|
|
||||||
如果我们想在非异步上下文中调用`async`函数,
|
|
||||||
建议使用`const _promise = asyncFoo()`来告诉读者
|
|
||||||
这是有意为之的,我们想调用异步函数并忽略Promise。
|
|
||||||
一些 lint 规则和 IDE 也会在未处理返回的 Promise 时发出警告。
|
|
||||||
|
|
||||||
### 获取数据
|
|
||||||
|
|
||||||
要获取数据,请使用`modules/fetch.js`中的包装函数`GET`、`POST`等。他们
|
|
||||||
接受内容的`data`选项,将自动设置 CSRF 令牌并返回
|
|
||||||
[Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)。
|
|
||||||
|
|
||||||
### HTML 属性和 dataset
|
|
||||||
|
|
||||||
禁止使用`dataset`,它的驼峰命名行为使得搜索属性变得困难。
|
|
||||||
然而,仍然存在一些特殊情况,因此当前的准则是:
|
|
||||||
|
|
||||||
* 对于旧代码:
|
|
||||||
* 应将`$.data()`重构为`$.attr()`。
|
|
||||||
* 在极少数情况下,可以使用`$.data()`将一些非字符串数据绑定到元素上,但强烈不推荐使用。
|
|
||||||
|
|
||||||
* 对于新代码:
|
|
||||||
* 不应使用`node.dataset`,而应使用`node.getAttribute`。
|
|
||||||
* 不要将任何用户数据绑定到 DOM 节点上,使用合适的设计模式描述节点和数据之间的关系。
|
|
||||||
|
|
||||||
### 显示/隐藏元素
|
|
||||||
|
|
||||||
* 推荐在Vue组件中使用`v-if`和`v-show`来显示/隐藏元素。
|
|
||||||
* Go 模板代码应使用 `.tw-hidden` 和 `showElem()/hideElem()/toggleElem()` 来显示/隐藏元素,请参阅`.tw-hidden`的注释以获取更多详细信息。
|
|
||||||
|
|
||||||
### Go HTML 模板中的样式和属性
|
|
||||||
|
|
||||||
建议使用以下方式:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="gt-name1 gt-name2 {{if .IsFoo}}gt-foo{{end}}" {{if .IsFoo}}data-foo{{end}}></div>
|
|
||||||
```
|
|
||||||
|
|
||||||
而不是:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="gt-name1 gt-name2{{if .IsFoo}} gt-foo{{end}}"{{if .IsFoo}} data-foo{{end}}></div>
|
|
||||||
```
|
|
||||||
|
|
||||||
以使代码更易读。
|
|
||||||
|
|
||||||
### 旧代码
|
|
||||||
|
|
||||||
许多旧代码已经存在于本文撰写之前。建议重构旧代码以遵循指南。
|
|
||||||
|
|
||||||
### Vue3 和 JSX
|
|
||||||
|
|
||||||
Gitea 现在正在使用 Vue3。我们决定不引入 JSX,以保持 HTML 代码和 JavaScript 代码分离。
|
|
||||||
|
|
||||||
### UI示例
|
|
||||||
|
|
||||||
Gitea 使用一些自制的 UI 元素并自定义其他元素,以将它们更好地集成到通用 UI 方法中。当在开发模式(`RUN_MODE=dev`)下运行 Gitea 时,在 `http(s)://your-gitea-url:port/devtest` 下会提供一个包含一些标准化 UI 示例的页面。
|
|
|
@ -1,49 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-02-14T00:00:00+00:00"
|
|
||||||
title: "Guidelines for Refactoring"
|
|
||||||
slug: "guidelines-refactoring"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/guidelines-refactoring
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "Guidelines for Refactoring"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "guidelines-refactoring"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Guidelines for Refactoring
|
|
||||||
|
|
||||||
## Background
|
|
||||||
|
|
||||||
Since the first line of code was written at Feb 12, 2014, Gitea has grown to be a large project.
|
|
||||||
As a result, the codebase has become larger and larger. The larger the codebase is, the more difficult it is to maintain.
|
|
||||||
A lot of outdated mechanisms exist, a lot of frameworks are mixed together, some legacy code might cause bugs and block new features.
|
|
||||||
To make the codebase more maintainable and make Gitea better, developers should keep in mind to use modern mechanisms to refactor the old code.
|
|
||||||
|
|
||||||
This document is a collection of guidelines for refactoring the codebase.
|
|
||||||
|
|
||||||
## Refactoring Suggestions
|
|
||||||
|
|
||||||
* Design more about the future, but not only resolve the current problem.
|
|
||||||
* Reduce ambiguity, reduce conflicts, improve maintainability.
|
|
||||||
* Describe the refactoring, for example:
|
|
||||||
* Why the refactoring is needed.
|
|
||||||
* How the legacy problems would be solved.
|
|
||||||
* What's the Pros/Cons of the refactoring.
|
|
||||||
* Only do necessary changes, keep the old logic as much as possible.
|
|
||||||
* Introduce some intermediate steps to make the refactoring easier to review, a complete refactoring plan could be done in several PRs.
|
|
||||||
* If there is any divergence, the TOC(Technical Oversight Committee) should be involved to help to make decisions.
|
|
||||||
* Add necessary tests to make sure the refactoring is correct.
|
|
||||||
* Non-bug refactoring is preferred to be done at the beginning of a milestone, it would be easier to find problems before the release.
|
|
||||||
|
|
||||||
## Reviewing & Merging Suggestions
|
|
||||||
|
|
||||||
* A refactoring PR shouldn't be kept open for a long time (usually 7 days), it should be reviewed as soon as possible.
|
|
||||||
* A refactoring PR should be merged as soon as possible, it should not be blocked by other PRs.
|
|
||||||
* If there is no objection from TOC, a refactoring PR could be merged after 7 days with one core member's approval (not the author).
|
|
||||||
* Tolerate some dirty/hacky intermediate steps if the final result is good.
|
|
||||||
* Tolerate some regression bugs if the refactoring is necessary, fix bugs as soon as possible.
|
|
|
@ -1,49 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-25T00:00:00+00:00"
|
|
||||||
title: "重构指南"
|
|
||||||
slug: "guidelines-refactoring"
|
|
||||||
sidebar_position: 20
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/guidelines-refactoring
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "重构指南"
|
|
||||||
sidebar_position: 20
|
|
||||||
identifier: "guidelines-refactoring"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 重构指南
|
|
||||||
|
|
||||||
## 背景
|
|
||||||
|
|
||||||
自2014年2月12日编写了第一行代码以来,Gitea已经发展成为一个庞大的项目。
|
|
||||||
因此,代码库变得越来越大。代码库越大,维护就越困难。
|
|
||||||
存在许多过时的机制,许多框架混合在一起,一些遗留代码可能会导致错误并阻碍新功能的开发。
|
|
||||||
为了使代码库更易于维护,使Gitea变得更好,开发人员应牢记使用现代机制来重构旧代码。
|
|
||||||
|
|
||||||
本文档是关于重构代码库的指南集合。
|
|
||||||
|
|
||||||
## 重构建议
|
|
||||||
|
|
||||||
* 设计更多关于未来的内容,而不仅仅解决当前问题。
|
|
||||||
* 减少模糊性,减少冲突,提高可维护性。
|
|
||||||
* 描述重构,例如:
|
|
||||||
* 为什么需要重构。
|
|
||||||
* 如何解决旧问题。
|
|
||||||
* 重构的优点/缺点是什么。
|
|
||||||
* 只做必要的更改,尽量保留旧逻辑。
|
|
||||||
* 引入一些中间步骤,使重构更容易审查,完整的重构计划可以在几个PR中完成。
|
|
||||||
* 如果存在分歧,应该请TOC(技术监督委员会)参与决策。
|
|
||||||
* 添加必要的测试以确保重构的正确性。
|
|
||||||
* 非错误重构优先在里程碑的开始时进行,这样可以更容易地在发布之前发现问题。
|
|
||||||
|
|
||||||
## 审查和合并建议
|
|
||||||
|
|
||||||
* 重构的PR不应该长时间保持打开状态(通常为7天),应尽快进行审查。
|
|
||||||
* 重构的PR应尽快合并,不应被其他PR阻塞。
|
|
||||||
* 如果TOC没有异议,重构的PR可以在7天后由一名核心成员(非作者)批准后合并。
|
|
||||||
* 如果最终结果良好,容忍一些不完美/临时的步骤。
|
|
||||||
* 如果重构是必要的,容忍一些回归错误,并尽快修复错误。
|
|
|
@ -1,64 +0,0 @@
|
||||||
---
|
|
||||||
date: "2021-01-22T00:00:00+02:00"
|
|
||||||
title: "Übersetzungs Richtlinien"
|
|
||||||
slug: "localization"
|
|
||||||
sidebar_position: 70
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "Übersetzungsrichtlinien"
|
|
||||||
sidebar_position: 70
|
|
||||||
identifier: "localization"
|
|
||||||
---
|
|
||||||
|
|
||||||
## Allgemeines
|
|
||||||
|
|
||||||
Anrede: Wenig förmlich:
|
|
||||||
|
|
||||||
* "Du"-Form
|
|
||||||
* Keine "Amtsdeusch"-Umschreibungen, einfach so als ob man den Nutzer direkt persönlich ansprechen würde
|
|
||||||
|
|
||||||
Genauer definiert:
|
|
||||||
|
|
||||||
* "falsch" anstatt "nicht korrekt/inkorrekt"
|
|
||||||
* Benutzerkonto oder Konto? Oder Account?
|
|
||||||
* "Wende dich an ..." anstatt "kontaktiere ..."
|
|
||||||
* In der selben Zeit übersetzen (sonst wird aus "is" "war")
|
|
||||||
* Richtige Anführungszeichen verwenden. Also `"` statt `''` oder `'` oder \` oder `´`
|
|
||||||
* `„` für beginnende Anführungszeichen, `“` für schließende Anführungszeichen
|
|
||||||
|
|
||||||
Es gelten Artikel und Worttrennungen aus dem Duden.
|
|
||||||
|
|
||||||
## Formulierungen in Modals und Buttons
|
|
||||||
|
|
||||||
Es sollten die gleichen Formulierungen auf Buttons und Modals verwendet werden.
|
|
||||||
|
|
||||||
Beispiel: Wenn der Button mit `löschen` beschriftet ist, sollte im Modal die Frage lauten `Willst du das wirklich löschen?` und nicht `Willst du das wirklich entfernen?`. Gleiches gilt für Success/Errormeldungen nach der Aktion.
|
|
||||||
|
|
||||||
## Trennungen
|
|
||||||
|
|
||||||
* Pull-Request
|
|
||||||
* Time-Tracker
|
|
||||||
* E-Mail-Adresse (siehe Duden)
|
|
||||||
|
|
||||||
## Artikeldefinitionen für Anglizismen
|
|
||||||
|
|
||||||
* _Der_ Commit (m.)
|
|
||||||
* _Der_ Branch (m.), plural: die Branches
|
|
||||||
* _Das_ Issue (n.)
|
|
||||||
* _Der_ Fork (m.)
|
|
||||||
* _Das_ Repository (n.), plural: die Repositories
|
|
||||||
* _Der_ Pull-Request (m.)
|
|
||||||
* _Der_ Token (m.), plural: die Token
|
|
||||||
* _Das_ Review (n.)
|
|
||||||
* _Der_ Key (m.)
|
|
||||||
* _Der_ Committer (m.), plural: die Committer
|
|
||||||
|
|
||||||
## Weiterführende Links
|
|
||||||
|
|
||||||
Diese beiden Links sind sehr empfehlenswert:
|
|
||||||
|
|
||||||
* http://docs.translatehouse.org/projects/localization-guide/en/latest/guide/translation_guidelines_german.html
|
|
||||||
* https://docs.qgis.org/2.18/en/docs/documentation_guidelines/do_translations.html
|
|
|
@ -1,39 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "Localization"
|
|
||||||
slug: "localization"
|
|
||||||
sidebar_position: 70
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/localization
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "Localization"
|
|
||||||
sidebar_position: 70
|
|
||||||
identifier: "localization"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Localization
|
|
||||||
|
|
||||||
Gitea's localization happens through our [Crowdin project](https://crowdin.com/project/gitea).
|
|
||||||
|
|
||||||
For changes to an **English** translation, a pull request can be made that changes the appropriate key in
|
|
||||||
the [english locale](https://github.com/go-gitea/gitea/blob/main/options/locale/locale_en-US.ini).
|
|
||||||
|
|
||||||
For changes to a **non-English** translation, refer to the Crowdin project above.
|
|
||||||
|
|
||||||
## Supported Languages
|
|
||||||
|
|
||||||
Any language listed in the above Crowdin project will be supported as long as 25% or more has been translated.
|
|
||||||
|
|
||||||
After a translation has been accepted, it will be reflected in the main repository after the next Crowdin sync, which is generally after any PR is merged.
|
|
||||||
|
|
||||||
At the time of writing, this means that a changed translation may not appear until the following Gitea release.
|
|
||||||
|
|
||||||
If you use a bleeding edge build, it should appear as soon as you update after the change is synced.
|
|
||||||
|
|
||||||
# How to Contribute
|
|
||||||
|
|
||||||
Different Languages have different translation guidelines. Please visit the respective page for more information.
|
|
|
@ -1,34 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "本地化"
|
|
||||||
slug: "localization"
|
|
||||||
sidebar_position: 70
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/localization
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "本地化"
|
|
||||||
sidebar_position: 70
|
|
||||||
identifier: "localization"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 本地化
|
|
||||||
|
|
||||||
Gitea的本地化是通过我们的[Crowdin项目](https://crowdin.com/project/gitea)进行的。
|
|
||||||
|
|
||||||
对于对**英语翻译**的更改,可以发出pull-request,来更改[英语语言环境](https://github.com/go-gitea/gitea/blob/main/options/locale/locale_en-US.ini)中合适的关键字。
|
|
||||||
|
|
||||||
有关对**非英语**翻译的更改,请参阅上面的 Crowdin 项目。
|
|
||||||
|
|
||||||
## 支持的语言
|
|
||||||
|
|
||||||
上述 Crowdin 项目中列出的任何语言一旦翻译了 25% 或更多都将得到支持。
|
|
||||||
|
|
||||||
翻译被接受后,它将在下一次 Crowdin 同步后反映在主存储库中,这通常是在任何 PR 合并之后。
|
|
||||||
|
|
||||||
在撰写本文时,这意味着更改后的翻译可能要到 Gitea 的下一个版本才会出现。
|
|
||||||
|
|
||||||
如果使用开发版本,则在同步更改内容后,它应该会在更新后立即显示。
|
|
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-25T00:00:00+02:00"
|
|
||||||
title: "翻译指南"
|
|
||||||
sidebar_position: 70
|
|
||||||
toc: true
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "contributing"
|
|
||||||
name: "翻译指南"
|
|
||||||
sidebar_position: 70
|
|
||||||
identifier: "translation-guidelines"
|
|
||||||
---
|
|
||||||
|
|
||||||
本页面用于提供一套通用规则,以确保翻译的一致性。
|
|
||||||
|
|
||||||
* [German](/de-de/übersetzungs-richtlinien/)
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "Development"
|
|
||||||
slug: "development"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "Development"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "development"
|
|
||||||
---
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "开发"
|
|
||||||
slug: "development"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "开发"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "development"
|
|
||||||
---
|
|
|
@ -1,132 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-06-24:00:00+02:00"
|
|
||||||
title: "API Usage"
|
|
||||||
slug: "api-usage"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/api-usage
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "API Usage"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "api-usage"
|
|
||||||
---
|
|
||||||
|
|
||||||
# API Usage
|
|
||||||
|
|
||||||
## Enabling/configuring API access
|
|
||||||
|
|
||||||
By default, `ENABLE_SWAGGER` is true, and `MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat Sheet](administration/config-cheat-sheet.md) for more information.
|
|
||||||
|
|
||||||
## Authentication
|
|
||||||
|
|
||||||
Gitea supports these methods of API authentication:
|
|
||||||
|
|
||||||
- HTTP basic authentication
|
|
||||||
- `token=...` parameter in URL query string
|
|
||||||
- `access_token=...` parameter in URL query string
|
|
||||||
- `Authorization: token ...` header in HTTP headers
|
|
||||||
|
|
||||||
All of these methods accept the same API key token type. You can
|
|
||||||
better understand this by looking at the code -- as of this writing,
|
|
||||||
Gitea parses queries and headers to find the token in
|
|
||||||
[modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47).
|
|
||||||
|
|
||||||
## Generating and listing API tokens
|
|
||||||
|
|
||||||
A new token can be generated with a `POST` request to
|
|
||||||
`/users/:name/tokens`.
|
|
||||||
|
|
||||||
Note that `/users/:name/tokens` is a special endpoint and requires you
|
|
||||||
to authenticate using `BasicAuth` and a password, as follows:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ curl -H "Content-Type: application/json" -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens
|
|
||||||
{"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"}
|
|
||||||
```
|
|
||||||
|
|
||||||
The ``sha1`` (the token) is only returned once and is not stored in
|
|
||||||
plain-text. It will not be displayed when listing tokens with a `GET`
|
|
||||||
request; e.g.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ curl --url https://yourusername:password@gitea.your.host/api/v1/users/<username>/tokens
|
|
||||||
[{"name":"test","sha1":"","token_last_eight:"........":},{"name":"dev","sha1":"","token_last_eight":"........"}]
|
|
||||||
```
|
|
||||||
|
|
||||||
To use the API with basic authentication with two factor authentication
|
|
||||||
enabled, you'll need to send an additional header that contains the one
|
|
||||||
time password (6 digitrotating token).
|
|
||||||
An example of the header is `X-Gitea-OTP: 123456` where `123456`
|
|
||||||
is where you'd place the code from your authenticator.
|
|
||||||
Here is how the request would look like in curl:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ curl -H "X-Gitea-OTP: 123456" --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also create an API key token via your Gitea installation's web
|
|
||||||
interface: `Settings | Applications | Generate New Token`.
|
|
||||||
|
|
||||||
## OAuth2 Provider
|
|
||||||
|
|
||||||
Access tokens obtained from Gitea's [OAuth2 provider](development/oauth2-provider.md) are accepted by these methods:
|
|
||||||
|
|
||||||
- `Authorization bearer ...` header in HTTP headers
|
|
||||||
- `token=...` parameter in URL query string
|
|
||||||
- `access_token=...` parameter in URL query string
|
|
||||||
|
|
||||||
### More on the `Authorization:` header
|
|
||||||
|
|
||||||
For historical reasons, Gitea needs the word `token` included before
|
|
||||||
the API key token in an authorization header, like this:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675
|
|
||||||
```
|
|
||||||
|
|
||||||
In a `curl` command, for instance, this would look like:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \
|
|
||||||
-H "accept: application/json" \
|
|
||||||
-H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \
|
|
||||||
-H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i
|
|
||||||
```
|
|
||||||
|
|
||||||
As mentioned above, the token used is the same one you would use in
|
|
||||||
the `token=` string in a GET request.
|
|
||||||
|
|
||||||
## Pagination
|
|
||||||
|
|
||||||
The API supports pagination. The `page` and `limit` parameters are used to specify the page number and the number of items per page. As well, the `Link` header is returned with the next, previous, and last page links if there are more than one pages. The `x-total-count` is also returned to indicate the total number of items.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
curl -v "http://localhost/api/v1/repos/search?limit=1"
|
|
||||||
...
|
|
||||||
< link: <http://localhost/api/v1/repos/search?limit=1&page=2>; rel="next",<http://localhost/api/v1/repos/search?limit=1&page=5252>; rel="last"
|
|
||||||
...
|
|
||||||
< x-total-count: 5252
|
|
||||||
```
|
|
||||||
|
|
||||||
## API Guide
|
|
||||||
|
|
||||||
API Reference guide is auto-generated by swagger and available on:
|
|
||||||
`https://gitea.your.host/api/swagger`
|
|
||||||
or on the
|
|
||||||
[Gitea demo instance](https://try.gitea.io/api/swagger)
|
|
||||||
|
|
||||||
The OpenAPI document is at:
|
|
||||||
`https://gitea.your.host/swagger.v1.json`
|
|
||||||
|
|
||||||
## Sudo
|
|
||||||
|
|
||||||
The API allows admin users to sudo API requests as another user. Simply add either a `sudo=` parameter or `Sudo:` request header with the username of the user to sudo.
|
|
||||||
|
|
||||||
## SDKs
|
|
||||||
|
|
||||||
- [Official go-sdk](https://gitea.com/gitea/go-sdk)
|
|
||||||
- [more](https://gitea.com/gitea/awesome-gitea#user-content-sdk)
|
|
|
@ -1,72 +0,0 @@
|
||||||
---
|
|
||||||
date: "2018-06-24:00:00+02:00"
|
|
||||||
title: "API 使用指南"
|
|
||||||
slug: "api-usage"
|
|
||||||
sidebar_position: 40
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/api-usage
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "API 使用指南"
|
|
||||||
sidebar_position: 40
|
|
||||||
identifier: "api-usage"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Gitea API 使用指南
|
|
||||||
|
|
||||||
## 开启/配置 API 访问
|
|
||||||
|
|
||||||
通常情况下, `ENABLE_SWAGGER` 默认开启并且参数 `MAX_RESPONSE_ITEMS` 默认为 50。您可以从 [Config Cheat Sheet](administration/config-cheat-sheet.md) 中获取更多配置相关信息。
|
|
||||||
|
|
||||||
## 通过 API 认证
|
|
||||||
|
|
||||||
Gitea 支持以下几种 API 认证方式:
|
|
||||||
|
|
||||||
- HTTP basic authentication 方式
|
|
||||||
- 通过指定 `token=...` URL 查询参数方式
|
|
||||||
- 通过指定 `access_token=...` URL 查询参数方式
|
|
||||||
- 通过指定 `Authorization: token ...` HTTP header 方式
|
|
||||||
|
|
||||||
以上提及的认证方法接受相同的 apiKey token 类型,您可以在编码时通过查阅代码更好地理解这一点。
|
|
||||||
Gitea 调用解析查询参数以及头部信息来获取 token 的代码可以在 [modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47) 中找到。
|
|
||||||
|
|
||||||
您可以通过您的 gitea web 界面来创建 apiKey token:
|
|
||||||
`Settings | Applications | Generate New Token`.
|
|
||||||
|
|
||||||
### 关于 `Authorization:` header
|
|
||||||
|
|
||||||
由于一些历史原因,Gitea 需要在 header 的 apiKey token 里引入前缀 `token`,类似于如下形式:
|
|
||||||
|
|
||||||
```
|
|
||||||
Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675
|
|
||||||
```
|
|
||||||
|
|
||||||
以 `curl` 命令为例,它会以如下形式携带在请求中:
|
|
||||||
|
|
||||||
```
|
|
||||||
curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \
|
|
||||||
-H "accept: application/json" \
|
|
||||||
-H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \
|
|
||||||
-H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i
|
|
||||||
```
|
|
||||||
|
|
||||||
正如上例所示,您也可以在 GET 请求中使用同一个 token 并以 `token=` 的查询参数形式携带 token 来进行认证。
|
|
||||||
|
|
||||||
## 通过 API 列出您发布的令牌
|
|
||||||
|
|
||||||
`/users/:name/tokens` 是一个特殊的接口,需要您使用 basic authentication 进行认证,具体原因在 issue 中
|
|
||||||
[#3842](https://github.com/go-gitea/gitea/issues/3842#issuecomment-397743346) 有所提及,使用方法如下所示:
|
|
||||||
|
|
||||||
### 使用 Basic authentication 认证:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ curl --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
|
|
||||||
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}]
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用 Sudo 方式请求 API
|
|
||||||
|
|
||||||
此 API 允许管理员借用其他用户身份进行 API 请求。只需在请求中指定查询参数 `sudo=` 或是指定 header 中的 `Sudo:` 为需要使用的用户 username 即可。
|
|
|
@ -1,374 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "Hacking on Gitea"
|
|
||||||
slug: "hacking-on-gitea"
|
|
||||||
sidebar_position: 10
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/hacking-on-gitea
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "Hacking on Gitea"
|
|
||||||
sidebar_position: 10
|
|
||||||
identifier: "hacking-on-gitea"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Hacking on Gitea
|
|
||||||
|
|
||||||
## Quickstart
|
|
||||||
|
|
||||||
To get a quick working development environment you could use Gitpod.
|
|
||||||
|
|
||||||
[![Open in Gitpod](/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea)
|
|
||||||
|
|
||||||
## Installing go
|
|
||||||
|
|
||||||
You should [install go](https://go.dev/doc/install) and set up your go
|
|
||||||
environment correctly.
|
|
||||||
|
|
||||||
Next, [install Node.js with npm](https://nodejs.org/en/download/) which is
|
|
||||||
required to build the JavaScript and CSS files. The minimum supported Node.js
|
|
||||||
version is @minNodeVersion@ and the latest LTS version is recommended.
|
|
||||||
|
|
||||||
**Note**: When executing make tasks that require external tools, like
|
|
||||||
`make watch-backend`, Gitea will automatically download and build these as
|
|
||||||
necessary. To be able to use these you must have the `"$GOPATH"/bin` directory
|
|
||||||
on the executable path. If you don't add the go bin directory to the
|
|
||||||
executable path you will have to manage this yourself.
|
|
||||||
|
|
||||||
**Note 2**: Go version @minGoVersion@ or higher is required.
|
|
||||||
Gitea uses `gofmt` to format source code. However, the results of
|
|
||||||
`gofmt` can differ by the version of `go`. Therefore it is
|
|
||||||
recommended to install the version of Go that our continuous integration is
|
|
||||||
running. As of last update, the Go version should be @goVersion@.
|
|
||||||
|
|
||||||
To lint the template files, ensure [Python](https://www.python.org/) and
|
|
||||||
[Poetry](https://python-poetry.org/) are installed.
|
|
||||||
|
|
||||||
## Installing Make
|
|
||||||
|
|
||||||
Gitea makes heavy use of Make to automate tasks and improve development. This
|
|
||||||
guide covers how to install Make.
|
|
||||||
|
|
||||||
### On Linux
|
|
||||||
|
|
||||||
Install with the package manager.
|
|
||||||
|
|
||||||
On Ubuntu/Debian:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt-get install make
|
|
||||||
```
|
|
||||||
|
|
||||||
On Fedora/RHEL/CentOS:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo yum install make
|
|
||||||
```
|
|
||||||
|
|
||||||
### On Windows
|
|
||||||
|
|
||||||
One of these three distributions of Make will run on Windows:
|
|
||||||
|
|
||||||
- [Single binary build](http://www.equation.com/servlet/equation.cmd?fa=make). Copy somewhere and add to `PATH`.
|
|
||||||
- [32-bits version](http://www.equation.com/ftpdir/make/32/make.exe)
|
|
||||||
- [64-bits version](http://www.equation.com/ftpdir/make/64/make.exe)
|
|
||||||
- [MinGW-w64](https://www.mingw-w64.org) / [MSYS2](https://www.msys2.org/).
|
|
||||||
- MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software, it includes MinGW-w64.
|
|
||||||
- In MingGW-w64, the binary is called `mingw32-make.exe` instead of `make.exe`. Add the `bin` folder to `PATH`.
|
|
||||||
- In MSYS2, you can use `make` directly. See [MSYS2 Porting](https://www.msys2.org/wiki/Porting/).
|
|
||||||
- To compile Gitea with CGO_ENABLED (eg: SQLite3), you might need to use [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) instead of MSYS2 gcc, because MSYS2 gcc headers lack some Windows-only CRT functions like `_beginthread`.
|
|
||||||
- [Chocolatey package](https://chocolatey.org/packages/make). Run `choco install make`
|
|
||||||
|
|
||||||
**Note**: If you are attempting to build using make with Windows Command Prompt, you may run into issues. The above prompts (Git bash, or MinGW) are recommended, however if you only have command prompt (or potentially PowerShell) you can set environment variables using the [set](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1) command, e.g. `set TAGS=bindata`.
|
|
||||||
|
|
||||||
## Downloading and cloning the Gitea source code
|
|
||||||
|
|
||||||
The recommended method of obtaining the source code is by using `git clone`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/go-gitea/gitea
|
|
||||||
```
|
|
||||||
|
|
||||||
(Since the advent of go modules, it is no longer necessary to build go projects
|
|
||||||
from within the `$GOPATH`, hence the `go get` approach is no longer recommended.)
|
|
||||||
|
|
||||||
## Forking Gitea
|
|
||||||
|
|
||||||
Download the main Gitea source code as above. Then, fork the
|
|
||||||
[Gitea repository](https://github.com/go-gitea/gitea) on GitHub,
|
|
||||||
and either switch the git remote origin for your fork or add your fork as another remote:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Rename original Gitea origin to upstream
|
|
||||||
git remote rename origin upstream
|
|
||||||
git remote add origin "git@github.com:$GITHUB_USERNAME/gitea.git"
|
|
||||||
git fetch --all --prune
|
|
||||||
```
|
|
||||||
|
|
||||||
or:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Add new remote for our fork
|
|
||||||
git remote add "$FORK_NAME" "git@github.com:$GITHUB_USERNAME/gitea.git"
|
|
||||||
git fetch --all --prune
|
|
||||||
```
|
|
||||||
|
|
||||||
To be able to create pull requests, the forked repository should be added as a remote
|
|
||||||
to the Gitea sources. Otherwise, changes can't be pushed.
|
|
||||||
|
|
||||||
## Building Gitea (Basic)
|
|
||||||
|
|
||||||
Take a look at our
|
|
||||||
[instructions](installation/from-source.md)
|
|
||||||
for [building from source](installation/from-source.md).
|
|
||||||
|
|
||||||
The simplest recommended way to build from source is:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TAGS="bindata sqlite sqlite_unlock_notify" make build
|
|
||||||
```
|
|
||||||
|
|
||||||
The `build` target will execute both `frontend` and `backend` sub-targets. If the `bindata` tag is present, the frontend files will be compiled into the binary. It is recommended to leave out the tag when doing frontend development so that changes will be reflected.
|
|
||||||
|
|
||||||
See `make help` for all available `make` targets. Also see [`.drone.yml`](https://github.com/go-gitea/gitea/blob/main/.drone.yml) to see how our continuous integration works.
|
|
||||||
|
|
||||||
## Building continuously
|
|
||||||
|
|
||||||
To run and continuously rebuild when source files change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# for both frontend and backend
|
|
||||||
make watch
|
|
||||||
|
|
||||||
# or: watch frontend files (html/js/css) only
|
|
||||||
make watch-frontend
|
|
||||||
|
|
||||||
# or: watch backend files (go) only
|
|
||||||
make watch-backend
|
|
||||||
```
|
|
||||||
|
|
||||||
On macOS, watching all backend source files may hit the default open files limit which can be increased via `ulimit -n 12288` for the current shell or in your shell startup file for all future shells.
|
|
||||||
|
|
||||||
### Formatting, code analysis and spell check
|
|
||||||
|
|
||||||
Our continuous integration will reject PRs that fail the code linters (including format check, code analysis and spell check).
|
|
||||||
|
|
||||||
You should format your code:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make fmt
|
|
||||||
```
|
|
||||||
|
|
||||||
and lint the source code:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# lint both frontend and backend code
|
|
||||||
make lint
|
|
||||||
# lint only backend code
|
|
||||||
make lint-backend
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note**: The results of `gofmt` are dependent on the version of `go` present.
|
|
||||||
You should run the same version of go that is on the continuous integration
|
|
||||||
server as mentioned above.
|
|
||||||
|
|
||||||
### Working on JS and CSS
|
|
||||||
|
|
||||||
Frontend development should follow [Guidelines for Frontend Development](contributing/guidelines-frontend.md)
|
|
||||||
|
|
||||||
To build with frontend resources, either use the `watch-frontend` target mentioned above or just build once:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make build && ./gitea
|
|
||||||
```
|
|
||||||
|
|
||||||
Before committing, make sure the linters pass:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make lint-frontend
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuring local ElasticSearch instance
|
|
||||||
|
|
||||||
Start local ElasticSearch instance using docker:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
mkdir -p $(pwd)/data/elasticsearch
|
|
||||||
sudo chown -R 1000:1000 $(pwd)/data/elasticsearch
|
|
||||||
docker run --rm --memory="4g" -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v "$(pwd)/data/elasticsearch:/usr/share/elasticsearch/data" docker.elastic.co/elasticsearch/elasticsearch:7.16.3
|
|
||||||
```
|
|
||||||
|
|
||||||
Configure `app.ini`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[indexer]
|
|
||||||
ISSUE_INDEXER_TYPE = elasticsearch
|
|
||||||
ISSUE_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200
|
|
||||||
REPO_INDEXER_ENABLED = true
|
|
||||||
REPO_INDEXER_TYPE = elasticsearch
|
|
||||||
REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200
|
|
||||||
```
|
|
||||||
|
|
||||||
### Building and adding SVGs
|
|
||||||
|
|
||||||
SVG icons are built using the `make svg` target which compiles the icon sources into the output directory `public/assets/img/svg`. Custom icons can be added in the `web_src/svg` directory.
|
|
||||||
|
|
||||||
### Building the Logo
|
|
||||||
|
|
||||||
The PNG and SVG versions of the Gitea logo are built from a single SVG source file `assets/logo.svg` using the `TAGS="gitea" make generate-images` target. To run it, Node.js and npm must be available.
|
|
||||||
|
|
||||||
The same process can also be used to generate custom logo PNGs from a SVG source file by updating `assets/logo.svg` and running `make generate-images`. Omitting the `gitea` tag will update only the user-designated logo files.
|
|
||||||
|
|
||||||
### Updating the API
|
|
||||||
|
|
||||||
When creating new API routes or modifying existing API routes, you **MUST**
|
|
||||||
update and/or create [Swagger](https://swagger.io/docs/specification/2-0/what-is-swagger/)
|
|
||||||
documentation for these using [go-swagger](https://goswagger.io/) comments.
|
|
||||||
The structure of these comments is described in the [specification](https://goswagger.io/use/spec.html#annotation-syntax).
|
|
||||||
If you want more information about the Swagger structure, you can look at the
|
|
||||||
[Swagger 2.0 Documentation](https://swagger.io/docs/specification/2-0/basic-structure/)
|
|
||||||
or compare with a previous PR adding a new API endpoint, e.g. [PR #5483](https://github.com/go-gitea/gitea/pull/5843/files#diff-2e0a7b644cf31e1c8ef7d76b444fe3aaR20)
|
|
||||||
|
|
||||||
You should be careful not to break the API for downstream users which depend
|
|
||||||
on a stable API. In general, this means additions are acceptable, but deletions
|
|
||||||
or fundamental changes to the API will be rejected.
|
|
||||||
|
|
||||||
Once you have created or changed an API endpoint, please regenerate the Swagger
|
|
||||||
documentation using:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make generate-swagger
|
|
||||||
```
|
|
||||||
|
|
||||||
You should validate your generated Swagger file:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make swagger-validate
|
|
||||||
```
|
|
||||||
|
|
||||||
You should commit the changed swagger JSON file. The continuous integration
|
|
||||||
server will check that this has been done using:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make swagger-check
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note**: Please note you should use the Swagger 2.0 documentation, not the
|
|
||||||
OpenAPI 3 documentation.
|
|
||||||
|
|
||||||
### Creating new configuration options
|
|
||||||
|
|
||||||
When creating new configuration options, it is not enough to add them to the
|
|
||||||
`modules/setting` files. You should add information to `custom/conf/app.ini`
|
|
||||||
and to the
|
|
||||||
[configuration cheat sheet](administration/config-cheat-sheet.md)
|
|
||||||
found in `docs/content/doc/administer/config-cheat-sheet.en-us.md`
|
|
||||||
|
|
||||||
### Changing the logo
|
|
||||||
|
|
||||||
When changing the Gitea logo SVG, you will need to run and commit the results
|
|
||||||
of:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make generate-images
|
|
||||||
```
|
|
||||||
|
|
||||||
This will create the necessary Gitea favicon and others.
|
|
||||||
|
|
||||||
### Database Migrations
|
|
||||||
|
|
||||||
If you make breaking changes to any of the database persisted structs in the
|
|
||||||
`models/` directory, you will need to make a new migration. These can be found
|
|
||||||
in `models/migrations/`. You can ensure that your migrations work for the main
|
|
||||||
database types using:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make test-sqlite-migration # with SQLite switched for the appropriate database
|
|
||||||
```
|
|
||||||
|
|
||||||
## Testing
|
|
||||||
|
|
||||||
There are two types of test run by Gitea: Unit tests and Integration Tests.
|
|
||||||
|
|
||||||
### Unit Tests
|
|
||||||
|
|
||||||
Unit tests are covered by `*_test.go` in `go test` system.
|
|
||||||
You can set the environment variable `GITEA_UNIT_TESTS_LOG_SQL=1` to display all SQL statements when running the tests in verbose mode (i.e. when `GOTESTFLAGS=-v` is set).
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TAGS="bindata sqlite sqlite_unlock_notify" make test # Runs the unit tests
|
|
||||||
```
|
|
||||||
|
|
||||||
### Integration Tests
|
|
||||||
|
|
||||||
Unit tests will not and cannot completely test Gitea alone. Therefore, we
|
|
||||||
have written integration tests; however, these are database dependent.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite
|
|
||||||
```
|
|
||||||
|
|
||||||
will run the integration tests in an SQLite environment. Integration tests
|
|
||||||
require `git lfs` to be installed. Other database tests are available but
|
|
||||||
may need adjustment to the local environment.
|
|
||||||
|
|
||||||
Take a look at [`tests/integration/README.md`](https://github.com/go-gitea/gitea/blob/main/tests/integration/README.md)
|
|
||||||
for more information and how to run a single test.
|
|
||||||
|
|
||||||
### Testing for a PR
|
|
||||||
|
|
||||||
Our continuous integration will test the code passes its unit tests and that
|
|
||||||
all supported databases will pass integration test in a Docker environment.
|
|
||||||
Migration from several recent versions of Gitea will also be tested.
|
|
||||||
|
|
||||||
Please submit your PR with additional tests and integration tests as
|
|
||||||
appropriate.
|
|
||||||
|
|
||||||
## Documentation for the website
|
|
||||||
|
|
||||||
Documentation for the website is found in `docs/`. If you change this you
|
|
||||||
can test your changes to ensure that they pass continuous integration using:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make lint-md
|
|
||||||
```
|
|
||||||
|
|
||||||
## Visual Studio Code
|
|
||||||
|
|
||||||
A `launch.json` and `tasks.json` are provided within `contrib/ide/vscode` for
|
|
||||||
Visual Studio Code. Look at
|
|
||||||
[`contrib/ide/README.md`](https://github.com/go-gitea/gitea/blob/main/contrib/ide/README.md)
|
|
||||||
for more information.
|
|
||||||
|
|
||||||
## GoLand
|
|
||||||
|
|
||||||
Clicking the `Run Application` arrow on the function `func main()` in `/main.go`
|
|
||||||
can quickly start a debuggable Gitea instance.
|
|
||||||
|
|
||||||
The `Output Directory` in `Run/Debug Configuration` MUST be set to the
|
|
||||||
gitea project directory (which contains `main.go` and `go.mod`),
|
|
||||||
otherwise, the started instance's working directory is a GoLand's temporary directory
|
|
||||||
and prevents Gitea from loading dynamic resources (eg: templates) in a development environment.
|
|
||||||
|
|
||||||
To run unit tests with SQLite in GoLand, set `-tags sqlite,sqlite_unlock_notify`
|
|
||||||
in `Go tool arguments` of `Run/Debug Configuration`.
|
|
||||||
|
|
||||||
## Submitting PRs
|
|
||||||
|
|
||||||
Once you're happy with your changes, push them up and open a pull request. It
|
|
||||||
is recommended that you allow Gitea Managers and Owners to modify your PR
|
|
||||||
branches as we will need to update it to main before merging and/or may be
|
|
||||||
able to help fix issues directly.
|
|
||||||
|
|
||||||
Any PR requires two approvals from the Gitea maintainers and needs to pass the
|
|
||||||
continuous integration. Take a look at our
|
|
||||||
[`CONTRIBUTING.md`](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md)
|
|
||||||
document.
|
|
||||||
|
|
||||||
If you need more help pop on to [Discord](https://discord.gg/gitea) #Develop
|
|
||||||
and chat there.
|
|
||||||
|
|
||||||
That's it! You are ready to hack on Gitea.
|
|
|
@ -1,343 +0,0 @@
|
||||||
---
|
|
||||||
date: "2016-12-01T16:00:00+02:00"
|
|
||||||
title: "玩转 Gitea"
|
|
||||||
slug: "hacking-on-gitea"
|
|
||||||
sidebar_position: 10
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/hacking-on-gitea
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "玩转 Gitea"
|
|
||||||
sidebar_position: 10
|
|
||||||
identifier: "hacking-on-gitea"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Hacking on Gitea
|
|
||||||
|
|
||||||
## 快速入门
|
|
||||||
|
|
||||||
要获得快速工作的开发环境,您可以使用 Gitpod。
|
|
||||||
|
|
||||||
[![在 Gitpod 中打开](/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea)
|
|
||||||
|
|
||||||
## 安装 Golang
|
|
||||||
|
|
||||||
您需要 [安装 go]( https://go.dev/doc/install ) 并设置您的 go 环境。
|
|
||||||
|
|
||||||
接下来,[使用 npm 安装 Node.js](https://nodejs.org/en/download/) ,这是构建
|
|
||||||
JavaScript 和 CSS 文件的必要工具。最低支持的 Node.js 版本是 @minNodeVersion@
|
|
||||||
并且推荐使用最新的 LTS 版本。
|
|
||||||
|
|
||||||
**注意** :当执行需要外部工具的 make 任务时,比如
|
|
||||||
`make watch-backend`,Gitea 会自动下载并构建这些必要的组件。为了能够使用这些,你必须
|
|
||||||
将 `"$GOPATH"/bin` 目录加入到可执行路径上。如果你不把go bin目录添加到可执行路径你必须手动
|
|
||||||
指定可执行程序路径。
|
|
||||||
|
|
||||||
**注意2** :Go版本 @minGoVersion@ 或更高版本是必须的。Gitea 使用 `gofmt` 来
|
|
||||||
格式化源代码。然而,`gofmt` 的结果可能因 `go` 的版本而有差异。因此推荐安装我们持续集成使用
|
|
||||||
的 Go版本。截至上次更新,Go 版本应该是 @goVersion@。
|
|
||||||
|
|
||||||
## 安装 Make
|
|
||||||
|
|
||||||
Gitea 大量使用 `Make` 来自动化任务和改进开发。本指南涵盖了如何安装 Make。
|
|
||||||
|
|
||||||
### 在 Linux 上
|
|
||||||
|
|
||||||
使用包管理器安装。
|
|
||||||
|
|
||||||
在 Ubuntu/Debian 上:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt-get install make
|
|
||||||
```
|
|
||||||
|
|
||||||
在 Fedora/RHEL/CentOS 上:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo yum install make
|
|
||||||
```
|
|
||||||
|
|
||||||
### 在 Windows 上
|
|
||||||
|
|
||||||
Make 的这三个发行版都可以在 Windows 上运行:
|
|
||||||
|
|
||||||
- [单个二进制构建]( http://www.equation.com/servlet/equation.cmd?fa=make )。复制到某处并添加到 `PATH`。
|
|
||||||
- [32 位版本](http://www.equation.com/ftpdir/make/32/make.exe)
|
|
||||||
- [64 位版本](http://www.equation.com/ftpdir/make/64/make.exe)
|
|
||||||
- [MinGW-w64](https://www.mingw-w64.org) / [MSYS2](https://www.msys2.org/)。
|
|
||||||
- MSYS2 是一个工具和库的集合,为您提供一个易于使用的环境来构建、安装和运行本机 Windows 软件,它包括 MinGW-w64。
|
|
||||||
- 在 MingGW-w64 中,二进制文件称为 `mingw32-make.exe` 而不是 `make.exe`。将 `bin` 文件夹添加到 `PATH`。
|
|
||||||
- 在 MSYS2 中,您可以直接使用 `make`。请参阅 [MSYS2 移植](https://www.msys2.org/wiki/Porting/)。
|
|
||||||
- 要使用 CGO_ENABLED(例如:SQLite3)编译 Gitea,您可能需要使用 [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) 而不是 MSYS2 gcc,因为 MSYS2 gcc 标头缺少一些 Windows -只有 CRT 函数像 _beginthread 一样。
|
|
||||||
- [Chocolatey包管理器]( https://chocolatey.org/packages/make )。运行`choco install make`
|
|
||||||
|
|
||||||
**注意** :如果您尝试在 Windows 命令提示符下使用 make 进行构建,您可能会遇到问题。建议使用上述提示(Git bash 或 MinGW),但是如果您只有命令提示符(或可能是 PowerShell),则可以使用 [set](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1) 命令,例如 `set TAGS=bindata`。
|
|
||||||
|
|
||||||
## 下载并克隆 Gitea 源代码
|
|
||||||
|
|
||||||
获取源代码的推荐方法是使用 `git clone`。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/go-gitea/gitea
|
|
||||||
```
|
|
||||||
|
|
||||||
(自从go modules出现后,不再需要构建 go 项目从 `$GOPATH` 中获取,因此不再推荐使用 `go get` 方法。)
|
|
||||||
|
|
||||||
## 派生 Gitea
|
|
||||||
|
|
||||||
如上所述下载主要的 Gitea 源代码。然后,派生 [Gitea 仓库](https://github.com/go-gitea/gitea),
|
|
||||||
并为您的本地仓库切换 git 远程源,或添加另一个远程源:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 将原来的 Gitea origin 重命名为 upstream
|
|
||||||
git remote rename origin upstream
|
|
||||||
git remote add origin "git@github.com:$GITHUB_USERNAME/gitea.git"
|
|
||||||
git fetch --all --prune
|
|
||||||
```
|
|
||||||
|
|
||||||
或者:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 为我们的 fork 添加新的远程
|
|
||||||
git remote add "$FORK_NAME" "git@github.com:$GITHUB_USERNAME/gitea.git"
|
|
||||||
git fetch --all --prune
|
|
||||||
```
|
|
||||||
|
|
||||||
为了能够创建合并请求,应将分叉存储库添加为 Gitea 本地仓库的远程,否则无法推送更改。
|
|
||||||
|
|
||||||
## 构建 Gitea(基本)
|
|
||||||
|
|
||||||
看看我们的
|
|
||||||
[说明](installation/from-source.md)
|
|
||||||
关于如何[从源代码构建](installation/from-source.md) 。
|
|
||||||
|
|
||||||
从源代码构建的最简单推荐方法是:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TAGS="bindata sqlite sqlite_unlock_notify" make build
|
|
||||||
```
|
|
||||||
|
|
||||||
`build` 目标将同时执行 `frontend` 和 `backend` 子目标。如果存在 `bindata` 标签,资源文件将被编译成二进制文件。建议在进行前端开发时省略 `bindata` 标签,以便实时反映更改。
|
|
||||||
|
|
||||||
有关所有可用的 `make` 目标,请参阅 `make help`。另请参阅 [`.drone.yml`](https://github.com/go-gitea/gitea/blob/main/.drone.yml) 以了解我们的持续集成是如何工作的。
|
|
||||||
|
|
||||||
## 持续构建
|
|
||||||
|
|
||||||
要在源文件更改时运行并持续构建:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 对于前端和后端
|
|
||||||
make watch
|
|
||||||
|
|
||||||
# 或者:只看前端文件(html/js/css)
|
|
||||||
make watch-frontend
|
|
||||||
|
|
||||||
# 或者:只看后端文件 (go)
|
|
||||||
make watch-backend
|
|
||||||
```
|
|
||||||
|
|
||||||
在 macOS 上,监视所有后端源文件可能会达到默认的打开文件限制,这可以通过当前 shell 的 `ulimit -n 12288` 或所有未来 shell 的 shell 启动文件来增加。
|
|
||||||
|
|
||||||
### 格式化、代码分析和拼写检查
|
|
||||||
|
|
||||||
我们的持续集成将拒绝未通过代码检查(包括格式检查、代码分析和拼写检查)的 PR。
|
|
||||||
|
|
||||||
你应该格式化你的代码:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make fmt
|
|
||||||
```
|
|
||||||
|
|
||||||
并检查源代码:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# lint 前端和后端代码
|
|
||||||
make lint
|
|
||||||
# 仅 lint 后端代码
|
|
||||||
make lint-backend
|
|
||||||
```
|
|
||||||
|
|
||||||
**注意** :`gofmt` 的结果取决于 `go` 的版本。您应该运行与持续集成相同的 go 版本。
|
|
||||||
|
|
||||||
### 处理 JS 和 CSS
|
|
||||||
|
|
||||||
前端开发应遵循 [Guidelines for Frontend Development](contributing/guidelines-frontend.md)。
|
|
||||||
|
|
||||||
要使用前端资源构建,请使用上面提到的“watch-frontend”目标或只构建一次:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make build && ./gitea
|
|
||||||
```
|
|
||||||
|
|
||||||
在提交之前,确保 linters 通过:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make lint-frontend
|
|
||||||
```
|
|
||||||
|
|
||||||
### 配置本地 ElasticSearch 实例
|
|
||||||
|
|
||||||
使用 docker 启动本地 ElasticSearch 实例:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
mkdir -p $(pwd) /data/elasticsearch
|
|
||||||
sudo chown -R 1000:1000 $(pwd) /data/elasticsearch
|
|
||||||
docker run --rm --memory= "4g" -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v "$(pwd)/data /elasticsearch:/usr/share/elasticsearch/data" docker.elastic.co/elasticsearch/elasticsearch:7.16.3
|
|
||||||
```
|
|
||||||
|
|
||||||
配置`app.ini`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[indexer]
|
|
||||||
ISSUE_INDEXER_TYPE = elasticsearch
|
|
||||||
ISSUE_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200
|
|
||||||
REPO_INDEXER_ENABLED = true
|
|
||||||
REPO_INDEXER_TYPE = elasticsearch
|
|
||||||
REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200
|
|
||||||
```
|
|
||||||
|
|
||||||
### 构建和添加 SVGs
|
|
||||||
|
|
||||||
SVG 图标是使用 `make svg` 命令构建的,该命令将图标资源编译到输出目录 `public/assets/img/svg` 中。可以在 `web_src/svg` 目录中添加自定义图标。
|
|
||||||
|
|
||||||
### 构建 Logo
|
|
||||||
|
|
||||||
Gitea Logo的 PNG 和 SVG 版本是使用 `TAGS="gitea" make generate-images` 目标从单个 SVG 源文件 assets/logo.svg 构建的。要运行它,Node.js 和 npm 必须可用。
|
|
||||||
|
|
||||||
通过更新 `assets/logo.svg` 并运行 `make generate-images`,同样的过程也可用于从 SVG 源文件生成自定义 Logo PNG。忽略 gitea 编译选项将仅更新用户指定的 LOGO 文件。
|
|
||||||
|
|
||||||
### 更新 API
|
|
||||||
|
|
||||||
创建新的 API 路由或修改现有的 API 路由时,您**必须**
|
|
||||||
更新和/或创建 [Swagger](https://swagger.io/docs/specification/2-0/what-is-swagger/)
|
|
||||||
这些使用 [go-swagger](https://goswagger.io/) 评论的文档。
|
|
||||||
[规范]( https://goswagger.io/use/spec.html#annotation-syntax )中描述了这些注释的结构。
|
|
||||||
如果您想了解更多有关 Swagger 结构的信息,可以查看
|
|
||||||
[Swagger 2.0 文档](https://swagger.io/docs/specification/2-0/basic-structure/)
|
|
||||||
或与添加新 API 端点的先前 PR 进行比较,例如 [PR #5483](https://github.com/go-gitea/gitea/pull/5843/files#diff-2e0a7b644cf31e1c8ef7d76b444fe3aaR20)
|
|
||||||
|
|
||||||
您应该注意不要破坏下游用户依赖的 API。在稳定的 API 上,一般来说添加是可以接受的,但删除
|
|
||||||
或对 API 进行根本性更改将会被拒绝。
|
|
||||||
|
|
||||||
创建或更改 API 端点后,请用以下命令重新生成 Swagger 文档:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make generate-swagger
|
|
||||||
```
|
|
||||||
|
|
||||||
您应该验证生成的 Swagger 文件:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make swagger-validate
|
|
||||||
```
|
|
||||||
|
|
||||||
您应该提交更改后的 swagger JSON 文件。持续集成服务器将使用以下方法检查是否已完成:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make swagger-check
|
|
||||||
```
|
|
||||||
|
|
||||||
**注意** :请注意,您应该使用 Swagger 2.0 文档,而不是 OpenAPI 3 文档。
|
|
||||||
|
|
||||||
### 创建新的配置选项
|
|
||||||
|
|
||||||
创建新的配置选项时,将它们添加到 `modules/setting` 的对应文件。您应该将信息添加到 `custom/conf/app.ini`
|
|
||||||
并到[配置备忘单](administration/config-cheat-sheet.md)
|
|
||||||
在 `docs/content/doc/advanced/config-cheat-sheet.zh-cn.md` 中找到
|
|
||||||
|
|
||||||
### 更改Logo
|
|
||||||
|
|
||||||
更改 Gitea Logo SVG 时,您将需要运行并提交结果的:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make generate-images
|
|
||||||
```
|
|
||||||
|
|
||||||
这将创建必要的 Gitea 图标和其他图标。
|
|
||||||
|
|
||||||
### 数据库迁移
|
|
||||||
|
|
||||||
如果您对数据库中的任何数据库持久结构进行重大更改
|
|
||||||
`models/` 目录,您将需要进行新的迁移。可以找到这些
|
|
||||||
在 `models/migrations/` 中。您可以确保您的迁移适用于主要
|
|
||||||
数据库类型使用:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make test-sqlite-migration # 将 SQLite 切换为适当的数据库
|
|
||||||
```
|
|
||||||
|
|
||||||
## 测试
|
|
||||||
|
|
||||||
Gitea 运行两种类型的测试:单元测试和集成测试。
|
|
||||||
|
|
||||||
### 单元测试
|
|
||||||
|
|
||||||
`go test` 系统中的`*_test.go` 涵盖了单元测试。
|
|
||||||
您可以设置环境变量 `GITEA_UNIT_TESTS_LOG_SQL=1` 以在详细模式下运行测试时显示所有 SQL 语句(即设置`GOTESTFLAGS=-v` 时)。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TAGS="bindata sqlite sqlite_unlock_notify" make test # Runs the unit tests
|
|
||||||
```
|
|
||||||
|
|
||||||
### 集成测试
|
|
||||||
|
|
||||||
单元测试不会也不能完全单独测试 Gitea。因此,我们编写了集成测试;但是,这些依赖于数据库。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite
|
|
||||||
```
|
|
||||||
|
|
||||||
将在 SQLite 环境中运行集成测试。集成测试需要安装 `git lfs`。其他数据库测试可用,但
|
|
||||||
可能需要适应当地环境。
|
|
||||||
|
|
||||||
看看 [`tests/integration/README.md`](https://github.com/go-gitea/gitea/blob/main/tests/integration/README.md) 有关更多信息以及如何运行单个测试。
|
|
||||||
|
|
||||||
### 测试 PR
|
|
||||||
|
|
||||||
我们的持续集成将测试代码是否通过了单元测试,并且所有支持的数据库都将在 Docker 环境中通过集成测试。
|
|
||||||
还将测试从几个最新版本的 Gitea 迁移。
|
|
||||||
|
|
||||||
请在PR中附带提交适当的单元测试和集成测试。
|
|
||||||
|
|
||||||
## 网站文档
|
|
||||||
|
|
||||||
该网站的文档位于 `docs/` 中。如果你改变了文档内容,你可以使用以下测试方法进行持续集成:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make lint-md
|
|
||||||
```
|
|
||||||
|
|
||||||
## Visual Studio Code
|
|
||||||
|
|
||||||
`contrib/ide/vscode` 中为 Visual Studio Code 提供了 `launch.json` 和 `tasks.json`。查看
|
|
||||||
[`contrib/ide/README.md`](https://github.com/go-gitea/gitea/blob/main/contrib/ide/README.md) 了解更多信息。
|
|
||||||
|
|
||||||
## Goland
|
|
||||||
|
|
||||||
单击 `/main.go` 中函数 `func main()` 上的 `Run Application` 箭头
|
|
||||||
可以快速启动一个可调试的 Gitea 实例。
|
|
||||||
|
|
||||||
`Run/Debug Configuration` 中的 `Output Directory` 必须设置为
|
|
||||||
gitea 项目目录(包含 `main.go` 和 `go.mod`),
|
|
||||||
否则,启动实例的工作目录是 GoLand 的临时目录
|
|
||||||
并防止 Gitea 在开发环境中加载动态资源(例如:模板)。
|
|
||||||
|
|
||||||
要在 GoLand 中使用 SQLite 运行单元测试,请设置 `-tags sqlite,sqlite_unlock_notify`
|
|
||||||
在 `运行/调试配置` 的 `Go 工具参数` 中。
|
|
||||||
|
|
||||||
## 提交 PR
|
|
||||||
|
|
||||||
对更改感到满意后,将它们推送并打开拉取请求。它建议您允许 Gitea Managers 和 Owners 修改您的 PR
|
|
||||||
分支,因为我们需要在合并之前将其更新为 main 和/或可能是能够直接帮助解决问题。
|
|
||||||
|
|
||||||
任何 PR 都需要 Gitea 维护者的两次批准,并且需要通过持续集成。看看我们的
|
|
||||||
[CONTRIBUTING.md](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md)
|
|
||||||
文档。
|
|
||||||
|
|
||||||
如果您需要更多帮助,请访问 [Discord](https://discord.gg/gitea) #Develop 频道
|
|
||||||
并在那里聊天。
|
|
||||||
|
|
||||||
现在,您已准备好 Hacking Gitea。
|
|
|
@ -1,47 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-04-15T17:29:00+08:00"
|
|
||||||
title: "Integrations"
|
|
||||||
slug: "integrations"
|
|
||||||
sidebar_position: 65
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/integrations
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "Integrations"
|
|
||||||
sidebar_position: 65
|
|
||||||
identifier: "integrations"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Integrations
|
|
||||||
|
|
||||||
Gitea has a wonderful community of third-party integrations, as well as first-class support in various other
|
|
||||||
projects.
|
|
||||||
|
|
||||||
We are curating a list over at [awesome-gitea](https://gitea.com/gitea/awesome-gitea) to track these!
|
|
||||||
|
|
||||||
If you are looking for [CI/CD](https://gitea.com/gitea/awesome-gitea#user-content-devops),
|
|
||||||
an [SDK](https://gitea.com/gitea/awesome-gitea#user-content-sdk),
|
|
||||||
or even some extra [themes](https://gitea.com/gitea/awesome-gitea#user-content-themes),
|
|
||||||
you can find them listed in the [awesome-gitea](https://gitea.com/gitea/awesome-gitea) repository!
|
|
||||||
|
|
||||||
## Pre-Fill New File name and contents
|
|
||||||
|
|
||||||
If you'd like to open a new file with a given name and contents,
|
|
||||||
you can do so with query parameters:
|
|
||||||
|
|
||||||
```txt
|
|
||||||
GET /{{org}}/{{repo}}/_new/{{filepath}}
|
|
||||||
?filename={{filename}}
|
|
||||||
&value={{content}}
|
|
||||||
```
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```txt
|
|
||||||
GET https://git.example.com/johndoe/bliss/_new/articles/
|
|
||||||
?filename=hello-world.md
|
|
||||||
&value=Hello%2C%20World!
|
|
||||||
```
|
|
|
@ -1,46 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-25T17:29:00+08:00"
|
|
||||||
title: "集成"
|
|
||||||
slug: "integrations"
|
|
||||||
sidebar_position: 65
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/integrations
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "集成"
|
|
||||||
sidebar_position: 65
|
|
||||||
identifier: "integrations"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 集成
|
|
||||||
|
|
||||||
Gitea拥有一个出色的第三方集成社区,以及在其他各种项目中的一流支持。
|
|
||||||
|
|
||||||
我们正在[awesome-gitea](https://gitea.com/gitea/awesome-gitea)上整理一个列表来跟踪这些集成!
|
|
||||||
|
|
||||||
如果你正在寻找[CI/CD](https://gitea.com/gitea/awesome-gitea#user-content-devops),
|
|
||||||
一个[SDK](https://gitea.com/gitea/awesome-gitea#user-content-sdk),
|
|
||||||
甚至一些额外的[主题](https://gitea.com/gitea/awesome-gitea#user-content-themes),
|
|
||||||
你可以在[awesome-gitea](https://gitea.com/gitea/awesome-gitea)中找到它们的列表!
|
|
||||||
|
|
||||||
## 预填新文件名和内容
|
|
||||||
|
|
||||||
如果你想打开一个具有给定名称和内容的新文件,
|
|
||||||
你可以使用查询参数来实现:
|
|
||||||
|
|
||||||
```txt
|
|
||||||
GET /{{org}}/{{repo}}/_new/{{filepath}}
|
|
||||||
?filename={{filename}}
|
|
||||||
&value={{content}}
|
|
||||||
```
|
|
||||||
|
|
||||||
例如:
|
|
||||||
|
|
||||||
```txt
|
|
||||||
GET https://git.example.com/johndoe/bliss/_new/articles/
|
|
||||||
?filename=hello-world.md
|
|
||||||
&value=Hello%2C%20World!
|
|
||||||
```
|
|
|
@ -1,43 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-04-15T17:29:00+08:00"
|
|
||||||
title: "Migrations Interfaces"
|
|
||||||
slug: "migrations-interfaces"
|
|
||||||
sidebar_position: 55
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/migrations-interfaces
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "Migrations Interfaces"
|
|
||||||
sidebar_position: 55
|
|
||||||
identifier: "migrations-interfaces"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Migration Features
|
|
||||||
|
|
||||||
Complete migrations were introduced in Gitea 1.9.0. It defines two interfaces to support migrating
|
|
||||||
repository data from other Git host platforms to Gitea or, in the future, migrating Gitea data to other Git host platforms.
|
|
||||||
|
|
||||||
Currently, migrations from GitHub, GitLab, and other Gitea instances are implemented.
|
|
||||||
|
|
||||||
First of all, Gitea defines some standard objects in packages [modules/migration](https://github.com/go-gitea/gitea/tree/main/modules/migration).
|
|
||||||
They are `Repository`, `Milestone`, `Release`, `ReleaseAsset`, `Label`, `Issue`, `Comment`, `PullRequest`, `Reaction`, `Review`, `ReviewComment`.
|
|
||||||
|
|
||||||
## Downloader Interfaces
|
|
||||||
|
|
||||||
To migrate from a new Git host platform, there are two steps to be updated.
|
|
||||||
|
|
||||||
- You should implement a `Downloader` which will be used to get repository information.
|
|
||||||
- You should implement a `DownloaderFactory` which will be used to detect if the URL matches and create the above `Downloader`.
|
|
||||||
- You'll need to register the `DownloaderFactory` via `RegisterDownloaderFactory` on `init()`.
|
|
||||||
|
|
||||||
You can find these interfaces in [downloader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/downloader.go).
|
|
||||||
|
|
||||||
## Uploader Interface
|
|
||||||
|
|
||||||
Currently, only a `GiteaLocalUploader` is implemented, so we only save downloaded
|
|
||||||
data via this `Uploader` to the local Gitea instance. Other uploaders are not supported at this time.
|
|
||||||
|
|
||||||
You can find these interfaces in [uploader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/uploader.go).
|
|
|
@ -1,40 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-05-25T17:29:00+08:00"
|
|
||||||
title: "迁移界面"
|
|
||||||
slug: "migrations-interfaces"
|
|
||||||
sidebar_position: 55
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/migrations-interfaces
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "迁移界面"
|
|
||||||
sidebar_position: 55
|
|
||||||
identifier: "migrations-interfaces"
|
|
||||||
---
|
|
||||||
|
|
||||||
# 迁移功能
|
|
||||||
|
|
||||||
完整迁移功能在Gitea 1.9.0版本中引入。它定义了两个接口,用于支持从其他Git托管平台迁移存储库数据到Gitea,或者在将来将Gitea数据迁移到其他Git托管平台。
|
|
||||||
|
|
||||||
目前已实现了从GitHub、GitLab和其他Gitea实例的迁移。
|
|
||||||
|
|
||||||
首先,Gitea在包[modules/migration](https://github.com/go-gitea/gitea/tree/main/modules/migration)中定义了一些标准对象。它们是`Repository`、`Milestone`、`Release`、`ReleaseAsset`、`Label`、`Issue`、`Comment`、`PullRequest`、`Reaction`、`Review`、`ReviewComment`。
|
|
||||||
|
|
||||||
## 下载器接口
|
|
||||||
|
|
||||||
要从新的Git托管平台迁移,需要进行两个步骤的更新。
|
|
||||||
|
|
||||||
- 您应该实现一个`Downloader`,用于获取存储库信息。
|
|
||||||
- 您应该实现一个`DownloaderFactory`,用于检测URL是否匹配,并创建上述的`Downloader`。
|
|
||||||
- 您需要在`init()`中通过`RegisterDownloaderFactory`注册`DownloaderFactory`。
|
|
||||||
|
|
||||||
您可以在[downloader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/downloader.go)中找到这些接口。
|
|
||||||
|
|
||||||
## 上传器接口
|
|
||||||
|
|
||||||
目前,只实现了`GiteaLocalUploader`,因此我们只能通过此Uploader将下载的数据保存到本地的Gitea实例。目前不支持其他上传器。
|
|
||||||
|
|
||||||
您可以在[uploader.go](https://github.com/go-gitea/gitea/blob/main/modules/migration/uploader.go)中找到这些接口。
|
|
|
@ -1,214 +0,0 @@
|
||||||
---
|
|
||||||
date: "2023-06-01T08:40:00+08:00"
|
|
||||||
title: "OAuth2 provider"
|
|
||||||
slug: "oauth2-provider"
|
|
||||||
sidebar_position: 41
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/oauth2-provider
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "OAuth2 Provider"
|
|
||||||
sidebar_position: 41
|
|
||||||
identifier: "oauth2-provider"
|
|
||||||
---
|
|
||||||
|
|
||||||
# OAuth2 provider
|
|
||||||
|
|
||||||
Gitea supports acting as an OAuth2 provider to allow third party applications to access its resources with the user's consent. This feature is available since release 1.8.0.
|
|
||||||
|
|
||||||
## Endpoints
|
|
||||||
|
|
||||||
| Endpoint | URL |
|
|
||||||
| ------------------------ | ----------------------------------- |
|
|
||||||
| OpenID Connect Discovery | `/.well-known/openid-configuration` |
|
|
||||||
| Authorization Endpoint | `/login/oauth/authorize` |
|
|
||||||
| Access Token Endpoint | `/login/oauth/access_token` |
|
|
||||||
| OpenID Connect UserInfo | `/login/oauth/userinfo` |
|
|
||||||
| JSON Web Key Set | `/login/oauth/keys` |
|
|
||||||
|
|
||||||
## Supported OAuth2 Grants
|
|
||||||
|
|
||||||
At the moment Gitea only supports the [**Authorization Code Grant**](https://tools.ietf.org/html/rfc6749#section-1.3.1) standard with additional support of the following extensions:
|
|
||||||
|
|
||||||
- [Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636)
|
|
||||||
- [OpenID Connect (OIDC)](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
|
|
||||||
|
|
||||||
To use the Authorization Code Grant as a third party application it is required to register a new application via the "Settings" (`/user/settings/applications`) section of the settings. To test or debug you can use the web-tool https://oauthdebugger.com/.
|
|
||||||
|
|
||||||
## Scopes
|
|
||||||
|
|
||||||
Gitea supports scoped access tokens, which allow users the ability to restrict tokens to operate only on selected url routes. Scopes are grouped by high-level API routes, and further refined to the following:
|
|
||||||
|
|
||||||
- `read`: `GET` routes
|
|
||||||
- `write`: `POST`, `PUT`, `PATCH`, and `DELETE` routes (in addition to `GET`)
|
|
||||||
|
|
||||||
Gitea token scopes are as follows:
|
|
||||||
|
|
||||||
| Name | Description |
|
|
||||||
| ---- |------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| **(no scope)** | Not supported. A scope is required even for public repositories. |
|
|
||||||
| **activitypub** | `activitypub` API routes: ActivityPub related operations. |
|
|
||||||
| **read:activitypub** | Grants read access for ActivityPub operations. |
|
|
||||||
| **write:activitypub** | Grants read/write/delete access for ActivityPub operations. |
|
|
||||||
| **admin** | `/admin/*` API routes: Site-wide administrative operations (hidden for non-admin accounts). |
|
|
||||||
| **read:admin** | Grants read access for admin operations, such as getting cron jobs or registered user emails. |
|
|
||||||
| **write:admin** | Grants read/write/delete access for admin operations, such as running cron jobs or updating user accounts. |
|
|
||||||
| **issue** | `issues/*`, `labels/*`, `milestones/*` API routes: Issue-related operations. |
|
|
||||||
| **read:issue** | Grants read access for issues operations, such as getting issue comments, issue attachments, and milestones. |
|
|
||||||
| **write:issue** | Grants read/write/delete access for issues operations, such as posting or editing an issue comment or attachment, and updating milestones. |
|
|
||||||
| **misc** | Reserved for future usage. |
|
|
||||||
| **read:misc** | Reserved for future usage. |
|
|
||||||
| **write:misc** | Reserved for future usage. |
|
|
||||||
| **notification** | `notification/*` API routes: user notification operations. |
|
|
||||||
| **read:notification** | Grants read access to user notifications, such as which notifications users are subscribed to and read new notifications. |
|
|
||||||
| **write:notification** | Grants read/write/delete access to user notifications, such as marking notifications as read. |
|
|
||||||
| **organization** | `orgs/*` and `teams/*` API routes: Organization and team management operations. |
|
|
||||||
| **read:organization** | Grants read access to org and team status, such as listing all orgs a user has visibility to, teams, and team members. |
|
|
||||||
| **write:organization** | Grants read/write/delete access to org and team status, such as creating and updating teams and updating org settings. |
|
|
||||||
| **package** | `/packages/*` API routes: Packages operations |
|
|
||||||
| **read:package** | Grants read access to package operations, such as reading and downloading available packages. |
|
|
||||||
| **write:package** | Grants read/write/delete access to package operations. Currently the same as `read:package`. |
|
|
||||||
| **repository** | `/repos/*` API routes except `/repos/issues/*`: Repository file, pull-request, and release operations. |
|
|
||||||
| **read:repository** | Grants read access to repository operations, such as getting repository files, releases, collaborators. |
|
|
||||||
| **write:repository** | Grants read/write/delete access to repository operations, such as getting updating repository files, creating pull requests, updating collaborators. |
|
|
||||||
| **user** | `/user/*` and `/users/*` API routes: User-related operations. |
|
|
||||||
| **read:user** | Grants read access to user operations, such as getting user repo subscriptions and user settings. |
|
|
||||||
| **write:user** | Grants read/write/delete access to user operations, such as updating user repo subscriptions, followed users, and user settings. |
|
|
||||||
|
|
||||||
## Pre-configured Applications
|
|
||||||
|
|
||||||
Gitea creates OAuth applications for the following services by default on startup, as we assume that these are universally useful.
|
|
||||||
|
|
||||||
|Application|Description|Client ID|
|
|
||||||
|-----------|-----------|---------|
|
|
||||||
|[git-credential-oauth](https://github.com/hickford/git-credential-oauth)|Git credential helper|`a4792ccc-144e-407e-86c9-5e7d8d9c3269`|
|
|
||||||
|[Git Credential Manager](https://github.com/git-ecosystem/git-credential-manager)|Git credential helper|`e90ee53c-94e2-48ac-9358-a874fb9e0662`|
|
|
||||||
|[tea](https://gitea.com/gitea/tea)|tea|`d57cb8c4-630c-4168-8324-ec79935e18d4`|
|
|
||||||
|
|
||||||
To prevent unexpected behavior, they are being displayed as locked in the UI and their creation can instead be controlled by the `DEFAULT_APPLICATIONS` parameter in `app.ini`.
|
|
||||||
|
|
||||||
## Client types
|
|
||||||
|
|
||||||
Gitea supports both confidential and public client types, [as defined by RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1).
|
|
||||||
|
|
||||||
For public clients, a redirect URI of a loopback IP address such as `http://127.0.0.1/` allows any port. Avoid using `localhost`, [as recommended by RFC 8252](https://datatracker.ietf.org/doc/html/rfc8252#section-8.3).
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Confidential client
|
|
||||||
|
|
||||||
**Note:** This example does not use PKCE.
|
|
||||||
|
|
||||||
1. Redirect the user to the authorization endpoint in order to get their consent for accessing the resources:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&state=STATE
|
|
||||||
```
|
|
||||||
|
|
||||||
The `CLIENT_ID` can be obtained by registering an application in the settings. The `STATE` is a random string that will be sent back to your application after the user authorizes. The `state` parameter is optional, but should be used to prevent CSRF attacks.
|
|
||||||
|
|
||||||
![Authorization Page](/authorize.png)
|
|
||||||
|
|
||||||
The user will now be asked to authorize your application. If they authorize it, the user will be redirected to the `REDIRECT_URL`, for example:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Using the provided `code` from the redirect, you can request a new application and refresh token. The access token endpoint accepts POST requests with `application/json` and `application/x-www-form-urlencoded` body, for example:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
POST https://[YOUR-GITEA-URL]/login/oauth/access_token
|
|
||||||
```
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"client_id": "YOUR_CLIENT_ID",
|
|
||||||
"client_secret": "YOUR_CLIENT_SECRET",
|
|
||||||
"code": "RETURNED_CODE",
|
|
||||||
"grant_type": "authorization_code",
|
|
||||||
"redirect_uri": "REDIRECT_URI"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Response:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug",
|
|
||||||
"token_type": "bearer",
|
|
||||||
"expires_in": 3600,
|
|
||||||
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The `CLIENT_SECRET` is the unique secret code generated for this application. Please note that the secret will only be visible after you created/registered the application with Gitea and cannot be recovered. If you lose the secret, you must regenerate the secret via the application's settings.
|
|
||||||
|
|
||||||
The `REDIRECT_URI` in the `access_token` request must match the `REDIRECT_URI` in the `authorize` request.
|
|
||||||
|
|
||||||
3. Use the `access_token` to make [API requests](development/api-usage.md#oauth2-provider) to access the user's resources.
|
|
||||||
|
|
||||||
### Public client (PKCE)
|
|
||||||
|
|
||||||
PKCE (Proof Key for Code Exchange) is an extension to the OAuth flow which allows for a secure credential exchange without the requirement to provide a client secret.
|
|
||||||
|
|
||||||
**Note**: Please ensure you have registered your OAuth application as a public client.
|
|
||||||
|
|
||||||
To achieve this, you have to provide a `code_verifier` for every authorization request. A `code_verifier` has to be a random string with a minimum length of 43 characters and a maximum length of 128 characters. It can contain alphanumeric characters as well as the characters `-`, `.`, `_` and `~`.
|
|
||||||
|
|
||||||
Using this `code_verifier` string, a new one called `code_challenge` is created by using one of two methods:
|
|
||||||
|
|
||||||
- If you have the required functionality on your client, set `code_challenge` to be a URL-safe base64-encoded string of the SHA256 hash of `code_verifier`. In that case, your `code_challenge_method` becomes `S256`.
|
|
||||||
- If you are unable to do so, you can provide your `code_verifier` as a plain string to `code_challenge`. Then you have to set your `code_challenge_method` as `plain`.
|
|
||||||
|
|
||||||
After you have generated this values, you can continue with your request.
|
|
||||||
|
|
||||||
1. Redirect the user to the authorization endpoint in order to get their consent for accessing the resources:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&code_challenge_method=CODE_CHALLENGE_METHOD&code_challenge=CODE_CHALLENGE&state=STATE
|
|
||||||
```
|
|
||||||
|
|
||||||
The `CLIENT_ID` can be obtained by registering an application in the settings. The `STATE` is a random string that will be sent back to your application after the user authorizes. The `state` parameter is optional, but should be used to prevent CSRF attacks.
|
|
||||||
|
|
||||||
![Authorization Page](/authorize.png)
|
|
||||||
|
|
||||||
The user will now be asked to authorize your application. If they authorize it, the user will be redirected to the `REDIRECT_URL`, for example:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Using the provided `code` from the redirect, you can request a new application and refresh token. The access token endpoint accepts POST requests with `application/json` and `application/x-www-form-urlencoded` body, for example:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
POST https://[YOUR-GITEA-URL]/login/oauth/access_token
|
|
||||||
```
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"client_id": "YOUR_CLIENT_ID",
|
|
||||||
"code": "RETURNED_CODE",
|
|
||||||
"grant_type": "authorization_code",
|
|
||||||
"redirect_uri": "REDIRECT_URI",
|
|
||||||
"code_verifier": "CODE_VERIFIER",
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Response:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug",
|
|
||||||
"token_type": "bearer",
|
|
||||||
"expires_in": 3600,
|
|
||||||
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The `REDIRECT_URI` in the `access_token` request must match the `REDIRECT_URI` in the `authorize` request.
|
|
||||||
|
|
||||||
3. Use the `access_token` to make [API requests](development/api-usage.md#oauth2-provider) to access the user's resources.
|
|
|
@ -1,137 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-04-19:44:00+01:00"
|
|
||||||
title: "OAuth2 提供者"
|
|
||||||
slug: "oauth2-provider"
|
|
||||||
sidebar_position: 41
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /zh-cn/oauth2-provider
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "development"
|
|
||||||
name: "OAuth2 提供者"
|
|
||||||
sidebar_position: 41
|
|
||||||
identifier: "oauth2-provider"
|
|
||||||
---
|
|
||||||
|
|
||||||
# OAuth2 提供者
|
|
||||||
|
|
||||||
Gitea 支持作为 OAuth2 提供者,允许第三方应用程序在用户同意的情况下访问其资源。此功能自 1.8.0 版起可用。
|
|
||||||
|
|
||||||
## 端点
|
|
||||||
|
|
||||||
| 端点 | URL |
|
|
||||||
| ------------------------ | ----------------------------------- |
|
|
||||||
| OpenID Connect Discovery | `/.well-known/openid-configuration` |
|
|
||||||
| Authorization Endpoint | `/login/oauth/authorize` |
|
|
||||||
| Access Token Endpoint | `/login/oauth/access_token` |
|
|
||||||
| OpenID Connect UserInfo | `/login/oauth/userinfo` |
|
|
||||||
| JSON Web Key Set | `/login/oauth/keys` |
|
|
||||||
|
|
||||||
## 支持的 OAuth2 授权
|
|
||||||
|
|
||||||
目前 Gitea 仅支持 [**Authorization Code Grant**](https://tools.ietf.org/html/rfc6749#section-1.3.1) 标准,并额外支持以下扩展:
|
|
||||||
|
|
||||||
- [Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636)
|
|
||||||
- [OpenID Connect (OIDC)](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
|
|
||||||
|
|
||||||
要将 Authorization Code Grant 作为第三方应用程序,您需要通过在设置中添加一个新的 "应用程序" (`/user/settings/applications`)。
|
|
||||||
|
|
||||||
## 范围
|
|
||||||
|
|
||||||
Gitea 支持以下令牌范围:
|
|
||||||
|
|
||||||
| 名称 | 介绍 |
|
|
||||||
| ---- | ----------- |
|
|
||||||
| **(no scope)** | 授予对公共用户配置文件和公共存储库的只读访问权限 |
|
|
||||||
| **repo** | 完全控制所有存储库 |
|
|
||||||
| **repo:status** | 授予对所有存储库中提交状态的读/写访问权限 |
|
|
||||||
| **public_repo** | 仅授予对公共存储库的读/写访问权限 |
|
|
||||||
| **admin:repo_hook** | 授予对所有存储库的 Hooks 访问权限,该权限已包含在 `repo` 范围中 |
|
|
||||||
| **write:repo_hook** | 授予对存储库 Hooks 的读/写访问权限 |
|
|
||||||
| **read:repo_hook** | 授予对存储库 Hooks 的只读访问权限 |
|
|
||||||
| **admin:org** | 授予对组织设置的完全访问权限 |
|
|
||||||
| **write:org** | 授予对组织设置的读/写访问权限 |
|
|
||||||
| **read:org** | 授予对组织设置的只读访问权限 |
|
|
||||||
| **admin:public_key** | 授予公钥管理的完全访问权限 |
|
|
||||||
| **write:public_key** | 授予对公钥的读/写访问权限 |
|
|
||||||
| **read:public_key** | 授予对公钥的只读访问权限 |
|
|
||||||
| **admin:org_hook** | 授予对组织级别 Hooks 的完全访问权限 |
|
|
||||||
| **admin:user_hook** | 授予对用户级别 Hooks 的完全访问权限 |
|
|
||||||
| **notification** | 授予对通知的完全访问权限 |
|
|
||||||
| **user** | 授予对用户个人资料信息的完全访问权限 |
|
|
||||||
| **read:user** | 授予对用户个人资料的读取权限 |
|
|
||||||
| **user:email** | 授予对用户电子邮件地址的读取权限 |
|
|
||||||
| **user:follow** | 授予访问权限以关注/取消关注用户 |
|
|
||||||
| **delete_repo** | 授予删除存储库的权限 |
|
|
||||||
| **package** | 授予对托管包的完全访问权限 |
|
|
||||||
| **write:package** | 授予对包的读/写访问权限 |
|
|
||||||
| **read:package** | 授予对包的读取权限 |
|
|
||||||
| **delete:package** | 授予对包的删除权限 |
|
|
||||||
| **admin:gpg_key** | 授予 GPG 密钥管理的完全访问权限 |
|
|
||||||
| **write:gpg_key** | 授予对 GPG 密钥的读/写访问权限 |
|
|
||||||
| **read:gpg_key** | 授予对 GPG 密钥的只读访问权限 |
|
|
||||||
| **admin:application** | 授予应用程序管理的完全访问权限 |
|
|
||||||
| **write:application** | 授予应用程序管理的读/写访问权限 |
|
|
||||||
| **read:application** | 授予应用程序管理的读取权限 |
|
|
||||||
| **sudo** | 允许以站点管理员身份执行操作 |
|
|
||||||
|
|
||||||
## 客户端类型
|
|
||||||
|
|
||||||
Gitea 支持私密和公共客户端类型,[参见 RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1).
|
|
||||||
|
|
||||||
对于公共客户端, 允许在本地回环地址的重定向 URI 中使用任意端口,例如 `http://127.0.0.1/`。根据 [RFC 8252 的建议](https://datatracker.ietf.org/doc/html/rfc8252#section-8.3),请避免使用 `localhost`。
|
|
||||||
|
|
||||||
## 示例
|
|
||||||
|
|
||||||
**注意:** 该示例中尚未使用 PKCE。
|
|
||||||
|
|
||||||
1. 将用户重定向到授权端点,以获得他们的访问资源授权:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE
|
|
||||||
```
|
|
||||||
|
|
||||||
在设置中注册应用程序以获得 `CLIENT_ID`。`STATE` 是一个随机字符串,它将在获得用户授权后发送回您的应用程序。`state` 参数是可选的,但您应该使用它来防止 CSRF 攻击。
|
|
||||||
|
|
||||||
![Authorization Page](/authorize.png)
|
|
||||||
|
|
||||||
用户将会被询问是否授权给您的应用程序。如果他们同意了授权,用户将会被重定向到 `REDIRECT_URL`,例如:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE
|
|
||||||
```
|
|
||||||
|
|
||||||
2. 使用重定向提供的 `code`,您可以请求一个新的应用程序和 Refresh Token。Access Token Endpoint 接受 `application/json` 或 `application/x-www-form-urlencoded` 类型的 POST 请求,例如:
|
|
||||||
|
|
||||||
```curl
|
|
||||||
POST https://[YOUR-GITEA-URL]/login/oauth/access_token
|
|
||||||
```
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"client_id": "YOUR_CLIENT_ID",
|
|
||||||
"client_secret": "YOUR_CLIENT_SECRET",
|
|
||||||
"code": "RETURNED_CODE",
|
|
||||||
"grant_type": "authorization_code",
|
|
||||||
"redirect_uri": "REDIRECT_URI"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
返回:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug",
|
|
||||||
"token_type": "bearer",
|
|
||||||
"expires_in": 3600,
|
|
||||||
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
`CLIENT_SECRET` 是生成给应用程序的唯一密钥。请注意,该密钥只会在您使用 Gitea 创建/注册应用程序后出现一次。如果您丢失了密钥,您必须在应用程序设置中重新生成密钥。
|
|
||||||
|
|
||||||
`access_token` 请求中的 `REDIRECT_URI` 必须与 `authorize` 请求中的 `REDIRECT_URI` 相符。
|
|
||||||
|
|
||||||
3. 使用 `access_token` 来构造 [API 请求](development/api-usage.md#oauth2-provider) 以读写用户的资源。
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-01-20T15:00:00+08:00"
|
|
||||||
title: "Help"
|
|
||||||
slug: "help"
|
|
||||||
sidebar_position: 5
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "Help"
|
|
||||||
sidebar_position: 100
|
|
||||||
identifier: "help"
|
|
||||||
---
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
date: "2017-01-20T15:00:00+08:00"
|
|
||||||
title: "帮助"
|
|
||||||
slug: "help"
|
|
||||||
sidebar_position: 5
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
name: "帮助"
|
|
||||||
sidebar_position: 100
|
|
||||||
identifier: "help"
|
|
||||||
---
|
|
|
@ -1,443 +0,0 @@
|
||||||
---
|
|
||||||
date: "2019-04-05T16:00:00+02:00"
|
|
||||||
title: "FAQ"
|
|
||||||
slug: "faq"
|
|
||||||
sidebar_position: 5
|
|
||||||
toc: false
|
|
||||||
draft: false
|
|
||||||
aliases:
|
|
||||||
- /en-us/faq
|
|
||||||
menu:
|
|
||||||
sidebar:
|
|
||||||
parent: "help"
|
|
||||||
name: "FAQ"
|
|
||||||
sidebar_position: 5
|
|
||||||
identifier: "faq"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Frequently Asked Questions
|
|
||||||
|
|
||||||
This page contains some common questions and answers.
|
|
||||||
|
|
||||||
For more help resources, check all [Support Options](help/support.md).
|
|
||||||
|
|
||||||
## Difference between 1.x and 1.x.x downloads, how can I get latest stable release with bug fixes?
|
|
||||||
|
|
||||||
Version 1.20.x will be used for this example.
|
|
||||||
|
|
||||||
On our [downloads page](https://dl.gitea.com/gitea/) you will see a 1.20 directory, as well as directories for 1.20.0, 1.20.1.
|
|
||||||
|
|
||||||
The 1.20 directory is the nightly build, which is built on each merged commit to the [`release/v1.20`](https://github.com/go-gitea/gitea/tree/release/v1.20) branch.
|
|
||||||
|
|
||||||
The 1.20.0 directory is a release build that was created when the [`v1.20.0`](https://github.com/go-gitea/gitea/releases/tag/v1.20.0) tag was created.
|
|
||||||
|
|
||||||
The nightly builds (1.x) downloads will change as commits are merged to their respective branch, they contain the latest changes/fixes before a tag release is built.
|
|
||||||
|
|
||||||
If a bug fix is targeted on 1.20.1 but 1.20.1 is not released yet, you can get the "1.20-nightly" build to get the bug fix.
|
|
||||||
|
|
||||||
## How to migrate from Gogs/GitHub/etc. to Gitea
|
|
||||||
|
|
||||||
To migrate from Gogs to Gitea:
|
|
||||||
|
|
||||||
- [Gogs version 0.11.46.0418](https://github.com/go-gitea/gitea/issues/4286)
|
|
||||||
|
|
||||||
To migrate from GitHub to Gitea, you can use Gitea's built-in migration form.
|
|
||||||
|
|
||||||
In order to migrate items such as issues, pull requests, etc. you will need to input at least your username.
|
|
||||||
|
|
||||||
[Example (requires login)](https://try.gitea.io/repo/migrate)
|
|
||||||
|
|
||||||
To migrate from GitLab to Gitea, you can use this non-affiliated tool:
|
|
||||||
|
|
||||||
https://github.com/loganinak/MigrateGitlabToGogs
|
|
||||||
|
|
||||||
## Where does Gitea store what file
|
|
||||||
|
|
||||||
- _`AppWorkPath`_
|
|
||||||
- The `WORK_PATH` option in `app.ini`
|
|
||||||
- Else the `--work-path` flag
|
|
||||||
- Else Environment variable `GITEA_WORK_DIR`
|
|
||||||
- Else a built-in value set at build time
|
|
||||||
- Else the directory that contains the Gitea binary
|
|
||||||
- `AppDataPath` (default for database, indexers, etc.)
|
|
||||||
- `APP_DATA_PATH` from `app.ini`
|
|
||||||
- Else _`AppWorkPath`_`/data`
|
|
||||||
- _`CustomPath`_ (custom templates)
|
|
||||||
- The `--custom-path` flag
|
|
||||||
- Else Environment variable `GITEA_CUSTOM`
|
|
||||||
- Else a built-in value set at build time
|
|
||||||
- Else _`AppWorkPath`_`/custom`
|
|
||||||
- HomeDir
|
|
||||||
- Unix: Environment variable `HOME`
|
|
||||||
- Windows: Environment variable `USERPROFILE`, else environment variables `HOMEDRIVE`+`HOMEPATH`
|
|
||||||
- RepoRootPath
|
|
||||||
- `ROOT` in the \[repository] section of `app.ini` if absolute
|
|
||||||
- Else _`AppWorkPath`_`/ROOT` if `ROOT` in the \[repository] section of `app.ini` if relative
|
|
||||||
- Default `%(APP_DATA_PATH)/gitea-repositories`
|
|
||||||
- INI (config file)
|
|
||||||
- `--config` flag
|
|
||||||
- A possible built-in value set a build time
|
|
||||||
- Else _`CustomPath`_`/conf/app.ini`
|
|
||||||
- SQLite Database
|
|
||||||
- `PATH` in `database` section of `app.ini`
|
|
||||||
- Else `%(APP_DATA_PATH)/gitea.db`
|
|
||||||
|
|
||||||
## Not seeing a clone URL or the clone URL being incorrect
|
|
||||||
|
|
||||||
There are a few places that could make this show incorrectly.
|
|
||||||
|
|
||||||
1. If using a reverse proxy, make sure you have followed the correction directions in the [reverse proxy guide](administration/reverse-proxies.md)
|
|
||||||
2. Make sure you have correctly set `ROOT_URL` in the `server` section of your `app.ini`
|
|
||||||
|
|
||||||
If certain clone options aren't showing up (HTTP/S or SSH), the following options can be checked in your `app.ini`
|
|
||||||
|
|
||||||
- `DISABLE_HTTP_GIT`: if set to true, there will be no HTTP/HTTPS link
|
|
||||||
- `DISABLE_SSH`: if set to true, there will be no SSH link
|
|
||||||
- `SSH_EXPOSE_ANONYMOUS`: if set to false, SSH links will be hidden for anonymous users
|
|
||||||
|
|
||||||
## File upload fails with: 413 Request Entity Too Large
|
|
||||||
|
|
||||||
This error occurs when the reverse proxy limits the file upload size.
|
|
||||||
|
|
||||||
See the [reverse proxy guide](administration/reverse-proxies.md) for a solution with nginx.
|
|
||||||
|
|
||||||
## Custom Templates not loading or working incorrectly
|
|
||||||
|
|
||||||
Gitea's custom templates must be added to the correct location or Gitea will not find and use them.
|
|
||||||
|
|
||||||
The correct path for the template(s) will be relative to the `CustomPath`
|
|
||||||
|
|
||||||
1. To find `CustomPath`, look for Custom File Root Path in Site Administration -> Configuration
|
|
||||||
2. If you are still unable to find a path, the default can be [calculated above](#where-does-gitea-store-what-file)
|
|
||||||
3. Once you have figured out the correct custom path, you can refer to the [customizing Gitea](administration/customizing-gitea.md) page to add your template to the correct location.
|
|
||||||
|
|
||||||
## Does Gitea have a "GitHub/GitLab pages" feature?
|
|
||||||
|
|
||||||
Gitea doesn't provide a built-in Pages server. You need a dedicated domain to serve static pages to avoid CSRF security risks.
|
|
||||||
|
|
||||||
For simple usage, you can use a reverse proxy to rewrite & serve static contents from Gitea's raw file URLs.
|
|
||||||
|
|
||||||
And there are already available third-party services, like a standalone [pages server](https://codeberg.org/Codeberg/pages-server) or a [caddy plugin](https://github.com/42wim/caddy-gitea), that can provide the required functionality.
|
|
||||||
|
|
||||||
## Active user vs login prohibited user
|
|
||||||
|
|
||||||
In Gitea, an "active" user refers to a user that has activated their account via email.
|
|
||||||
|
|
||||||
A "login prohibited" user is a user that is not allowed to log in to Gitea anymore
|
|
||||||
|
|
||||||
## Setting up logging
|
|
||||||
|
|
||||||
- [Official Docs](administration/logging-config.md)
|
|
||||||
|
|
||||||
## What is Swagger?
|
|
||||||
|
|
||||||
[Swagger](https://swagger.io/) is what Gitea uses for its API documentation.
|
|
||||||
|
|
||||||
All Gitea instances have the built-in API and there is no way to disable it completely.
|
|
||||||
You can, however, disable showing its documentation by setting `ENABLE_SWAGGER` to `false` in the `api` section of your `app.ini`.
|
|
||||||
For more information, refer to Gitea's [API docs](development/api-usage.md).
|
|
||||||
|
|
||||||
You can see the latest API (for example) on https://try.gitea.io/api/swagger
|
|
||||||
|
|
||||||
You can also see an example of the `swagger.json` file at https://try.gitea.io/swagger.v1.json
|
|
||||||
|
|
||||||
## Adjusting your server for public/private use
|
|
||||||
|
|
||||||
### Preventing spammers
|
|
||||||
|
|
||||||
There are multiple things you can combine to prevent spammers.
|
|
||||||
|
|
||||||
1. By whitelisting or blocklisting certain email domains
|
|
||||||
2. By only whitelisting certain domains with OpenID (see below)
|
|
||||||
3. Setting `ENABLE_CAPTCHA` to `true` in your `app.ini` and properly configuring `RECAPTCHA_SECRET` and `RECAPTCHA_SITEKEY`
|
|
||||||
4. Settings `DISABLE_REGISTRATION` to `true` and creating new users via the [CLI](administration/command-line.md), [API](development/api-usage.md), or Gitea's Admin UI
|
|
||||||
|
|
||||||
### Only allow/block certain email domains
|
|
||||||
|
|
||||||
You can configure `EMAIL_DOMAIN_WHITELIST` or `EMAIL_DOMAIN_BLOCKLIST` in your app.ini under `[service]`
|
|
||||||
|
|
||||||
### Only allow/block certain OpenID providers
|
|
||||||
|
|
||||||
You can configure `WHITELISTED_URIS` or `BLACKLISTED_URIS` under `[openid]` in your `app.ini`
|
|
||||||
|
|
||||||
**NOTE:** whitelisted takes precedence, so if it is non-blank then blacklisted is ignored
|
|
||||||
|
|
||||||
### Issue only users
|
|
||||||
|
|
||||||
The current way to achieve this is to create/modify a user with a max repo creation limit of 0.
|
|
||||||
|
|
||||||
### Restricted users
|
|
||||||
|
|
||||||
Restricted users are limited to a subset of the content based on their organization/team memberships and collaborations, ignoring the public flag on organizations/repos etc.\_\_
|
|
||||||
|
|
||||||
Example use case: A company runs a Gitea instance that requires login. Most repos are public (accessible/browsable by all co-workers).
|
|
||||||
|
|
||||||
At some point, a customer or third party needs access to a specific repo and only that repo. Making such a customer account restricted and granting any needed access using team membership(s) and/or collaboration(s) is a simple way to achieve that without the need to make everything private.
|
|
||||||
|
|
||||||
### Enable Fail2ban
|
|
||||||
|
|
||||||
Use [Fail2Ban](administration/fail2ban-setup.md) to monitor and stop automated login attempts or other malicious behavior based on log patterns
|
|
||||||
|
|
||||||
## How to add/use custom themes
|
|
||||||
|
|
||||||
Gitea supports three official themes right now, `gitea-light`, `gitea-dark`, and `gitea-auto` (automatically switches between the previous two depending on operating system settings).
|
|
||||||
To add your own theme, currently the only way is to provide a complete theme (not just color overrides)
|
|
||||||
|
|
||||||
As an example, let's say our theme is `arc-blue` (this is a real theme, and can be found [in this issue](https://github.com/go-gitea/gitea/issues/6011))
|
|
||||||
|
|
||||||
Name the `.css` file `theme-arc-blue.css` and add it to your custom folder in `custom/public/assets/css`
|
|
||||||
|
|
||||||
Allow users to use it by adding `arc-blue` to the list of `THEMES` in your `app.ini`
|
|
||||||
|
|
||||||
## SSHD vs built-in SSH
|
|
||||||
|
|
||||||
SSHD is the built-in SSH server on most Unix systems.
|
|
||||||
|
|
||||||
Gitea also provides its own SSH server, for usage when SSHD is not available.
|
|
||||||
|
|
||||||
## Gitea is running slow
|
|
||||||
|
|
||||||
The most common culprit for this is loading federated avatars.
|
|
||||||
|
|
||||||
This can be turned off by setting `ENABLE_FEDERATED_AVATAR` to `false` in your `app.ini`
|
|
||||||
|
|
||||||
Another option that may need to be changed is setting `DISABLE_GRAVATAR` to `true` in your `app.ini`
|
|
||||||
|
|
||||||
## Can't create repositories/files
|
|
||||||
|
|
||||||
Make sure that Gitea has sufficient permissions to write to its home directory and data directory.
|
|
||||||
|
|
||||||
See [AppDataPath and RepoRootPath](#where-does-gitea-store-what-file)
|
|
||||||
|
|
||||||
**Note for Arch users:** At the time of writing this, there is an issue with the Arch package's systemd file including this line:
|
|
||||||
|
|
||||||
`ReadWritePaths=/etc/gitea/app.ini`
|
|
||||||
|
|
||||||
Which makes all other paths non-writeable to Gitea.
|
|
||||||
|
|
||||||
## Translation is incorrect/how to add more translations
|
|
||||||
|
|
||||||
Our translations are currently crowd-sourced on our [Crowdin project](https://crowdin.com/project/gitea)
|
|
||||||
|
|
||||||
Whether you want to change a translation or add a new one, it will need to be there as all translations are overwritten in our CI via the Crowdin integration.
|
|
||||||
|
|
||||||
## Push Hook / Webhook aren't running
|
|
||||||
|
|
||||||
If you can push but can't see push activities on the home dashboard, or the push doesn't trigger webhook, there are a few possibilities:
|
|
||||||
|
|
||||||
1. The git hooks are out of sync: run "Resynchronize pre-receive, update and post-receive hooks of all repositories" on the site admin panel
|
|
||||||
2. The git repositories (and hooks) are stored on some filesystems (ex: mounted by NAS) which don't support script execution, make sure the filesystem supports `chmod a+x any-script`
|
|
||||||
3. If you are using docker, make sure Docker Server (not the client) >= 20.10.6
|
|
||||||
|
|
||||||
## SSH issues
|
|
||||||
|
|
||||||
If you cannot reach repositories over `ssh`, but `https` works fine, consider looking into the following.
|
|
||||||
|
|
||||||
First, make sure you can access Gitea via SSH.
|
|
||||||
|
|
||||||
`ssh git@myremote.example`
|
|
||||||
|
|
||||||
If the connection is successful, you should receive an error message like the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
Hi there, You've successfully authenticated, but Gitea does not provide shell access.
|
|
||||||
If this is unexpected, please log in with password and setup Gitea under another user.
|
|
||||||
```
|
|
||||||
|
|
||||||
If you do not get the above message but still connect, it means your SSH key is **not** being managed by Gitea. This means hooks won't run, among other potential problems.
|
|
||||||
|
|
||||||
If you cannot connect at all, your SSH key may not be configured correctly locally.
|
|
||||||
This is specific to SSH and not Gitea, so will not be covered here.
|
|
||||||
|
|
||||||
### SSH Common Errors
|
|
||||||
|
|
||||||
```
|
|
||||||
Permission denied (publickey).
|
|
||||||
fatal: Could not read from remote repository.
|
|
||||||
```
|
|
||||||
|
|
||||||
This error signifies that the server rejected a log in attempt, check the
|
|
||||||
following things:
|
|
||||||
|
|
||||||
- On the client:
|
|
||||||
- Ensure the public and private ssh keys are added to the correct Gitea user.
|
|
||||||
- Make sure there are no issues in the remote url. In particular, ensure the name of the
|
|
||||||
Git user (before the `@`) is spelled correctly.
|
|
||||||
- Ensure public and private ssh keys are correct on client machine.
|
|
||||||
- On the server:
|
|
||||||
- Make sure the repository exists and is correctly named.
|
|
||||||
- Check the permissions of the `.ssh` directory in the system user's home directory.
|
|
||||||
- Verify that the correct public keys are added to `.ssh/authorized_keys`.
|
|
||||||
|
|
||||||
Try to run `Rewrite '.ssh/authorized_keys' file (for Gitea SSH keys)` on the
|
|
||||||
Gitea admin panel.
|
|
||||||
- Read Gitea logs.
|
|
||||||
- Read /var/log/auth (or similar).
|
|
||||||
- Check permissions of repositories.
|
|
||||||
|
|
||||||
The following is an example of a missing public SSH key where authentication
|
|
||||||
succeeded, but some other setting is preventing SSH from reaching the correct
|
|
||||||
repository.
|
|
||||||
|
|
||||||
```
|
|
||||||
fatal: Could not read from remote repository.
|
|
||||||
|
|
||||||
Please make sure you have the correct access rights
|
|
||||||
and the repository exists.
|
|
||||||
```
|
|
||||||
|
|
||||||
In this case, look into the following settings:
|
|
||||||
|
|
||||||
- On the server:
|
|
||||||
- Make sure that the `git` system user has a usable shell set
|
|
||||||
- Verify this with `getent passwd git | cut -d: -f7`
|
|
||||||
- `usermod` or `chsh` can be used to modify this.
|
|
||||||
- Ensure that the `gitea serv` command in `.ssh/authorized_keys` uses the
|
|
||||||
correct configuration file.
|
|
||||||
|
|
||||||
## Missing releases after migrating repository with tags
|
|
||||||
|
|
||||||
To migrate an repository _with_ all tags, you need to do two things:
|
|
||||||
|
|
||||||
- Push tags to the repository:
|
|
||||||
|
|
||||||
```
|
|
||||||
git push --tags
|
|
||||||
```
|
|
||||||
|
|
||||||
- (Re-)sync tags of all repositories within Gitea:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea admin repo-sync-releases
|
|
||||||
```
|
|
||||||
|
|
||||||
## LFS Issues
|
|
||||||
|
|
||||||
For issues concerning LFS data upload
|
|
||||||
|
|
||||||
```
|
|
||||||
batch response: Authentication required: Authorization error: <GITEA_LFS_URL>/info/lfs/objects/batch
|
|
||||||
Check that you have proper access to the repository
|
|
||||||
error: failed to push some refs to '<GIT_REPO_URL>'
|
|
||||||
```
|
|
||||||
|
|
||||||
Check the value of `LFS_HTTP_AUTH_EXPIRY` in your `app.ini` file.
|
|
||||||
|
|
||||||
By default, your LFS token will expire after 20 minutes. If you have a slow connection or a large file (or both), it may not finish uploading within the time limit.
|
|
||||||
|
|
||||||
You may want to set this value to `60m` or `120m`.
|
|
||||||
|
|
||||||
## How can I create users before starting Gitea
|
|
||||||
|
|
||||||
Gitea provides a sub-command `gitea migrate` to initialize the database, after which you can use the [admin CLI commands](administration/command-line.md#admin) to add users like normal.
|
|
||||||
|
|
||||||
## How can I enable password reset
|
|
||||||
|
|
||||||
There is no setting for password resets. It is enabled when a [mail service](administration/email-setup.md) is configured, and disabled otherwise.
|
|
||||||
|
|
||||||
## How can a user's password be changed
|
|
||||||
|
|
||||||
- As an **admin**, you can change any user's password (and optionally force them to change it on next login)...
|
|
||||||
- By navigating to your `Site Administration -> User Accounts` page and editing a user.
|
|
||||||
- By using the [admin CLI commands](administration/command-line.md#admin).
|
|
||||||
|
|
||||||
Keep in mind most commands will also need a [global flag](administration/command-line.md#global-options) to point the CLI at the correct configuration.
|
|
||||||
- As a **user** you can change it...
|
|
||||||
- In your account `Settings -> Account` page (this method **requires** you to know your current password).
|
|
||||||
- By using the `Forgot Password` link.
|
|
||||||
|
|
||||||
If the `Forgot Password/Account Recovery` page is disabled, please contact your administrator to configure a [mail service](administration/email-setup.md).
|
|
||||||
|
|
||||||
## Why is my markdown broken
|
|
||||||
|
|
||||||
In Gitea version `1.11` we moved to [goldmark](https://github.com/yuin/goldmark) for markdown rendering, which is [CommonMark](https://commonmark.org/) compliant.
|
|
||||||
|
|
||||||
If you have markdown that worked as you expected prior to version `1.11` and after upgrading it's not working anymore, please look through the CommonMark spec to see whether the problem is due to a bug or non-compliant syntax.
|
|
||||||
|
|
||||||
If it is the latter, _usually_ there is a compliant alternative listed in the spec.
|
|
||||||
|
|
||||||
## Upgrade errors with MySQL
|
|
||||||
|
|
||||||
If you are receiving errors on upgrade of Gitea using MySQL that read:
|
|
||||||
|
|
||||||
> `ORM engine initialization failed: migrate: do migrate: Error: 1118: Row size too large...`
|
|
||||||
|
|
||||||
Please run `gitea doctor convert` or run `ALTER TABLE table_name ROW_FORMAT=dynamic;` for each table in the database.
|
|
||||||
|
|
||||||
The underlying problem is that the space allocated for indices by the default row format
|
|
||||||
is too small. Gitea requires that the `ROWFORMAT` for its tables is `DYNAMIC`.
|
|
||||||
|
|
||||||
If you are receiving an error line containing `Error 1071: Specified key was too long; max key length is 1000 bytes...`
|
|
||||||
then you are attempting to run Gitea on tables which use the ISAM engine. While this may have worked by chance in previous versions of Gitea, it has never been officially supported and
|
|
||||||
you must use InnoDB. You should run `ALTER TABLE table_name ENGINE=InnoDB;` for each table in the database.
|
|
||||||
|
|
||||||
## Why are Emoji displaying only as placeholders or in monochrome
|
|
||||||
|
|
||||||
Gitea requires the system or browser to have one of the supported Emoji fonts installed, which are Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji and Twemoji Mozilla. Generally, the operating system should already provide one of these fonts, but especially on Linux, it may be necessary to install them manually.
|
|
||||||
|
|
||||||
## Initial logging
|
|
||||||
|
|
||||||
Before Gitea has read the configuration file and set-up its logging it will log a number of things to stdout in order to help debug things if logging does not work.
|
|
||||||
|
|
||||||
You can stop this logging by setting the `--quiet` or `-q` option. Please note this will only stop logging until Gitea has set-up its own logging.
|
|
||||||
|
|
||||||
If you report a bug or issue you MUST give us logs with this information restored.
|
|
||||||
|
|
||||||
You should only set this option once you have completely configured everything.
|
|
||||||
|
|
||||||
## Warnings about struct defaults during database startup
|
|
||||||
|
|
||||||
Sometimes when there are migrations the old columns and default values may be left
|
|
||||||
unchanged in the database schema. This may lead to warning such as:
|
|
||||||
|
|
||||||
```
|
|
||||||
2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync() [W] Table user Column keep_activity_private db default is , struct default is 0
|
|
||||||
```
|
|
||||||
|
|
||||||
These can safely be ignored, but you are able to stop these warnings by getting Gitea to recreate these tables using:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table user
|
|
||||||
```
|
|
||||||
|
|
||||||
This will cause Gitea to recreate the user table and copy the old data into the new table
|
|
||||||
with the defaults set appropriately.
|
|
||||||
|
|
||||||
You can ask Gitea to recreate multiple tables using:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table table1 table2 ...
|
|
||||||
```
|
|
||||||
|
|
||||||
And if you would like Gitea to recreate all tables simply call:
|
|
||||||
|
|
||||||
```
|
|
||||||
gitea doctor recreate-table
|
|
||||||
```
|
|
||||||
|
|
||||||
It is highly recommended to back-up your database before running these commands.
|
|
||||||
|
|
||||||
## How to adopt repositories from disk
|
|
||||||
|
|
||||||
- Add your (bare) repositories to the correct spot for your configuration (`repository.ROOT`), ensuring they are in the correct layout `<REPO_ROOT>/[user]/[repo].git`.
|
|
||||||
- **Note:** the directory names must be lowercase.
|
|
||||||
- You can also check `<ROOT_URL>/admin/config` for the repository root path.
|
|
||||||
- Ensure that the user/org exists that you want to adopt repositories for.
|
|
||||||
- As an admin, go to `<ROOT_URL>/admin/repos/unadopted` and search.
|
|
||||||
- Users can also be given similar permissions via config [`ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`](administration/config-cheat-sheet.md#repository).
|
|
||||||
- If the above steps are done correctly, you should be able to select repositories to adopt.
|
|
||||||
- If no repositories are found, enable [debug logging](administration/config-cheat-sheet.md#repository) to check for any specific errors.
|
|
||||||
|
|
||||||
## Gitea can't start on NFS
|
|
||||||
|
|
||||||
In most cases, it's caused by broken NFS lock system. You can try to stop Gitea process and
|
|
||||||
run `flock -n /data-nfs/gitea/queues/LOCK echo 'lock acquired'` to see whether the lock can be acquired immediately.
|
|
||||||
If the lock can't be acquired, NFS might report some errors like `lockd: cannot monitor node-3, statd: server rpc.statd not responding, timed out` in its server logs.
|
|
||||||
|
|
||||||
Then the NFS lock could be reset by:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# /etc/init.d/nfs stop
|
|
||||||
# rm -rf /var/lib/nfs/sm/*
|
|
||||||
# /etc/init.d/nfs start
|
|
||||||
```
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue