Skip to content

Commit cb2de12

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Fix typo in act-runner file (go-gitea#24652) RSS icon fixes (go-gitea#24476) Notification list enhancements, fix striped tables on dark theme (go-gitea#24639) Improve "goto issue by number" button (go-gitea#24577) Increase default LFS auth timeout from 20m to 24h (go-gitea#24628) Fix typo in the swift package documentation (go-gitea#24637) Fix broken links in documents (go-gitea#24630) Improve updating Actions tasks (go-gitea#24600) Modify luminance calculation and extract related functions into single files (go-gitea#24586) Do not send "registration success email" for external auth sources (go-gitea#24632) Fix typo in Actions demo file (go-gitea#24631) Review fixes and enhancements (go-gitea#24526) Remove fluid on compare diff page (go-gitea#24627) Make the actions control button look like an actual button (go-gitea#24611) Add a tooltip to the job rerun button (go-gitea#24617) Improve reverse-proxy document and fix nginx config bug (go-gitea#24616)
2 parents 57e3902 + 36ed6bd commit cb2de12

Some content is hidden

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

57 files changed

+576
-353
lines changed

custom/conf/app.example.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ RUN_MODE = ; prod
303303
LFS_JWT_SECRET =
304304
;;
305305
;; LFS authentication validity period (in time.Duration), pushes taking longer than this may fail.
306-
;LFS_HTTP_AUTH_EXPIRY = 20m
306+
;LFS_HTTP_AUTH_EXPIRY = 24h
307307
;;
308308
;; Maximum allowed LFS file size in bytes (Set to 0 for no limit).
309309
;LFS_MAX_FILE_SIZE = 0

docs/content/doc/actions/act-runner.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ You may be confused about the runner labels, which will be explained later.
138138
If you want to register the runner in a non-interactive way, you can use arguments to do it.
139139

140140
```bash
141-
./act_runner register --no-interactive --instance <intance_url> --token <registration_token> --name <runner_name> --labels <runner_labels>
141+
./act_runner register --no-interactive --instance <instance_url> --token <registration_token> --name <runner_name> --labels <runner_labels>
142142
```
143143

144144
When you have registered the runner, you can find a new file named `.runner` in the current directory.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The missing host will be filled with `https://gitea.com` if you don't configure
132132
That means `uses: actions/checkout@v3` will download the action from [gitea.com/actions/checkout](https://gitea.com/actions/checkout), instead of [github.com/actions/checkout](https://github.com/actions/checkout).
133133

134134
As mentioned, it's configurable.
135-
If you want your runners to download actions from GitHub or your own Gitea instance by default, you can configure it by setting `[actions].DEFAULT_ACTIONS_URL`. See [Configuration Cheat Sheet](({{ < relref "doc/administration/config-cheat-sheet.en-us.md#actions-actions" > }})).
135+
If you want your runners to download actions from GitHub or your own Gitea instance by default, you can configure it by setting `[actions].DEFAULT_ACTIONS_URL`. See [Configuration Cheat Sheet]({{< relref "doc/administration/config-cheat-sheet.en-us.md#actions-actions" >}}).
136136

137137
### Context availability
138138

docs/content/doc/actions/quickstart.en-us.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This page will guide you through the process of using Gitea Actions.
2424
## Set up Gitea
2525

2626
First of all, you need a Gitea instance.
27-
You can follow the [documentation]({{ < relref "doc/installation/from-package.en-us.md" > }}) to set up a new instance or upgrade your existing one.
27+
You can follow the [documentation]({{< relref "doc/installation/from-package.en-us.md" >}}) to set up a new instance or upgrade your existing one.
2828
It doesn't matter how you install or run Gitea, as long as its version is 1.19.0 or higher.
2929

3030
Actions are disabled by default, so you need to add the following to the configuration file to enable it:
@@ -34,7 +34,7 @@ Actions are disabled by default, so you need to add the following to the configu
3434
ENABLED=true
3535
```
3636

37-
If you want to learn more or encounter any problems while configuring it, please refer to the [Configuration Cheat Sheet]({{ < relref "doc/administration/config-cheat-sheet.en-us.md#actions-actions" > }}).
37+
If you want to learn more or encounter any problems while configuring it, please refer to the [Configuration Cheat Sheet]({{< relref "doc/administration/config-cheat-sheet.en-us.md#actions-actions" >}}).
3838

3939
### Set up runner
4040

@@ -85,7 +85,7 @@ And you can see the new runner in the management page:
8585

8686
![view runner](/images/usage/actions/view-runner.png)
8787

88-
You can find more information by visiting [Act runner]({{ < relref "doc/actions/act-runner.en-us.md" > }}).
88+
You can find more information by visiting [Act runner]({{< relref "doc/actions/act-runner.en-us.md" >}}).
8989

9090
### Use Actions
9191

@@ -119,7 +119,7 @@ jobs:
119119
- name: List files in the repository
120120
run: |
121121
ls ${{ gitea.workspace }}
122-
- run: echo "🍏 This job's status is ${{ gitea.status }}."
122+
- run: echo "🍏 This job's status is ${{ job.status }}."
123123
```
124124
125125
You can upload it as a file with the extension `.yaml` in the directory `.gitea/workflows/` of the repository, for example `.gitea/workflows/demo.yaml`.
@@ -129,7 +129,7 @@ That is because Gitea Actions is designed to be compatible with GitHub Actions
129129
Be careful, the demo file contains some emojis.
130130
Please make sure your database supports them, especially when using MySQL.
131131
If the charset is not `utf8mb4`, errors will occur, such as `Error 1366 (HY000): Incorrect string value: '\\xF0\\x9F\\x8E\\x89 T...' for column 'name' at row 1`.
132-
See [Database Preparation]( {{ < relref "doc/installation/database-preparation.en-us.md#mysql" > }}) for more information.
132+
See [Database Preparation]({{< relref "doc/installation/database-preparation.en-us.md#mysql" >}}) for more information.
133133

134134
Alternatively, you can remove all emojis from the demo file and try again.
135135

docs/content/doc/administration/config-cheat-sheet.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
364364
- `LFS_START_SERVER`: **false**: Enables Git LFS support.
365365
- `LFS_CONTENT_PATH`: **%(APP_DATA_PATH)s/lfs**: Default LFS content path. (if it is on local storage.) **DEPRECATED** use settings in `[lfs]`.
366366
- `LFS_JWT_SECRET`: **\<empty\>**: LFS authentication secret, change this a unique string.
367-
- `LFS_HTTP_AUTH_EXPIRY`: **20m**: LFS authentication validity period in time.Duration, pushes taking longer than this may fail.
367+
- `LFS_HTTP_AUTH_EXPIRY`: **24h**: LFS authentication validity period in time.Duration, pushes taking longer than this may fail.
368368
- `LFS_MAX_FILE_SIZE`: **0**: Maximum allowed LFS file size in bytes (Set to 0 for no limit).
369369
- `LFS_LOCKS_PAGING_NUM`: **50**: Maximum number of LFS Locks returned per page.
370370

docs/content/doc/administration/reverse-proxies.en-us.md

+29-17
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ menu:
2525

2626
If you want Nginx to serve your Gitea instance, add the following `server` section to the `http` section of `nginx.conf`:
2727

28-
```apacheconf
28+
```
2929
server {
3030
listen 80;
3131
server_name git.example.com;
3232
3333
location / {
34+
client_max_body_size 512M;
3435
proxy_pass http://localhost:3000;
3536
proxy_set_header Host $host;
3637
proxy_set_header X-Real-IP $remote_addr;
@@ -40,23 +41,32 @@ server {
4041
}
4142
```
4243

44+
### Resolving Error: 413 Request Entity Too Large
45+
46+
This error indicates nginx is configured to restrict the file upload size,
47+
it affects attachment uploading, form posting, package uploading and LFS pushing, etc.
48+
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).
49+
4350
## Nginx with a sub-path
4451

4552
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`:
4653

47-
```apacheconf
54+
```
4855
server {
4956
listen 80;
5057
server_name git.example.com;
5158
5259
# Note: Trailing slash
53-
location /git/ {
54-
# Note: Trailing slash
55-
proxy_pass http://localhost:3000/;
56-
proxy_set_header Host $host;
57-
proxy_set_header X-Real-IP $remote_addr;
58-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
59-
proxy_set_header X-Forwarded-Proto $scheme;
60+
location /gitea/ {
61+
client_max_body_size 512M;
62+
63+
# make nginx use unescaped URI, keep "%2F" as is
64+
rewrite ^ $request_uri;
65+
rewrite ^/gitea(/.*) $1 break;
66+
proxy_pass http://127.0.0.1:3000$uri;
67+
68+
# other common HTTP headers, see the "Nginx" config section above
69+
proxy_set_header ...
6070
}
6171
}
6272
```
@@ -132,14 +142,6 @@ server {
132142
}
133143
```
134144

135-
## Resolving Error: 413 Request Entity Too Large
136-
137-
This error indicates nginx is configured to restrict the file upload size.
138-
139-
In your nginx config file containing your Gitea proxy directive, find the `location { ... }` block for Gitea and add the line
140-
`client_max_body_size 16M;` to set this limit to 16 megabytes or any other number of choice.
141-
If you use Git LFS, this will also limit the size of the largest file you will be able to push.
142-
143145
## Apache HTTPD
144146

145147
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):
@@ -387,3 +389,13 @@ gitea:
387389
This config assumes that you are handling HTTPS on the traefik side and using HTTP between Gitea and traefik.
388390
389391
Then you **MUST** set something like `[server] ROOT_URL = http://example.com/gitea/` correctly in your configuration.
392+
393+
## General sub-path configuration
394+
395+
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.
396+
397+
If you really need to do so, to make Gitea works with sub-path (eg: `http://example.com/gitea/`), here are the requirements:
398+
399+
1. Set `[server] ROOT_URL = http://example.com/gitea/` in your `app.ini` file.
400+
2. Make the reverse-proxy pass `http://example.com/gitea/foo` to `http://gitea-server:3000/foo`.
401+
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`.

docs/content/doc/development/hacking-on-gitea.zh-cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ make lint-backend
168168

169169
### 处理 JS 和 CSS
170170

171-
前端开发应遵循 [Guidelines for Frontend Development]({{ < 相关参考 "doc/development/guidelines-frontend.en-us.md" > }})
171+
前端开发应遵循 [Guidelines for Frontend Development]({{< relref "doc/contributing/guidelines-frontend.zh-cn.md" >}})
172172

173173
要使用前端资源构建,请使用上面提到的“watch-frontend”目标或只构建一次:
174174

docs/content/doc/usage/packages/swift.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ menu:
1515

1616
# Swift Packages Repository
1717

18-
Publish [Swift](hhttps://www.swift.org/) packages for your user or organization.
18+
Publish [Swift](https://www.swift.org/) packages for your user or organization.
1919

2020
**Table of Contents**
2121

docs/content/doc/usage/push.zh-tw.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Push to create is a feature that allows you to push to a repository that does no
5454

5555
## Enabling Push To Create
5656

57-
In the `app.ini` file, set `ENABLE_PUSH_CREATE_USER` to `true` and `ENABLE_PUSH_CREATE_ORG` to `true` if you want to allow users to create repositories in their own user account and in organizations they are a member of respectively. Restart Gitea for the changes to take effect. You can read more about these two options in the [Configuration Cheat Sheet]({{ < relref "doc/administration/config-cheat-sheet.zh-tw.md#repository-repository" > }}).
57+
In the `app.ini` file, set `ENABLE_PUSH_CREATE_USER` to `true` and `ENABLE_PUSH_CREATE_ORG` to `true` if you want to allow users to create repositories in their own user account and in organizations they are a member of respectively. Restart Gitea for the changes to take effect. You can read more about these two options in the [Configuration Cheat Sheet]({{< relref "doc/administration/config-cheat-sheet.zh-tw.md#repository-repository" >}}).
5858

5959
## Using Push To Create
6060

models/actions/task.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
291291
}
292292

293293
task.LogFilename = logFileName(job.Run.Repo.FullName(), task.ID)
294-
if _, err := e.ID(task.ID).Cols("log_filename").Update(task); err != nil {
294+
if err := UpdateTask(ctx, task, "log_filename"); err != nil {
295295
return nil, false, err
296296
}
297297

@@ -367,9 +367,18 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT
367367
return nil, util.ErrNotExist
368368
}
369369

370+
if task.Status.IsDone() {
371+
// the state is final, do nothing
372+
return task, nil
373+
}
374+
375+
// state.Result is not unspecified means the task is finished
370376
if state.Result != runnerv1.Result_RESULT_UNSPECIFIED {
371377
task.Status = Status(state.Result)
372378
task.Stopped = timeutil.TimeStamp(state.StoppedAt.AsTime().Unix())
379+
if err := UpdateTask(ctx, task, "status", "stopped"); err != nil {
380+
return nil, err
381+
}
373382
if _, err := UpdateRunJob(ctx, &ActionRunJob{
374383
ID: task.JobID,
375384
Status: task.Status,
@@ -379,10 +388,6 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT
379388
}
380389
}
381390

382-
if _, err := e.ID(task.ID).Update(task); err != nil {
383-
return nil, err
384-
}
385-
386391
if err := task.LoadAttributes(ctx); err != nil {
387392
return nil, err
388393
}
@@ -440,7 +445,7 @@ func StopTask(ctx context.Context, taskID int64, status Status) error {
440445
return err
441446
}
442447

443-
if _, err := e.ID(task.ID).Update(task); err != nil {
448+
if err := UpdateTask(ctx, task, "status", "stopped"); err != nil {
444449
return err
445450
}
446451

models/issues/label.go

-27
Original file line numberDiff line numberDiff line change
@@ -159,33 +159,6 @@ func (l *Label) BelongsToRepo() bool {
159159
return l.RepoID > 0
160160
}
161161

162-
// Get color as RGB values in 0..255 range
163-
func (l *Label) ColorRGB() (float64, float64, float64, error) {
164-
color, err := strconv.ParseUint(l.Color[1:], 16, 64)
165-
if err != nil {
166-
return 0, 0, 0, err
167-
}
168-
169-
r := float64(uint8(0xFF & (uint32(color) >> 16)))
170-
g := float64(uint8(0xFF & (uint32(color) >> 8)))
171-
b := float64(uint8(0xFF & uint32(color)))
172-
return r, g, b, nil
173-
}
174-
175-
// Determine if label text should be light or dark to be readable on background color
176-
func (l *Label) UseLightTextColor() bool {
177-
if strings.HasPrefix(l.Color, "#") {
178-
if r, g, b, err := l.ColorRGB(); err == nil {
179-
// Perceived brightness from: https://www.w3.org/TR/AERT/#color-contrast
180-
// In the future WCAG 3 APCA may be a better solution
181-
brightness := (0.299*r + 0.587*g + 0.114*b) / 255
182-
return brightness < 0.35
183-
}
184-
}
185-
186-
return false
187-
}
188-
189162
// Return scope substring of label name, or empty string if none exists
190163
func (l *Label) ExclusiveScope() string {
191164
if !l.Exclusive {

models/issues/label_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ func TestLabel_CalOpenIssues(t *testing.T) {
2222
assert.EqualValues(t, 2, label.NumOpenIssues)
2323
}
2424

25-
func TestLabel_TextColor(t *testing.T) {
26-
assert.NoError(t, unittest.PrepareTestDatabase())
27-
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
28-
assert.False(t, label.UseLightTextColor())
29-
30-
label = unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 2})
31-
assert.True(t, label.UseLightTextColor())
32-
}
33-
3425
func TestLabel_ExclusiveScope(t *testing.T) {
3526
assert.NoError(t, unittest.PrepareTestDatabase())
3627
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 7})

models/issues/review.go

+14
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) {
189189
return err
190190
}
191191

192+
func (r *Review) HTMLTypeColorName() string {
193+
switch r.Type {
194+
case ReviewTypeApprove:
195+
return "green"
196+
case ReviewTypeComment:
197+
return "grey"
198+
case ReviewTypeReject:
199+
return "red"
200+
case ReviewTypeRequest:
201+
return "yellow"
202+
}
203+
return "grey"
204+
}
205+
192206
// GetReviewByID returns the review by the given ID
193207
func GetReviewByID(ctx context.Context, id int64) (*Review, error) {
194208
review := new(Review)

modules/setting/lfs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func loadLFSFrom(rootCfg ConfigProvider) {
4545
LFS.LocksPagingNum = 50
4646
}
4747

48-
LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
48+
LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour)
4949

5050
if LFS.StartServer {
5151
LFS.JWTSecretBytes = make([]byte, 32)

modules/templates/util_render.go

+28-29
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"code.gitea.io/gitea/modules/markup"
2121
"code.gitea.io/gitea/modules/markup/markdown"
2222
"code.gitea.io/gitea/modules/setting"
23+
"code.gitea.io/gitea/modules/util"
2324
)
2425

2526
// RenderCommitMessage renders commit message with XSS-safe and special links.
@@ -133,7 +134,9 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
133134
labelScope := label.ExclusiveScope()
134135

135136
textColor := "#111"
136-
if label.UseLightTextColor() {
137+
r, g, b := util.HexToRBGColor(label.Color)
138+
// Determine if label text should be light or dark to be readable on background color
139+
if util.UseLightTextOnBackground(r, g, b) {
137140
textColor = "#eee"
138141
}
139142

@@ -150,34 +153,30 @@ func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML {
150153
scopeText := RenderEmoji(ctx, labelScope)
151154
itemText := RenderEmoji(ctx, label.Name[len(labelScope)+1:])
152155

153-
itemColor := label.Color
154-
scopeColor := label.Color
155-
if r, g, b, err := label.ColorRGB(); err == nil {
156-
// Make scope and item background colors slightly darker and lighter respectively.
157-
// More contrast needed with higher luminance, empirically tweaked.
158-
luminance := (0.299*r + 0.587*g + 0.114*b) / 255
159-
contrast := 0.01 + luminance*0.03
160-
// Ensure we add the same amount of contrast also near 0 and 1.
161-
darken := contrast + math.Max(luminance+contrast-1.0, 0.0)
162-
lighten := contrast + math.Max(contrast-luminance, 0.0)
163-
// Compute factor to keep RGB values proportional.
164-
darkenFactor := math.Max(luminance-darken, 0.0) / math.Max(luminance, 1.0/255.0)
165-
lightenFactor := math.Min(luminance+lighten, 1.0) / math.Max(luminance, 1.0/255.0)
166-
167-
scopeBytes := []byte{
168-
uint8(math.Min(math.Round(r*darkenFactor), 255)),
169-
uint8(math.Min(math.Round(g*darkenFactor), 255)),
170-
uint8(math.Min(math.Round(b*darkenFactor), 255)),
171-
}
172-
itemBytes := []byte{
173-
uint8(math.Min(math.Round(r*lightenFactor), 255)),
174-
uint8(math.Min(math.Round(g*lightenFactor), 255)),
175-
uint8(math.Min(math.Round(b*lightenFactor), 255)),
176-
}
177-
178-
itemColor = "#" + hex.EncodeToString(itemBytes)
179-
scopeColor = "#" + hex.EncodeToString(scopeBytes)
180-
}
156+
// Make scope and item background colors slightly darker and lighter respectively.
157+
// More contrast needed with higher luminance, empirically tweaked.
158+
luminance := util.GetLuminance(r, g, b)
159+
contrast := 0.01 + luminance*0.03
160+
// Ensure we add the same amount of contrast also near 0 and 1.
161+
darken := contrast + math.Max(luminance+contrast-1.0, 0.0)
162+
lighten := contrast + math.Max(contrast-luminance, 0.0)
163+
// Compute factor to keep RGB values proportional.
164+
darkenFactor := math.Max(luminance-darken, 0.0) / math.Max(luminance, 1.0/255.0)
165+
lightenFactor := math.Min(luminance+lighten, 1.0) / math.Max(luminance, 1.0/255.0)
166+
167+
scopeBytes := []byte{
168+
uint8(math.Min(math.Round(r*darkenFactor), 255)),
169+
uint8(math.Min(math.Round(g*darkenFactor), 255)),
170+
uint8(math.Min(math.Round(b*darkenFactor), 255)),
171+
}
172+
itemBytes := []byte{
173+
uint8(math.Min(math.Round(r*lightenFactor), 255)),
174+
uint8(math.Min(math.Round(g*lightenFactor), 255)),
175+
uint8(math.Min(math.Round(b*lightenFactor), 255)),
176+
}
177+
178+
itemColor := "#" + hex.EncodeToString(itemBytes)
179+
scopeColor := "#" + hex.EncodeToString(scopeBytes)
181180

182181
s := fmt.Sprintf("<span class='ui label scope-parent' title='%s'>"+
183182
"<div class='ui label scope-left' style='color: %s !important; background-color: %s !important'>%s</div>"+

0 commit comments

Comments
 (0)