Skip to content

Commit 77e8790

Browse files
Merge branch 'master' into fix-go-gitea#6946-pass-in-pr-into-hooks
2 parents c015839 + e5a4d78 commit 77e8790

File tree

111 files changed

+5923
-1542
lines changed

Some content is hidden

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

111 files changed

+5923
-1542
lines changed

.drone.yml

Lines changed: 534 additions & 330 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ the destination platform from the [downloads page](https://dl.gitea.io/gitea/),
2121
the URL and replace the URL within the commands below:
2222

2323
```sh
24-
wget -O gitea https://dl.gitea.io/gitea/1.7.0/gitea-1.7.0-linux-amd64
24+
wget -O gitea https://dl.gitea.io/gitea/1.8.3/gitea-1.8.3-linux-amd64
2525
chmod +x gitea
2626
```
2727

@@ -30,7 +30,7 @@ Gitea signs all binaries with a [GPG key](https://pgp.mit.edu/pks/lookup?op=vind
3030

3131
```sh
3232
gpg --keyserver pgp.mit.edu --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
33-
gpg --verify gitea-1.7.0-linux-amd64.asc gitea-1.7.0-linux-amd64
33+
gpg --verify gitea-1.8.3-linux-amd64.asc gitea-1.8.3-linux-amd64
3434
```
3535

3636
## Test

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ require (
140140
xorm.io/core v0.6.3
141141
)
142142

143-
replace github.com/denisenkom/go-mssqldb => github.com/denisenkom/go-mssqldb v0.0.0-20161128230840-e32ca5036449
143+
replace github.com/denisenkom/go-mssqldb => github.com/denisenkom/go-mssqldb v0.0.0-20180314172330-6a30f4e59a44

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0
6060
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6161
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6262
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
63-
github.com/denisenkom/go-mssqldb v0.0.0-20161128230840-e32ca5036449 h1:JpA+YMG4JLW8nzLmU05mTiuB0O17xHGxpWolEZ0zDuA=
64-
github.com/denisenkom/go-mssqldb v0.0.0-20161128230840-e32ca5036449/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc=
63+
github.com/denisenkom/go-mssqldb v0.0.0-20180314172330-6a30f4e59a44 h1:x0uHqLQTSEL9LKic8sWDt3ASkq07ve5ojIIUl5uF64M=
64+
github.com/denisenkom/go-mssqldb v0.0.0-20180314172330-6a30f4e59a44/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc=
6565
github.com/dgrijalva/jwt-go v0.0.0-20161101193935-9ed569b5d1ac h1:xrQJVwQCGqDvOO7/0+RyIq5J2M3Q4ZF7Ug/BMQtML1E=
6666
github.com/dgrijalva/jwt-go v0.0.0-20161101193935-9ed569b5d1ac/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
6767
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 h1:aaQcKT9WumO6JEJcRyTqFVq4XUZiUcKR2/GI31TOcz8=

integrations/api_repo_file_content_test.go

Lines changed: 0 additions & 117 deletions
This file was deleted.

integrations/api_repo_file_create_test.go

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func getCreateFileOptions() api.CreateFileOptions {
2828
FileOptions: api.FileOptions{
2929
BranchName: "master",
3030
NewBranchName: "master",
31-
Message: "Creates new/file.txt",
31+
Message: "Making this new file new/file.txt",
3232
Author: api.Identity{
3333
Name: "John Doe",
3434
@@ -44,21 +44,29 @@ func getCreateFileOptions() api.CreateFileOptions {
4444

4545
func getExpectedFileResponseForCreate(commitID, treePath string) *api.FileResponse {
4646
sha := "a635aa942442ddfdba07468cf9661c08fbdf0ebf"
47+
encoding := "base64"
48+
content := "VGhpcyBpcyBuZXcgdGV4dA=="
49+
selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath + "?ref=master"
50+
htmlURL := setting.AppURL + "user2/repo1/src/branch/master/" + treePath
51+
gitURL := setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha
52+
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + treePath
4753
return &api.FileResponse{
48-
Content: &api.FileContentResponse{
54+
Content: &api.ContentsResponse{
4955
Name: filepath.Base(treePath),
5056
Path: treePath,
5157
SHA: sha,
5258
Size: 16,
53-
URL: setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath,
54-
HTMLURL: setting.AppURL + "user2/repo1/blob/master/" + treePath,
55-
GitURL: setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha,
56-
DownloadURL: setting.AppURL + "user2/repo1/raw/branch/master/" + treePath,
57-
Type: "blob",
59+
Type: "file",
60+
Encoding: &encoding,
61+
Content: &content,
62+
URL: &selfURL,
63+
HTMLURL: &htmlURL,
64+
GitURL: &gitURL,
65+
DownloadURL: &downloadURL,
5866
Links: &api.FileLinksResponse{
59-
Self: setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath,
60-
GitURL: setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha,
61-
HTMLURL: setting.AppURL + "user2/repo1/blob/master/" + treePath,
67+
Self: &selfURL,
68+
GitURL: &gitURL,
69+
HTMLURL: &htmlURL,
6270
},
6371
},
6472
Commit: &api.FileCommitResponse{
@@ -145,11 +153,24 @@ func TestAPICreateFile(t *testing.T) {
145153
var fileResponse api.FileResponse
146154
DecodeJSON(t, resp, &fileResponse)
147155
expectedSHA := "a635aa942442ddfdba07468cf9661c08fbdf0ebf"
148-
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/blob/new_branch/new/file%d.txt", fileID)
156+
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/new/file%d.txt", fileID)
149157
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/new/file%d.txt", fileID)
150158
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
151-
assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL)
152-
assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL)
159+
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
160+
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
161+
assert.EqualValues(t, createFileOptions.Message+"\n", fileResponse.Commit.Message)
162+
163+
// Test creating a file without a message
164+
createFileOptions = getCreateFileOptions()
165+
createFileOptions.Message = ""
166+
fileID++
167+
treePath = fmt.Sprintf("new/file%d.txt", fileID)
168+
url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
169+
req = NewRequestWithJSON(t, "POST", url, &createFileOptions)
170+
resp = session.MakeRequest(t, req, http.StatusCreated)
171+
DecodeJSON(t, resp, &fileResponse)
172+
expectedMessage := "Add '" + treePath + "'\n"
173+
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
153174

154175
// Test trying to create a file that already exists, should fail
155176
createFileOptions = getCreateFileOptions()

integrations/api_repo_file_delete_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func getDeleteFileOptions() *api.DeleteFileOptions {
2323
FileOptions: api.FileOptions{
2424
BranchName: "master",
2525
NewBranchName: "master",
26-
Message: "Updates new/file.txt",
26+
Message: "Removing the file new/file.txt",
2727
Author: api.Identity{
2828
Name: "John Doe",
2929
@@ -89,6 +89,20 @@ func TestAPIDeleteFile(t *testing.T) {
8989
DecodeJSON(t, resp, &fileResponse)
9090
assert.NotNil(t, fileResponse)
9191
assert.Nil(t, fileResponse.Content)
92+
assert.EqualValues(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message)
93+
94+
// Test deleting file without a message
95+
fileID++
96+
treePath = fmt.Sprintf("delete/file%d.txt", fileID)
97+
createFile(user2, repo1, treePath)
98+
deleteFileOptions = getDeleteFileOptions()
99+
deleteFileOptions.Message = ""
100+
url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
101+
req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions)
102+
resp = session.MakeRequest(t, req, http.StatusOK)
103+
DecodeJSON(t, resp, &fileResponse)
104+
expectedMessage := "Delete '" + treePath + "'\n"
105+
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
92106

93107
// Test deleting a file with the wrong SHA
94108
fileID++

integrations/api_repo_file_update_test.go

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,51 @@ func getUpdateFileOptions() *api.UpdateFileOptions {
2525
content := "This is updated text"
2626
contentEncoded := base64.StdEncoding.EncodeToString([]byte(content))
2727
return &api.UpdateFileOptions{
28-
DeleteFileOptions: *getDeleteFileOptions(),
29-
Content: contentEncoded,
28+
DeleteFileOptions: api.DeleteFileOptions{
29+
FileOptions: api.FileOptions{
30+
BranchName: "master",
31+
NewBranchName: "master",
32+
Message: "My update of new/file.txt",
33+
Author: api.Identity{
34+
Name: "John Doe",
35+
36+
},
37+
Committer: api.Identity{
38+
Name: "Jane Doe",
39+
40+
},
41+
},
42+
SHA: "103ff9234cefeee5ec5361d22b49fbb04d385885",
43+
},
44+
Content: contentEncoded,
3045
}
3146
}
3247

3348
func getExpectedFileResponseForUpdate(commitID, treePath string) *api.FileResponse {
3449
sha := "08bd14b2e2852529157324de9c226b3364e76136"
50+
encoding := "base64"
51+
content := "VGhpcyBpcyB1cGRhdGVkIHRleHQ="
52+
selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath + "?ref=master"
53+
htmlURL := setting.AppURL + "user2/repo1/src/branch/master/" + treePath
54+
gitURL := setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha
55+
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + treePath
3556
return &api.FileResponse{
36-
Content: &api.FileContentResponse{
57+
Content: &api.ContentsResponse{
3758
Name: filepath.Base(treePath),
3859
Path: treePath,
3960
SHA: sha,
61+
Type: "file",
4062
Size: 20,
41-
URL: setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath,
42-
HTMLURL: setting.AppURL + "user2/repo1/blob/master/" + treePath,
43-
GitURL: setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha,
44-
DownloadURL: setting.AppURL + "user2/repo1/raw/branch/master/" + treePath,
45-
Type: "blob",
63+
Encoding: &encoding,
64+
Content: &content,
65+
URL: &selfURL,
66+
HTMLURL: &htmlURL,
67+
GitURL: &gitURL,
68+
DownloadURL: &downloadURL,
4669
Links: &api.FileLinksResponse{
47-
Self: setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath,
48-
GitURL: setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha,
49-
HTMLURL: setting.AppURL + "user2/repo1/blob/master/" + treePath,
70+
Self: &selfURL,
71+
GitURL: &gitURL,
72+
HTMLURL: &htmlURL,
5073
},
5174
},
5275
Commit: &api.FileCommitResponse{
@@ -67,7 +90,7 @@ func getExpectedFileResponseForUpdate(commitID, treePath string) *api.FileRespon
6790
6891
},
6992
},
70-
Message: "Updates README.md\n",
93+
Message: "My update of README.md\n",
7194
},
7295
Verification: &api.PayloadCommitVerification{
7396
Verified: false,
@@ -135,11 +158,12 @@ func TestAPIUpdateFile(t *testing.T) {
135158
var fileResponse api.FileResponse
136159
DecodeJSON(t, resp, &fileResponse)
137160
expectedSHA := "08bd14b2e2852529157324de9c226b3364e76136"
138-
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/blob/new_branch/update/file%d.txt", fileID)
161+
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/update/file%d.txt", fileID)
139162
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/update/file%d.txt", fileID)
140163
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
141-
assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL)
142-
assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL)
164+
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
165+
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
166+
assert.EqualValues(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message)
143167

144168
// Test updating a file and renaming it
145169
updateFileOptions = getUpdateFileOptions()
@@ -154,11 +178,25 @@ func TestAPIUpdateFile(t *testing.T) {
154178
resp = session.MakeRequest(t, req, http.StatusOK)
155179
DecodeJSON(t, resp, &fileResponse)
156180
expectedSHA = "08bd14b2e2852529157324de9c226b3364e76136"
157-
expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/blob/master/rename/update/file%d.txt", fileID)
181+
expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID)
158182
expectedDownloadURL = fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/master/rename/update/file%d.txt", fileID)
159183
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
160-
assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL)
161-
assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL)
184+
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
185+
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
186+
187+
// Test updating a file without a message
188+
updateFileOptions = getUpdateFileOptions()
189+
updateFileOptions.Message = ""
190+
updateFileOptions.BranchName = repo1.DefaultBranch
191+
fileID++
192+
treePath = fmt.Sprintf("update/file%d.txt", fileID)
193+
createFile(user2, repo1, treePath)
194+
url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
195+
req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions)
196+
resp = session.MakeRequest(t, req, http.StatusOK)
197+
DecodeJSON(t, resp, &fileResponse)
198+
expectedMessage := "Update '" + treePath + "'\n"
199+
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
162200

163201
// Test updating a file with the wrong SHA
164202
fileID++

0 commit comments

Comments
 (0)