Skip to content

Commit ecb07e4

Browse files
authored
Merge branch 'main' into fix-appurl
2 parents 00c49ba + 51383ec commit ecb07e4

File tree

165 files changed

+1434
-1212
lines changed

Some content is hidden

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

165 files changed

+1434
-1212
lines changed

docs/content/doc/installation/from-binary.en-us.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ menu:
1616
# Installation from binary
1717

1818
All downloads come with SQLite, MySQL and PostgreSQL support, and are built with
19-
embedded assets. This can be different for older releases.
19+
embedded assets. This can be different from Gogs.
2020

2121
**Table of Contents**
2222

2323
{{< toc >}}
2424

2525
## Download
2626

27-
You can find the file matching your platform from the [downloads page](https://dl.gitea.io/gitea/) after navigating to the version you want to download.
27+
You can find the file matching your platform from the [downloads page](https://dl.gitea.com/gitea/) after navigating to the version you want to download.
2828

2929
### Choosing the right file
3030

@@ -36,12 +36,14 @@ You can find the file matching your platform from the [downloads page](https://d
3636

3737
**For macOS**, you should choose `darwin-arm64` if your hardware uses Apple Silicon, or `darwin-amd64` for Intel.
3838

39+
**For FreeBSD**, you should choose `freebsd12-amd64` for 64-bit Intel/AMD platforms.
40+
3941
### Downloading with wget
4042

4143
Copy the commands below and replace the URL within the one you wish to download.
4244

4345
```sh
44-
wget -O gitea https://dl.gitea.io/gitea/{{< version >}}/gitea-{{< version >}}-linux-amd64
46+
wget -O gitea https://dl.gitea.com/gitea/{{< version >}}/gitea-{{< version >}}-linux-amd64
4547
chmod +x gitea
4648
```
4749

@@ -173,7 +175,7 @@ an update of your Gitea version.
173175
Older Linux distributions (such as Debian 7 and CentOS 6) may not be able to load the
174176
Gitea binary, usually producing an error such as `./gitea: /lib/x86_64-linux-gnu/libc.so.6:
175177
version 'GLIBC\_2.14' not found (required by ./gitea)`. This is due to the integrated
176-
SQLite support in the binaries provided by dl.gitea.io. In this situation, it is usually
178+
SQLite support in the binaries provided by dl.gitea.com. In this situation, it is usually
177179
possible to [install from source]({{< relref "from-source.en-us.md" >}}), without including
178180
SQLite support.
179181

docs/content/doc/installation/from-binary.zh-cn.md

Lines changed: 136 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,150 @@ menu:
1515

1616
# 从二进制安装
1717

18-
所有下载均包括 SQLite, MySQL 和 PostgreSQL 的支持,同时所有资源均已嵌入到可执行程序中,这一点和老版本有所不同。 基于二进制的安装非常简单,只要从 [下载页面](https://dl.gitea.io/gitea) 选择对应平台,拷贝下载URL,执行以下命令即可(以Linux为例):
18+
所有打包的二进制程序均包含 SQLiteMySQL 和 PostgreSQL 的数据库连接支持,同时网站的静态资源均已嵌入到可执行程序中,这一点和曾经的 Gogs 有所不同。
1919

20-
```
21-
wget -O gitea https://dl.gitea.io/gitea/{{< version >}}/gitea-{{< version >}}-linux-amd64
20+
**目录**
21+
22+
{{< toc >}}
23+
24+
## 下载
25+
26+
你可以从 [下载页面](https://dl.gitea.com/gitea/) 选择对应平台的二进制文件。
27+
28+
### 选择架构
29+
30+
- **对于 Linux**`linux-amd64` 适用于 64-bit 的 Intel/AMD 平台。更多架构包含 `arm64` (Raspberry PI 4),`386` (32-bit),`arm-5` 以及 `arm-6`
31+
32+
- **对于 Windows**`windows-4.0-amd64` 适用于 64-bit 的 Intel/AMD 平台,`386` 适用于 32-bit 的 Intel/AMD 平台。(提示:`gogit-windows` 版本内建了 gogit 可能缓解在旧的 Windows 平台上 Go 程序调用 git 子程序时面临的 [性能问题](https://github.com/go-gitea/gitea/pull/15482)
33+
34+
- **对于 macOS**`darwin-arm64` 适用于 Apple Silicon 架构,`darwin-amd64` 适用于 Intel 架构.
35+
36+
- **对于 FreeBSD**`freebsd12-amd64` 适用于 64-bit 的 Intel/AMD 平台。
37+
38+
### 使用 wget 下载
39+
40+
使用以下命令下载适用于 64-bit Linux 平台的二进制文件。
41+
42+
```sh
43+
wget -O gitea https://dl.gitea.com/gitea/{{< version >}}/gitea-{{< version >}}-linux-amd64
2244
chmod +x gitea
2345
```
2446

25-
## 测试
47+
## 验证 GPG 签名
2648

27-
在执行了以上步骤之后,你将会获得 `gitea` 的二进制文件,在你复制到部署的机器之前可以先测试一下。在命令行执行完后,你可以 `Ctrl + C` 关掉程序。
49+
Gitea 对打包的二进制文件使用 [GPG密钥](https://keys.openpgp.org/search?q=teabot%40gitea.io) 签名以防止篡改。
50+
请根据对应文件名 `.asc` 中包含的校验码检验文件的一致性。
2851

52+
```sh
53+
gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
54+
gpg --verify gitea-{{< version >}}-linux-amd64.asc gitea-{{< version >}}-linux-amd64
2955
```
30-
./gitea web
56+
57+
校验正确时的信息为 `Good signature from "Teabot <[email protected]>"`
58+
校验错误时的信息为 `This key is not certified with a trusted signature!`
59+
60+
## 服务器设置
61+
62+
**提示:** `GITEA_WORK_DIR` 表示 Gitea 工作的路径。以下路径可以通过 [环境变量]({{< relref "doc/advanced/environment-variables.zh-cn.md" >}}) 初始化。
63+
64+
### 准备环境
65+
66+
检查是否安装 Git。要求 Git 版本 >= 2.0。
67+
68+
```sh
69+
git --version
70+
```
71+
72+
创建用户(推荐使用名称 `git`
73+
74+
```sh
75+
adduser \
76+
--system \
77+
--shell /bin/bash \
78+
--gecos 'Git Version Control' \
79+
--group \
80+
--disabled-password \
81+
--home /home/git \
82+
git
3183
```
3284

33-
## 需要帮助?
85+
### 创建工作路径
86+
87+
```sh
88+
mkdir -p /var/lib/gitea/{custom,data,log}
89+
chown -R git:git /var/lib/gitea/
90+
chmod -R 750 /var/lib/gitea/
91+
mkdir /etc/gitea
92+
chown root:git /etc/gitea
93+
chmod 770 /etc/gitea
94+
```
95+
96+
> **注意:** 为了让 Web 安装程序可以写入配置文件,我们临时为 `/etc/gitea` 路径授予了组外用户 `git` 写入权限。建议在安装结束后将配置文件的权限设置为只读。
97+
>
98+
> ```sh
99+
> chmod 750 /etc/gitea
100+
> chmod 640 /etc/gitea/app.ini
101+
> ```
102+
103+
如果您不希望通过 Web 安装程序创建配置文件,可以将配置文件设置为仅供 Gitea 用户只读(owner/group `root:git`, mode `0640`)并手工创建配置文件:
104+
105+
- 设置 `INSTALL_LOCK=true` 关闭安装界面
106+
- 手动配置数据库连接参数
107+
- 使用 `gitea generate secret` 创建 `SECRET_KEY``INTERNAL_TOKEN`
108+
- 提供所有必要的密钥
109+
110+
详情参考 [命令行文档](/zh-cn/command-line/) 中有关 `gitea generate secret` 的内容。
111+
112+
### 配置 Gitea 工作路径
113+
114+
**提示:** 如果使用 Systemd 管理 Gitea 的 Linux 服务,你可以采用 `WorkingDirectory` 参数来配置工作路径。 否则,使用环境变量 `GITEA_WORK_DIR` 来明确指出程序工作和数据存放路径。
115+
116+
```sh
117+
export GITEA_WORK_DIR=/var/lib/gitea/
118+
```
119+
120+
### 复制二进制文件到全局位置
121+
122+
```sh
123+
cp gitea /usr/local/bin/gitea
124+
```
125+
126+
## 运行 Gitea
127+
128+
完成以上步骤后,可以通过两种方式运行 Gitea:
129+
130+
### 1. 创建服务自动启动 Gitea(推荐)
131+
132+
学习创建 [Linux 服务]({{< relref "run-as-service-in-ubuntu.zh-cn.md" >}})
133+
134+
### 2. 通过命令行终端运行
135+
136+
```sh
137+
GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini
138+
```
139+
140+
## 升级到最新版本
141+
142+
您可以通过停止程序,替换 `/usr/local/bin/gitea` 并重启来更新到新版本。直接替换可执行程序时不要更改或使用新的文件名称,以避免数据出错。
143+
144+
建议您在更新之前进行[备份]({{< relref "doc/usage/backup-and-restore.zh-cn.md" >}})。
145+
146+
### 1. 使用 systemd 重新启动 Gitea(推荐)
147+
148+
我们建议使用 systemd 作为服务管理器,使用 `systemctl restart gitea` 安全地重启程序。
149+
150+
### 2. 非 systemd 重启方法
151+
152+
使用 SIGHUP 信号关闭程序:查询到 Gitea 程序的 PID,使用 `kill -1 $GITEA_PID`,或者 `killall -1 gitea`
153+
154+
更优雅的停止指令可能包括 `kill $GITEA_PID` 或者 `killall gitea`
155+
156+
**提示:** 我们不建议使用 SIGKILL 信号(`-9`),这会强制停止 Gitea 程序,但不会正确关闭队列、索引器等任务。
157+
158+
请参阅下面的疑难解答说明,以在Gitea版本更新后修复损坏的仓库。
159+
160+
## 排查故障
161+
162+
> 更多经验总结,请参考英文版 [Troubleshooting](/en-us/install-from-binary/#troubleshooting)
34163
35164
如果从本页中没有找到你需要的内容,请访问 [帮助页面]({{< relref "seek-help.zh-cn.md" >}})

models/avatars/avatar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const (
2323
// DefaultAvatarClass is the default class of a rendered avatar
24-
DefaultAvatarClass = "ui avatar vm"
24+
DefaultAvatarClass = "ui avatar gt-vm"
2525
// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar
2626
DefaultAvatarPixelSize = 28
2727
)

models/db/context.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"database/sql"
99

10+
"xorm.io/builder"
1011
"xorm.io/xorm"
1112
"xorm.io/xorm/schemas"
1213
)
@@ -183,6 +184,31 @@ func DeleteByBean(ctx context.Context, bean interface{}) (int64, error) {
183184
return GetEngine(ctx).Delete(bean)
184185
}
185186

187+
// DeleteByID deletes the given bean with the given ID
188+
func DeleteByID(ctx context.Context, id int64, bean interface{}) (int64, error) {
189+
return GetEngine(ctx).ID(id).NoAutoTime().Delete(bean)
190+
}
191+
192+
// FindIDs finds the IDs for the given table name satisfying the given condition
193+
// By passing a different value than "id" for "idCol", you can query for foreign IDs, i.e. the repo IDs which satisfy the condition
194+
func FindIDs(ctx context.Context, tableName, idCol string, cond builder.Cond) ([]int64, error) {
195+
ids := make([]int64, 0, 10)
196+
if err := GetEngine(ctx).Table(tableName).
197+
Cols(idCol).
198+
Where(cond).
199+
Find(&ids); err != nil {
200+
return nil, err
201+
}
202+
return ids, nil
203+
}
204+
205+
// DecrByIDs decreases the given column for entities of the "bean" type with one of the given ids by one
206+
// Timestamps of the entities won't be updated
207+
func DecrByIDs(ctx context.Context, ids []int64, decrCol string, bean interface{}) error {
208+
_, err := GetEngine(ctx).Decr(decrCol).In("id", ids).NoAutoCondition().NoAutoTime().Update(bean)
209+
return err
210+
}
211+
186212
// DeleteBeans deletes all given beans, beans should contain delete conditions.
187213
func DeleteBeans(ctx context.Context, beans ...interface{}) (err error) {
188214
e := GetEngine(ctx)

models/repo/repo_unit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ type PullRequestsConfig struct {
125125
AllowRebaseUpdate bool
126126
DefaultDeleteBranchAfterMerge bool
127127
DefaultMergeStyle MergeStyle
128+
DefaultAllowMaintainerEdit bool
128129
}
129130

130131
// FromDB fills up a PullRequestsConfig from serialized format.

modules/git/tree_entry.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ func (te *TreeEntry) FollowLinks() (*TreeEntry, error) {
101101
return entry, nil
102102
}
103103

104+
// returns the subtree, or nil if this is not a tree
105+
func (te *TreeEntry) Tree() *Tree {
106+
t, err := te.ptree.repo.getTree(te.ID)
107+
if err != nil {
108+
return nil
109+
}
110+
return t
111+
}
112+
104113
// GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory )
105114
func (te *TreeEntry) GetSubJumpablePathName() string {
106115
if te.IsSubModule() || !te.IsDir() {

modules/indexer/code/bleve.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/blevesearch/bleve/v2"
2828
analyzer_custom "github.com/blevesearch/bleve/v2/analysis/analyzer/custom"
2929
analyzer_keyword "github.com/blevesearch/bleve/v2/analysis/analyzer/keyword"
30+
"github.com/blevesearch/bleve/v2/analysis/token/camelcase"
3031
"github.com/blevesearch/bleve/v2/analysis/token/lowercase"
3132
"github.com/blevesearch/bleve/v2/analysis/token/unicodenorm"
3233
"github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode"
@@ -107,7 +108,7 @@ func (d *RepoIndexerData) Type() string {
107108
const (
108109
repoIndexerAnalyzer = "repoIndexerAnalyzer"
109110
repoIndexerDocType = "repoIndexerDocType"
110-
repoIndexerLatestVersion = 5
111+
repoIndexerLatestVersion = 6
111112
)
112113

113114
// createBleveIndexer create a bleve repo indexer if one does not already exist
@@ -138,7 +139,7 @@ func createBleveIndexer(path string, latestVersion int) (bleve.Index, error) {
138139
"type": analyzer_custom.Name,
139140
"char_filters": []string{},
140141
"tokenizer": unicode.Name,
141-
"token_filters": []string{unicodeNormalizeName, lowercase.Name},
142+
"token_filters": []string{unicodeNormalizeName, camelcase.Name, lowercase.Name},
142143
}); err != nil {
143144
return nil, err
144145
}

modules/indexer/issues/bleve.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/blevesearch/bleve/v2"
1717
"github.com/blevesearch/bleve/v2/analysis/analyzer/custom"
18+
"github.com/blevesearch/bleve/v2/analysis/token/camelcase"
1819
"github.com/blevesearch/bleve/v2/analysis/token/lowercase"
1920
"github.com/blevesearch/bleve/v2/analysis/token/unicodenorm"
2021
"github.com/blevesearch/bleve/v2/analysis/tokenizer/unicode"
@@ -27,7 +28,7 @@ import (
2728
const (
2829
issueIndexerAnalyzer = "issueIndexer"
2930
issueIndexerDocType = "issueIndexerDocType"
30-
issueIndexerLatestVersion = 1
31+
issueIndexerLatestVersion = 2
3132
)
3233

3334
// indexerID a bleve-compatible unique identifier for an integer id
@@ -134,7 +135,7 @@ func createIssueIndexer(path string, latestVersion int) (bleve.Index, error) {
134135
"type": custom.Name,
135136
"char_filters": []string{},
136137
"tokenizer": unicode.Name,
137-
"token_filters": []string{unicodeNormalizeName, lowercase.Name},
138+
"token_filters": []string{unicodeNormalizeName, camelcase.Name, lowercase.Name},
138139
}); err != nil {
139140
return nil, err
140141
}

modules/structs/repo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type Repository struct {
9696
AllowRebaseUpdate bool `json:"allow_rebase_update"`
9797
DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge"`
9898
DefaultMergeStyle string `json:"default_merge_style"`
99+
DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit"`
99100
AvatarURL string `json:"avatar_url"`
100101
Internal bool `json:"internal"`
101102
MirrorInterval string `json:"mirror_interval"`
@@ -187,6 +188,8 @@ type EditRepoOption struct {
187188
DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge,omitempty"`
188189
// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash".
189190
DefaultMergeStyle *string `json:"default_merge_style,omitempty"`
191+
// set to `true` to allow edits from maintainers by default
192+
DefaultAllowMaintainerEdit *bool `json:"default_allow_maintainer_edit,omitempty"`
190193
// set to `true` to archive this repository.
191194
Archived *bool `json:"archived,omitempty"`
192195
// set to a string like `8h30m0s` to set the mirror interval time

options/locale/locale_en-US.ini

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,14 +1871,10 @@ settings.enable_timetracker = Enable Time Tracking
18711871
settings.allow_only_contributors_to_track_time = Let Only Contributors Track Time
18721872
settings.pulls_desc = Enable Repository Pull Requests
18731873
settings.pulls.ignore_whitespace = Ignore Whitespace for Conflicts
1874-
settings.pulls.allow_merge_commits = Enable Commit Merging
1875-
settings.pulls.allow_rebase_merge = Enable Rebasing to Merge Commits
1876-
settings.pulls.allow_rebase_merge_commit = Enable Rebasing with explicit merge commits (--no-ff)
1877-
settings.pulls.allow_squash_commits = Enable Squashing to Merge Commits
1878-
settings.pulls.allow_manual_merge = Enable Mark PR as manually merged
18791874
settings.pulls.enable_autodetect_manual_merge = Enable autodetect manual merge (Note: In some special cases, misjudgments can occur)
18801875
settings.pulls.allow_rebase_update = Enable updating pull request branch by rebase
18811876
settings.pulls.default_delete_branch_after_merge = Delete pull request branch after merge by default
1877+
settings.pulls.default_allow_edits_from_maintainers = Allow edits from maintainers by default
18821878
settings.releases_desc = Enable Repository Releases
18831879
settings.packages_desc = Enable Repository Packages Registry
18841880
settings.projects_desc = Enable Repository Projects
@@ -2147,7 +2143,8 @@ settings.block_on_official_review_requests_desc = Merging will not be possible w
21472143
settings.block_outdated_branch = Block merge if pull request is outdated
21482144
settings.block_outdated_branch_desc = Merging will not be possible when head branch is behind base branch.
21492145
settings.default_branch_desc = Select a default repository branch for pull requests and code commits:
2150-
settings.default_merge_style_desc = Default merge style for pull requests:
2146+
settings.merge_style_desc = Merge Styles
2147+
settings.default_merge_style_desc = Default Merge Style
21512148
settings.choose_branch = Choose a branch…
21522149
settings.no_protected_branch = There are no protected branches.
21532150
settings.edit_protected_branch = Edit

routers/api/v1/repo/repo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
863863
AllowRebaseUpdate: true,
864864
DefaultDeleteBranchAfterMerge: false,
865865
DefaultMergeStyle: repo_model.MergeStyleMerge,
866+
DefaultAllowMaintainerEdit: false,
866867
}
867868
} else {
868869
config = unit.PullRequestsConfig()
@@ -898,6 +899,9 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
898899
if opts.DefaultMergeStyle != nil {
899900
config.DefaultMergeStyle = repo_model.MergeStyle(*opts.DefaultMergeStyle)
900901
}
902+
if opts.DefaultAllowMaintainerEdit != nil {
903+
config.DefaultAllowMaintainerEdit = *opts.DefaultAllowMaintainerEdit
904+
}
901905

902906
units = append(units, repo_model.RepoUnit{
903907
RepoID: repo.ID,

routers/web/repo/blame.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
262262

263263
var avatar string
264264
if commit.User != nil {
265-
avatar = string(templates.Avatar(commit.User, 18, "mr-3"))
265+
avatar = string(templates.Avatar(commit.User, 18, "gt-mr-3"))
266266
} else {
267-
avatar = string(templates.AvatarByEmail(commit.Author.Email, commit.Author.Name, 18, "mr-3"))
267+
avatar = string(templates.AvatarByEmail(commit.Author.Email, commit.Author.Name, 18, "gt-mr-3"))
268268
}
269269

270270
br.Avatar = gotemplate.HTML(avatar)

0 commit comments

Comments
 (0)