Skip to content

Commit aa86806

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-15178-provide-aliases-for-submodules
2 parents d168e9b + f166f9b commit aa86806

File tree

127 files changed

+1703
-336
lines changed

Some content is hidden

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

127 files changed

+1703
-336
lines changed

cmd/serv.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
package cmd
77

88
import (
9+
"context"
910
"fmt"
1011
"net/http"
1112
"net/url"
1213
"os"
1314
"os/exec"
15+
"os/signal"
1416
"regexp"
1517
"strconv"
1618
"strings"
19+
"syscall"
1720
"time"
1821

1922
"code.gitea.io/gitea/models"
@@ -273,12 +276,31 @@ func runServ(c *cli.Context) error {
273276
verb = strings.Replace(verb, "-", " ", 1)
274277
}
275278

279+
ctx, cancel := context.WithCancel(context.Background())
280+
defer cancel()
281+
go func() {
282+
// install notify
283+
signalChannel := make(chan os.Signal, 1)
284+
285+
signal.Notify(
286+
signalChannel,
287+
syscall.SIGINT,
288+
syscall.SIGTERM,
289+
)
290+
select {
291+
case <-signalChannel:
292+
case <-ctx.Done():
293+
}
294+
cancel()
295+
signal.Reset()
296+
}()
297+
276298
var gitcmd *exec.Cmd
277299
verbs := strings.Split(verb, " ")
278300
if len(verbs) == 2 {
279-
gitcmd = exec.Command(verbs[0], verbs[1], repoPath)
301+
gitcmd = exec.CommandContext(ctx, verbs[0], verbs[1], repoPath)
280302
} else {
281-
gitcmd = exec.Command(verb, repoPath)
303+
gitcmd = exec.CommandContext(ctx, verb, repoPath)
282304
}
283305

284306
gitcmd.Dir = setting.RepoRootPath

custom/conf/app.example.ini

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ PATH =
573573
;;
574574
;; Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
575575
;PULL_REQUEST_PUSH_MESSAGE = true
576+
;;
577+
;; (Go-Git only) Don't cache objects greater than this in memory. (Set to 0 to disable.)
578+
;LARGE_OBJECT_THRESHOLD = 1048576
579+
576580
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
577581
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
578582
; [git.submodule]
@@ -585,6 +589,7 @@ PATH =
585589
; MAP_NAME_2 = [email protected]/go-gitea/gitea
586590
; MAP_VALUE_2 = https://gitea.com/gitea/gitea
587591
; ...
592+
588593
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
589594
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
590595
[service]
@@ -1040,11 +1045,16 @@ PATH =
10401045
;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
10411046
;THEMES = gitea,arc-green
10421047
;;
1043-
;;All available reactions users can choose on issues/prs and comments.
1044-
;;Values can be emoji alias (:smile:) or a unicode emoji.
1045-
;;For custom reactions, add a tightly cropped square image to public/emoji/img/reaction_name.png
1048+
;; All available reactions users can choose on issues/prs and comments.
1049+
;; Values can be emoji alias (:smile:) or a unicode emoji.
1050+
;; For custom reactions, add a tightly cropped square image to public/img/emoji/reaction_name.png
10461051
;REACTIONS = +1, -1, laugh, hooray, confused, heart, rocket, eyes
10471052
;;
1053+
;; Additional Emojis not defined in the utf8 standard
1054+
;; By default we support gitea (:gitea:), to add more copy them to public/img/emoji/emoji_name.png and add it to this config.
1055+
;; Dont mistake it for Reactions.
1056+
;CUSTOM_EMOJIS = gitea, codeberg, gitlab, git, github, gogs
1057+
;;
10481058
;; Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
10491059
;DEFAULT_SHOW_FULL_NAME = false
10501060
;;

docs/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ params:
1818
description: Git with a cup of tea
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
21-
version: 1.14.2
21+
version: 1.14.3
2222
minGoVersion: 1.14
2323
goVersion: 1.16
2424
minNodeVersion: 12.17

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ The following configuration set `Content-Type: application/vnd.android.package-a
180180
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB)
181181
- `REACTIONS`: All available reactions users can choose on issues/prs and comments
182182
Values can be emoji alias (:smile:) or a unicode emoji.
183-
For custom reactions, add a tightly cropped square image to public/emoji/img/reaction_name.png
183+
For custom reactions, add a tightly cropped square image to public/img/emoji/reaction_name.png
184+
- `CUSTOM_EMOJIS`: **gitea, codeberg, gitlab, git, github, gogs**: Additional Emojis not defined in the utf8 standard.
185+
By default we support gitea (:gitea:), to add more copy them to public/img/emoji/emoji_name.png and
186+
add it to this config.
184187
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
185188
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
186189
- `USE_SERVICE_WORKER`: **true**: Whether to enable a Service Worker to cache frontend assets.
@@ -389,7 +392,7 @@ relation to port exhaustion.
389392
- `MAX_ATTEMPTS`: **10**: Maximum number of attempts to create the wrapped queue
390393
- `TIMEOUT`: **GRACEFUL_HAMMER_TIME + 30s**: Timeout the creation of the wrapped queue if it takes longer than this to create.
391394
- Queues by default come with a dynamically scaling worker pool. The following settings configure this:
392-
- `WORKERS`: **0** (v1.14 and before: **1**): Number of initial workers for the queue.
395+
- `WORKERS`: **0** (v1.14 and before: **1**): Number of initial workers for the queue.
393396
- `MAX_WORKERS`: **10**: Maximum number of worker go-routines for the queue.
394397
- `BLOCK_TIMEOUT`: **1s**: If the queue blocks for this time, boost the number of workers - the `BLOCK_TIMEOUT` will then be doubled before boosting again whilst the boost is ongoing.
395398
- `BOOST_TIMEOUT`: **5m**: Boost workers will timeout after this long.
@@ -834,7 +837,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
834837
- `PULL_REQUEST_PUSH_MESSAGE`: **true**: Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
835838
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
836839
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
837-
840+
- `LARGE_OBJECT_THRESHOLD`: **1048576**: (Go-Git only), don't cache objects greater than this in memory. (Set to 0 to disable.)
838841
## Git - Timeout settings (`git.timeout`)
839842

840843
- `DEFAUlT`: **360**: Git operations default timeout seconds.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ chmod +x gitea
3232
```
3333

3434
## Verify GPG signature
35-
Gitea signs all binaries with a [GPG key](https://keys.openpgp.org/search?q=teabot%40gitea.io) to prevent against unwanted modification of binaries. To validate the binary, download the signature file which ends in `.asc` for the binary you downloaded and use the gpg command line tool.
35+
Gitea signs all binaries with a [GPG key](https://keys.openpgp.org/search?q=teabot%40gitea.io) to prevent against unwanted modification of binaries.
36+
To validate the binary, download the signature file which ends in `.asc` for the binary you downloaded and use the gpg command line tool.
3637

3738
```sh
3839
gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
3940
gpg --verify gitea-{{< version >}}-linux-amd64.asc gitea-{{< version >}}-linux-amd64
4041
```
4142

43+
Look for the text `Good signature from "Teabot <[email protected]>"` to assert a good binary,
44+
despite warnings like `This key is not certified with a trusted signature!`.
45+
4246
## Recommended server configuration
4347

4448
**NOTE:** Many of the following directories can be configured using [Environment Variables]({{< relref "doc/advanced/environment-variables.en-us.md" >}}) as well!

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
date: "2016-12-01T16:00:00+02:00"
33
title: "Installation from package"
44
slug: "install-from-package"
5-
weight: 10
5+
weight: 20
66
toc: false
77
draft: false
88
menu:
@@ -92,18 +92,6 @@ is in `/usr/local/etc/rc.d/gitea`.
9292

9393
To enable Gitea to run as a service, run `sysrc gitea_enable=YES` and start it with `service gitea start`.
9494

95-
## Cloudron
96-
97-
Gitea is available as a 1-click install on [Cloudron](https://cloudron.io).
98-
Cloudron makes it easy to run apps like Gitea on your server and keep them up-to-date and secure.
99-
100-
[![Install](/cloudron.svg)](https://cloudron.io/button.html?app=io.gitea.cloudronapp)
101-
102-
The Gitea package is maintained [here](https://git.cloudron.io/cloudron/gitea-app).
103-
104-
There is a [demo instance](https://my.demo.cloudron.io) (username: cloudron password: cloudron) where
105-
you can experiment with running Gitea.
106-
10795
## Third-party
10896

10997
Various other third-party packages of Gitea exist.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
date: "2016-12-01T16:00:00+02:00"
3+
title: "Install on Cloud Provider"
4+
slug: "install-on-cloud-provider"
5+
weight: 20
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "installation"
11+
name: "On cloud provider"
12+
weight: 20
13+
identifier: "install-on-cloud-provider"
14+
---
15+
16+
# Installation on Cloud Provider
17+
18+
**Table of Contents**
19+
20+
{{< toc >}}
21+
22+
## Cloudron
23+
24+
Gitea is available as a 1-click install on [Cloudron](https://cloudron.io).
25+
Cloudron makes it easy to run apps like Gitea on your server and keep them up-to-date and secure.
26+
27+
[![Install](/cloudron.svg)](https://cloudron.io/button.html?app=io.gitea.cloudronapp)
28+
29+
The Gitea package is maintained [here](https://git.cloudron.io/cloudron/gitea-app).
30+
31+
There is a [demo instance](https://my.demo.cloudron.io) (username: cloudron password: cloudron) where
32+
you can experiment with running Gitea.
33+
34+
## Vultr
35+
36+
Gitea can found in [Vultr](https://www.vultr.com)'s marketplace.
37+
38+
To deploy it have a look at https://www.vultr.com/marketplace/apps/gitea.
39+
40+
## DigitalOcean
41+
42+
[DigitalOcean](https://www.digitalocean.com) has gitea as droplet in his marketplace.
43+
44+
Just create a new [Gitea Droplet](https://marketplace.digitalocean.com/apps/gitea).

docs/content/doc/usage/fail2ban-setup.en-us.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,32 @@ on a bad authentication from the web or CLI using SSH or HTTP respectively:
2929
```log
3030
2020/10/15 16:05:09 modules/ssh/ssh.go:143:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
3131
```
32+
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
3233

3334
```log
3435
2020/10/15 16:05:09 modules/ssh/ssh.go:155:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
3536
```
37+
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
3638

3739
```log
3840
2020/10/15 16:05:09 modules/ssh/ssh.go:198:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
3941
```
42+
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
4043

4144
```log
4245
2020/10/15 16:05:09 modules/ssh/ssh.go:213:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
4346
```
47+
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
4448

4549
```log
4650
2020/10/15 16:05:09 modules/ssh/ssh.go:227:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
4751
```
52+
(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.)
53+
54+
```log
55+
2020/10/15 16:05:09 modules/ssh/ssh.go:249:sshConnectionFailed() [W] Failed authentication attempt from xxx.xxx.xxx.xxx
56+
```
57+
(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.)
4858

4959
```log
5060
2020/10/15 16:08:44 ...s/context/context.go:204:HandleText() [E] invalid credentials from xxx.xxx.xxx.xxx

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require (
4141
github.com/go-chi/cors v1.2.0
4242
github.com/go-enry/go-enry/v2 v2.7.0
4343
github.com/go-git/go-billy/v5 v5.3.1
44-
github.com/go-git/go-git/v5 v5.4.2
44+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4
4545
github.com/go-ldap/ldap/v3 v3.3.0
4646
github.com/go-redis/redis/v8 v8.10.0
4747
github.com/go-sql-driver/mysql v1.6.0
@@ -123,9 +123,9 @@ require (
123123
go.uber.org/multierr v1.7.0 // indirect
124124
go.uber.org/zap v1.17.0 // indirect
125125
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
126-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
126+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
127127
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
128-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
128+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
129129
golang.org/x/text v0.3.6
130130
golang.org/x/time v0.0.0-20210608053304-ed9ce3a009e4 // indirect
131131
golang.org/x/tools v0.1.0

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Ai
313313
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
314314
github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=
315315
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
316-
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
317-
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
316+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4 h1:1RSUwVK7VjTeA82kcLIqz1EU70QRwFdZUlJW58gP4GY=
317+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
318318
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
319319
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
320320
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -1233,8 +1233,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
12331233
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
12341234
golang.org/x/net v0.0.0-20210331060903-cb1fcc7394e5/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
12351235
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
1236-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
1237-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1236+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
1237+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
12381238
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12391239
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12401240
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1339,8 +1339,9 @@ golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7w
13391339
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13401340
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13411341
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1342-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
13431342
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1343+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
1344+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13441345
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
13451346
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
13461347
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

integrations/api_pull_commits_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integrations
6+
7+
import (
8+
"net/http"
9+
"testing"
10+
11+
"code.gitea.io/gitea/models"
12+
api "code.gitea.io/gitea/modules/structs"
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestAPIPullCommits(t *testing.T) {
17+
defer prepareTestEnv(t)()
18+
pullIssue := models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
19+
assert.NoError(t, pullIssue.LoadIssue())
20+
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: pullIssue.HeadRepoID}).(*models.Repository)
21+
22+
session := loginUser(t, "user2")
23+
req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/%s/pulls/%d/commits", repo.OwnerName, repo.Name, pullIssue.Index)
24+
resp := session.MakeRequest(t, req, http.StatusOK)
25+
26+
var commits []*api.Commit
27+
DecodeJSON(t, resp, &commits)
28+
29+
if !assert.Len(t, commits, 2) {
30+
return
31+
}
32+
33+
assert.Equal(t, "5f22f7d0d95d614d25a5b68592adb345a4b5c7fd", commits[0].SHA)
34+
assert.Equal(t, "4a357436d925b5c974181ff12a994538ddc5a269", commits[1].SHA)
35+
}
36+
37+
// TODO add tests for already merged PR and closed PR

integrations/download_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"testing"
1010

11+
"code.gitea.io/gitea/modules/setting"
1112
"github.com/stretchr/testify/assert"
1213
)
1314

@@ -62,3 +63,30 @@ func TestDownloadByIDMediaForSVGUsesSecureHeaders(t *testing.T) {
6263
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
6364
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
6465
}
66+
67+
func TestDownloadRawTextFileWithoutMimeTypeMapping(t *testing.T) {
68+
defer prepareTestEnv(t)()
69+
70+
session := loginUser(t, "user2")
71+
72+
req := NewRequest(t, "GET", "/user2/repo2/raw/branch/master/test.xml")
73+
resp := session.MakeRequest(t, req, http.StatusOK)
74+
75+
assert.Equal(t, "text/plain; charset=utf-8", resp.HeaderMap.Get("Content-Type"))
76+
}
77+
78+
func TestDownloadRawTextFileWithMimeTypeMapping(t *testing.T) {
79+
defer prepareTestEnv(t)()
80+
setting.MimeTypeMap.Map[".xml"] = "text/xml"
81+
setting.MimeTypeMap.Enabled = true
82+
83+
session := loginUser(t, "user2")
84+
85+
req := NewRequest(t, "GET", "/user2/repo2/raw/branch/master/test.xml")
86+
resp := session.MakeRequest(t, req, http.StatusOK)
87+
88+
assert.Equal(t, "text/xml; charset=utf-8", resp.HeaderMap.Get("Content-Type"))
89+
90+
delete(setting.MimeTypeMap.Map, ".xml")
91+
setting.MimeTypeMap.Enabled = false
92+
}

integrations/gitea-repositories-meta/user2/repo2.git/objects/10/32bbf17fbc0d9c95bb5418dabe8f8c99278700

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
x��K
2+
�0Eg� %��":u��􊕦J|������p˭�Q��~%�9ل����G6G� �ͦw(��E4}*���{�)`YƆ�l�e�MJO�ܚ>�����%��^��ݿ�L�!]�N[v#E�6�U~/���0 Z��U'�gpJ5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
205ac761f3326a7ebe416e8673760016450b5cec
1+
1032bbf17fbc0d9c95bb5418dabe8f8c99278700

0 commit comments

Comments
 (0)