Skip to content

Commit a178e54

Browse files
authored
Merge branch 'master' into milestones
2 parents 3a71b07 + f6ba912 commit a178e54

Some content is hidden

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

85 files changed

+1639
-668
lines changed

cmd/web.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func runWeb(ctx *cli.Context) error {
122122
switch setting.Protocol {
123123
case setting.UnixSocket:
124124
case setting.FCGI:
125+
case setting.FCGIUnix:
125126
default:
126127
// Save LOCAL_ROOT_URL if port changed
127128
cfg := ini.Empty()
@@ -149,7 +150,7 @@ func runWeb(ctx *cli.Context) error {
149150
}
150151

151152
listenAddr := setting.HTTPAddr
152-
if setting.Protocol != setting.UnixSocket {
153+
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
153154
listenAddr += ":" + setting.HTTPPort
154155
}
155156
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
@@ -183,10 +184,13 @@ func runWeb(ctx *cli.Context) error {
183184
err = runHTTPS("tcp", listenAddr, setting.CertFile, setting.KeyFile, context2.ClearHandler(m))
184185
case setting.FCGI:
185186
NoHTTPRedirector()
186-
err = runFCGI(listenAddr, context2.ClearHandler(m))
187+
err = runFCGI("tcp", listenAddr, context2.ClearHandler(m))
187188
case setting.UnixSocket:
188189
NoHTTPRedirector()
189190
err = runHTTP("unix", listenAddr, context2.ClearHandler(m))
191+
case setting.FCGIUnix:
192+
NoHTTPRedirector()
193+
err = runFCGI("unix", listenAddr, context2.ClearHandler(m))
190194
default:
191195
log.Fatal("Invalid protocol: %s", setting.Protocol)
192196
}

cmd/web_graceful.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func NoMainListener() {
3737
graceful.Manager.InformCleanup()
3838
}
3939

40-
func runFCGI(listenAddr string, m http.Handler) error {
40+
func runFCGI(network, listenAddr string, m http.Handler) error {
4141
// This needs to handle stdin as fcgi point
42-
fcgiServer := graceful.NewServer("tcp", listenAddr)
42+
fcgiServer := graceful.NewServer(network, listenAddr)
4343

4444
err := fcgiServer.ListenAndServe(func(listener net.Listener) error {
4545
return fcgi.Serve(listener, m)

custom/conf/app.ini.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME = true
504504
; Default value for the domain part of the user's email address in the git log
505505
; if he has set KeepEmailPrivate to true. The user's email will be replaced with a
506506
; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
507-
NO_REPLY_ADDRESS = noreply.example.org
507+
NO_REPLY_ADDRESS = noreply.%(DOMAIN)s
508508
; Show Registration button
509509
SHOW_REGISTRATION_BUTTON = true
510510
; Show milestones dashboard page - a view of all the user's milestones

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
140140

141141
## Server (`server`)
142142

143-
- `PROTOCOL`: **http**: \[http, https, fcgi, unix\]
143+
- `PROTOCOL`: **http**: \[http, https, fcgi, unix, fcgi+unix\]
144144
- `DOMAIN`: **localhost**: Domain name of this server.
145145
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
146146
Overwrite the automatically generated public URL.
@@ -155,7 +155,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
155155
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
156156
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
157157
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
158-
- If `PROTOCOL` is set to `unix`, this should be the name of the Unix socket file to use.
158+
- If `PROTOCOL` is set to `unix` or `fcgi+unix`, this should be the name of the Unix socket file to use.
159159
- `HTTP_PORT`: **3000**: HTTP listen port.
160160
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
161161
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
@@ -313,6 +313,8 @@ relation to port exhaustion.
313313
- `DEFAULT_ORG_VISIBILITY`: **public**: Set default visibility mode for organisations, either "public", "limited" or "private".
314314
- `DEFAULT_ORG_MEMBER_VISIBLE`: **false** True will make the membership of the users visible when added to the organisation.
315315
- `ALLOW_ONLY_EXTERNAL_REGISTRATION`: **false** Set to true to force registration only using third-party services.
316+
- `NO_REPLY_ADDRESS`: **DOMAIN** Default value for the domain part of the user's email address in the git log if he has set KeepEmailPrivate to true.
317+
The user's email will be replaced with a concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
316318

317319
## Webhook (`webhook`)
318320

docs/content/doc/advanced/third-party-tools.en-us.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ Check our [CI/CD page]({{< relref "doc/advanced/ci-cd.en-us.md" >}})
3535

3636
### Editor Extensions
3737
- [Gitea Extension for Visual Studio](https://github.com/maikebing/Gitea.VisualStudio) Download from [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=MysticBoy.GiteaExtensionforVisualStudio)
38+
39+
### Project Management
40+
- [YouTrack by JetBrains](https://blog.jetbrains.com/youtrack/2019/12/whats-new-in-youtrack-2019-3/)

docs/content/doc/installation/windows-service.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ To register Gitea as a Windows service, open a command prompt (cmd) as an Admini
4040
then run the following command:
4141

4242
```
43-
sc create gitea start= auto binPath= "\"C:\gitea\gitea.exe\" web --config \"C:\gitea\custom\conf\app.ini\""
43+
sc.exe create gitea start= auto binPath= "\"C:\gitea\gitea.exe\" web --config \"C:\gitea\custom\conf\app.ini\""
4444
```
4545

4646
Do not forget to replace `C:\gitea` with the correct Gitea directory.
@@ -54,5 +54,5 @@ that was configured).
5454
To unregister Gitea as a service, open a command prompt (cmd) as an Administrator and run:
5555

5656
```
57-
sc delete gitea
57+
sc.exe delete gitea
5858
```

docs/static/_headers

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; style-src 'self' https://fonts.googleapis.com https://cdnjs.cloudflare.com; font-src 'self' data: https://cdnjs.cloudflare.com https://fonts.gstatic.com
2+
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdnjs.cloudflare.com; font-src 'self' data: https://cdnjs.cloudflare.com https://fonts.gstatic.com
33
X-Frame-Options: DENY
44
X-Xss-Protection: 1; mode=block
55
X-Content-Type-Options: nosniff

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/go-sql-driver/mysql v1.4.1
4646
github.com/go-swagger/go-swagger v0.20.1
4747
github.com/gobwas/glob v0.2.3
48-
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561
48+
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28
4949
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
5050
github.com/google/go-github/v24 v24.0.1
5151
github.com/gorilla/context v1.1.1
@@ -78,7 +78,6 @@ require (
7878
github.com/quasoft/websspi v1.0.0
7979
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 // indirect
8080
github.com/russross/blackfriday/v2 v2.0.1
81-
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
8281
github.com/satori/go.uuid v1.2.0
8382
github.com/sergi/go-diff v1.0.0
8483
github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b // indirect

go.sum

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk
235235
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
236236
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
237237
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
238-
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561 h1:deE7ritpK04PgtpyVOS2TYcQEld9qLCD5b5EbVNOuLA=
239-
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561/go.mod h1:YgYOrVn3Nj9Tq0EvjmFbphRytDj7JNRoWSStJZWDJTQ=
240238
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
241239
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
242240
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
241+
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28 h1:gBeyun7mySAKWg7Fb0GOcv0upX9bdaZScs8QcRo8mEY=
242+
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
243243
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14 h1:yXtpJr/LV6PFu4nTLgfjQdcMdzjbqqXMEnHfq0Or6p8=
244244
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14/go.mod h1:jPoNZLWDAqA5N3G5amEoiNbhVrmM+ZQEcnQvNQ2KaZk=
245245
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
@@ -477,8 +477,6 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue
477477
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
478478
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
479479
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
480-
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
481-
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
482480
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
483481
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
484482
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
@@ -527,6 +525,7 @@ github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2 h1:JNEGSiWg6D3lcBC
527525
github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2/go.mod h1:mjqs7N0Q6m5HpR7QfXVBZXZWSqTjQLeTujjA/xUp2uw=
528526
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
529527
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
528+
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
530529
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
531530
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
532531
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright 2019 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+
14+
"github.com/stretchr/testify/assert"
15+
)
16+
17+
func TestAPIListStopWatches(t *testing.T) {
18+
defer prepareTestEnv(t)()
19+
20+
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
21+
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
22+
23+
session := loginUser(t, owner.Name)
24+
token := getTokenForLoggedInUser(t, session)
25+
req := NewRequestf(t, "GET", "/api/v1/user/stopwatches?token=%s", token)
26+
resp := session.MakeRequest(t, req, http.StatusOK)
27+
var apiWatches []*api.StopWatch
28+
DecodeJSON(t, resp, &apiWatches)
29+
expect := models.AssertExistsAndLoadBean(t, &models.Stopwatch{UserID: owner.ID}).(*models.Stopwatch)
30+
expectAPI, _ := expect.APIFormat()
31+
assert.Len(t, apiWatches, 1)
32+
33+
assert.EqualValues(t, expectAPI.IssueIndex, apiWatches[0].IssueIndex)
34+
assert.EqualValues(t, expectAPI.Created.Unix(), apiWatches[0].Created.Unix())
35+
}
36+
37+
func TestAPIStopStopWatches(t *testing.T) {
38+
defer prepareTestEnv(t)()
39+
40+
issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
41+
_ = issue.LoadRepo()
42+
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: issue.Repo.OwnerID}).(*models.User)
43+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
44+
45+
session := loginUser(t, user.Name)
46+
token := getTokenForLoggedInUser(t, session)
47+
48+
req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/issues/%d/stopwatch/stop?token=%s", owner.Name, issue.Repo.Name, issue.Index, token)
49+
session.MakeRequest(t, req, http.StatusCreated)
50+
session.MakeRequest(t, req, http.StatusConflict)
51+
}
52+
53+
func TestAPICancelStopWatches(t *testing.T) {
54+
defer prepareTestEnv(t)()
55+
56+
issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 1}).(*models.Issue)
57+
_ = issue.LoadRepo()
58+
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: issue.Repo.OwnerID}).(*models.User)
59+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
60+
61+
session := loginUser(t, user.Name)
62+
token := getTokenForLoggedInUser(t, session)
63+
64+
req := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/issues/%d/stopwatch/delete?token=%s", owner.Name, issue.Repo.Name, issue.Index, token)
65+
session.MakeRequest(t, req, http.StatusNoContent)
66+
session.MakeRequest(t, req, http.StatusConflict)
67+
}
68+
69+
func TestAPIStartStopWatches(t *testing.T) {
70+
defer prepareTestEnv(t)()
71+
72+
issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 3}).(*models.Issue)
73+
_ = issue.LoadRepo()
74+
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: issue.Repo.OwnerID}).(*models.User)
75+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
76+
77+
session := loginUser(t, user.Name)
78+
token := getTokenForLoggedInUser(t, session)
79+
80+
req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/issues/%d/stopwatch/start?token=%s", owner.Name, issue.Repo.Name, issue.Index, token)
81+
session.MakeRequest(t, req, http.StatusCreated)
82+
session.MakeRequest(t, req, http.StatusConflict)
83+
}

