Skip to content

Commit 2fedb30

Browse files
authored
Merge branch 'main' into add-cardtype-to-org-project
2 parents 18b3973 + 0536712 commit 2fedb30

File tree

6 files changed

+105
-10
lines changed

6 files changed

+105
-10
lines changed

docs/content/doc/help/faq.en-us.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ The correct path for the template(s) will be relative to the `CustomPath`
118118
2. If you are still unable to find a path, the default can be [calculated above](#where-does-gitea-store-what-file)
119119
3. Once you have figured out the correct custom path, you can refer to the [customizing Gitea]({{< relref "doc/administration/customizing-gitea.en-us.md" >}}) page to add your template to the correct location.
120120

121+
## Does Gitea have a "GitHub/GitLab pages" feature?
122+
123+
Gitea doesn't provide a built-in Pages server. You need a dedicated domain to serve static pages to avoid CSRF security risks.
124+
125+
For simple usage, you can use a reverse proxy to rewrite & serve static contents from Gitea's raw file URLs.
126+
127+
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.
128+
121129
## Active user vs login prohibited user
122130

123131
In Gitea, an "active" user refers to a user that has activated their account via email.

docs/content/doc/installation/comparison.en-us.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ _Symbols used in table:_
3131

3232
- _✘ - unsupported_
3333

34+
- _⚙️ - supported through third-party software_
35+
3436
## General Features
3537

3638
| Feature | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE |
@@ -51,7 +53,7 @@ _Symbols used in table:_
5153
| Custom Theme Support ||||||||
5254
| Markdown support ||||||||
5355
| CSV support ||||||| ? |
54-
| 'GitHub / GitLab pages' | [](https://github.com/go-gitea/gitea/issues/302) |||||||
56+
| 'GitHub / GitLab pages' | [⚙️][gitea-pages-server], [⚙️][gitea-caddy-plugin] |||||||
5557
| Repo-specific wiki (as a repo itself) |||||| / ||
5658
| Deploy Tokens ||||||||
5759
| Repository Tokens with write rights ||||||||
@@ -144,3 +146,6 @@ _Symbols used in table:_
144146
| Two factor authentication (2FA) ||||||||
145147
| Integration with the most common services || / ||||||
146148
| Incorporate external CI/CD ||||||||
149+
150+
[gitea-caddy-plugin]: https://github.com/42wim/caddy-gitea
151+
[gitea-pages-server]: https://codeberg.org/Codeberg/pages-server

docs/content/doc/installation/comparison.zh-cn.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ _表格中的符号含义:_
2929

3030
* _? - 不确定_
3131

32+
* _⚙️ - 由第三方服务或插件支持_
33+
3234
#### 主要特性
3335

3436
| 特性 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE |
@@ -42,7 +44,7 @@ _表格中的符号含义:_
4244
| 支持 Orgmode ||||||| ? |
4345
| 支持 CSV ||||||| ? |
4446
| 支持第三方渲染工具 ||||||| ? |
45-
| Git 驱动的静态 pages | [](https://github.com/go-gitea/gitea/issues/302) |||||||
47+
| Git 驱动的静态 pages | [⚙️][gitea-pages-server], [⚙️][gitea-caddy-plugin] |||||||
4648
| Git 驱动的集成化 wiki |||||| ✓ (cloud only) ||
4749
| 部署令牌 ||||||||
4850
| 仓库写权限令牌 ||||||||
@@ -129,3 +131,6 @@ _表格中的符号含义:_
129131
| 集成 Discord ||||||||
130132
| 集成 Microsoft Teams ||||||||
131133
| 显示外部 CI/CD 的状态 ||||||||
134+
135+
[gitea-caddy-plugin]: https://github.com/42wim/caddy-gitea
136+
[gitea-pages-server]: https://codeberg.org/Codeberg/pages-server

docs/content/doc/installation/comparison.zh-tw.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ menu:
3131

3232
- ✘ - 不支援
3333

34+
- _⚙️ - 由第三方服務或外掛程式支援_
35+
3436
## 一般功能
3537

3638
| 功能 | Gitea | Gogs | GitHub EE | GitLab CE | GitLab EE | BitBucket | RhodeCode CE |
@@ -44,7 +46,7 @@ menu:
4446
| 支援 Orgmode ||||||| ? |
4547
| 支援 CSV ||||||| ? |
4648
| 支援第三方渲染工具 ||||||| ? |
47-
| Git 驅動的靜態頁面 | [](https://github.com/go-gitea/gitea/issues/302) |||||||
49+
| Git 驅動的靜態頁面 | [⚙️][gitea-pages-server], [⚙️][gitea-caddy-plugin] |||||||
4850
| Git 驅動的整合 wiki ||||||||
4951
| 部署 Token ||||||||
5052
| 有寫入權限的儲存庫 Token ||||||||
@@ -130,3 +132,6 @@ menu:
130132
| 整合 Discord ||||||||
131133
| 整合 Microsoft Teams ||||||||
132134
| 顯示外部 CI/CD 狀態 ||||||||
135+
136+
[gitea-caddy-plugin]: https://github.com/42wim/caddy-gitea
137+
[gitea-pages-server]: https://codeberg.org/Codeberg/pages-server
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package git
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestBranchRuleMatchPriority(t *testing.T) {
14+
kases := []struct {
15+
Rules []string
16+
BranchName string
17+
ExpectedMatchIdx int
18+
}{
19+
{
20+
Rules: []string{"release/*", "release/v1.17"},
21+
BranchName: "release/v1.17",
22+
ExpectedMatchIdx: 1,
23+
},
24+
{
25+
Rules: []string{"release/v1.17", "release/*"},
26+
BranchName: "release/v1.17",
27+
ExpectedMatchIdx: 0,
28+
},
29+
{
30+
Rules: []string{"release/**/v1.17", "release/test/v1.17"},
31+
BranchName: "release/test/v1.17",
32+
ExpectedMatchIdx: 1,
33+
},
34+
{
35+
Rules: []string{"release/test/v1.17", "release/**/v1.17"},
36+
BranchName: "release/test/v1.17",
37+
ExpectedMatchIdx: 0,
38+
},
39+
{
40+
Rules: []string{"release/**", "release/v1.0.0"},
41+
BranchName: "release/v1.0.0",
42+
ExpectedMatchIdx: 1,
43+
},
44+
{
45+
Rules: []string{"release/v1.0.0", "release/**"},
46+
BranchName: "release/v1.0.0",
47+
ExpectedMatchIdx: 0,
48+
},
49+
{
50+
Rules: []string{"release/**", "release/v1.0.0"},
51+
BranchName: "release/v2.0.0",
52+
ExpectedMatchIdx: 0,
53+
},
54+
{
55+
Rules: []string{"release/*", "release/v1.0.0"},
56+
BranchName: "release/1/v2.0.0",
57+
ExpectedMatchIdx: -1,
58+
},
59+
}
60+
61+
for _, kase := range kases {
62+
var pbs ProtectedBranchRules
63+
for _, rule := range kase.Rules {
64+
pbs = append(pbs, &ProtectedBranch{RuleName: rule})
65+
}
66+
pbs.sort()
67+
matchedPB := pbs.GetFirstMatched(kase.BranchName)
68+
if matchedPB == nil {
69+
if kase.ExpectedMatchIdx >= 0 {
70+
assert.Error(t, fmt.Errorf("no matched rules but expected %s[%d]", kase.Rules[kase.ExpectedMatchIdx], kase.ExpectedMatchIdx))
71+
}
72+
} else {
73+
assert.EqualValues(t, kase.Rules[kase.ExpectedMatchIdx], matchedPB.RuleName)
74+
}
75+
}
76+
}

models/git/protected_branch_list.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ func (rules ProtectedBranchRules) sort() {
2828
sort.Slice(rules, func(i, j int) bool {
2929
rules[i].loadGlob()
3030
rules[j].loadGlob()
31-
if rules[i].isPlainName {
32-
if !rules[j].isPlainName {
33-
return true
34-
}
35-
} else if rules[j].isPlainName {
36-
return true
31+
if rules[i].isPlainName != rules[j].isPlainName {
32+
return rules[i].isPlainName // plain name comes first, so plain name means "less"
3733
}
3834
return rules[i].CreatedUnix < rules[j].CreatedUnix
3935
})
@@ -46,7 +42,7 @@ func FindRepoProtectedBranchRules(ctx context.Context, repoID int64) (ProtectedB
4642
if err != nil {
4743
return nil, err
4844
}
49-
rules.sort()
45+
rules.sort() // to make non-glob rules have higher priority, and for same glob/non-glob rules, first created rules have higher priority
5046
return rules, nil
5147
}
5248

0 commit comments

Comments
 (0)