integrations/attachement_test.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright 2019 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+
"bytes"
9+
"image"
10+
"image/png"
11+
"io"
12+
"mime/multipart"
13+
"net/http"
14+
"testing"
15+
16+
"code.gitea.io/gitea/modules/test"
17+
"github.com/stretchr/testify/assert"
18+
)
19+
20+
func generateImg() bytes.Buffer {
21+
// Generate image
22+
myImage := image.NewRGBA(image.Rect(0, 0, 32, 32))
23+
var buff bytes.Buffer
24+
png.Encode(&buff, myImage)
25+
return buff
26+
}
27+
28+
func createAttachment(t *testing.T, session *TestSession, repoURL, filename string, buff bytes.Buffer, expectedStatus int) string {
29+
body := &bytes.Buffer{}
30+
31+
//Setup multi-part
32+
writer := multipart.NewWriter(body)
33+
part, err := writer.CreateFormFile("file", filename)
34+
assert.NoError(t, err)
35+
_, err = io.Copy(part, &buff)
36+
assert.NoError(t, err)
37+
err = writer.Close()
38+
assert.NoError(t, err)
39+
40+
csrf := GetCSRF(t, session, repoURL)
41+
42+
req := NewRequestWithBody(t, "POST", "/attachments", body)
43+
req.Header.Add("X-Csrf-Token", csrf)
44+
req.Header.Add("Content-Type", writer.FormDataContentType())
45+
resp := session.MakeRequest(t, req, expectedStatus)
46+
47+
if expectedStatus != http.StatusOK {
48+
return ""
49+
}
50+
var obj map[string]string
51+
DecodeJSON(t, resp, &obj)
52+
return obj["uuid"]
53+
}
54+
55+
func TestCreateAnonymousAttachment(t *testing.T) {
56+
prepareTestEnv(t)
57+
session := emptyTestSession(t)
58+
createAttachment(t, session, "user2/repo1", "image.png", generateImg(), http.StatusFound)
59+
}
60+
61+
func TestCreateIssueAttachement(t *testing.T) {
62+
prepareTestEnv(t)
63+
const repoURL = "user2/repo1"
64+
session := loginUser(t, "user2")
65+
uuid := createAttachment(t, session, repoURL, "image.png", generateImg(), http.StatusOK)
66+
67+
req := NewRequest(t, "GET", repoURL+"/issues/new")
68+
resp := session.MakeRequest(t, req, http.StatusOK)
69+
htmlDoc := NewHTMLParser(t, resp.Body)
70+
71+
link, exists := htmlDoc.doc.Find("form").Attr("action")
72+
assert.True(t, exists, "The template has changed")
73+
74+
postData := map[string]string{
75+
"_csrf": htmlDoc.GetCSRF(),
76+
"title": "New Issue With Attachement",
77+
"content": "some content",
78+
"files[0]": uuid,
79+
}
80+
81+
req = NewRequestWithValues(t, "POST", link, postData)
82+
resp = session.MakeRequest(t, req, http.StatusFound)
83+
test.RedirectURL(resp) // check that redirect URL exists
84+
85+
//Validate that attachement is available
86+
req = NewRequest(t, "GET", "/attachments/"+uuid)
87+
session.MakeRequest(t, req, http.StatusOK)
88+
}

integrations/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func initIntegrationTest() {
125125

126126
setting.SetCustomPathAndConf("", "", "")
127127
setting.NewContext()
128+
os.RemoveAll(models.LocalCopyPath())
128129
setting.CheckLFSVersion()
129130
setting.InitDBConfig()
130131

@@ -182,7 +183,6 @@ func prepareTestEnv(t testing.TB, skip ...int) func() {
182183
deferFn := PrintCurrentTest(t, ourSkip)
183184
assert.NoError(t, models.LoadFixtures())
184185
assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
185-
assert.NoError(t, os.RemoveAll(models.LocalCopyPath()))
186186

187187
assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"),
188188
setting.RepoRootPath))

integrations/release_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestCreateRelease(t *testing.T) {
7878
session := loginUser(t, "user2")
7979
createNewRelease(t, session, "/user2/repo1", "v0.0.1", "v0.0.1", false, false)
8080

81-
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", i18n.Tr("en", "repo.release.stable"), 1)
81+
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", i18n.Tr("en", "repo.release.stable"), 2)
8282
}
8383

8484
func TestCreateReleasePreRelease(t *testing.T) {
@@ -87,7 +87,7 @@ func TestCreateReleasePreRelease(t *testing.T) {
8787
session := loginUser(t, "user2")
8888
createNewRelease(t, session, "/user2/repo1", "v0.0.1", "v0.0.1", true, false)
8989

90-
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", i18n.Tr("en", "repo.release.prerelease"), 1)
90+
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", i18n.Tr("en", "repo.release.prerelease"), 2)
9191
}
9292

9393
func TestCreateReleaseDraft(t *testing.T) {
@@ -96,7 +96,7 @@ func TestCreateReleaseDraft(t *testing.T) {
9696
session := loginUser(t, "user2")
9797
createNewRelease(t, session, "/user2/repo1", "v0.0.1", "v0.0.1", false, true)
9898

99-
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", i18n.Tr("en", "repo.release.draft"), 1)
99+
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", i18n.Tr("en", "repo.release.draft"), 2)
100100
}
101101

102102
func TestCreateReleasePaging(t *testing.T) {

models/attachment.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ func getAttachmentByUUID(e Engine, uuid string) (*Attachment, error) {
133133
return attach, nil
134134
}
135135

136+
// GetAttachmentsByUUIDs returns attachment by given UUID list.
137+
func GetAttachmentsByUUIDs(uuids []string) ([]*Attachment, error) {
138+
return getAttachmentsByUUIDs(x, uuids)
139+
}
140+
136141
func getAttachmentsByUUIDs(e Engine, uuids []string) ([]*Attachment, error) {
137142
if len(uuids) == 0 {
138143
return []*Attachment{}, nil

0 commit comments

Comments
 (0)