Skip to content

Commit be24568

Browse files
committed
Merge branch 'master' of git://github.com/go-gitea/gitea
2 parents d4e8ebc + 0b2d399 commit be24568

File tree

355 files changed

+112343
-52766
lines changed

Some content is hidden

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

355 files changed

+112343
-52766
lines changed

.drone.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ steps:
9595
- make build
9696
environment:
9797
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
98+
GOSUMDB: sum.golang.org
9899
TAGS: bindata sqlite sqlite_unlock_notify
99100

100101
- name: unit-test

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func runServ(c *cli.Context) error {
109109
if key.Type == models.KeyTypeDeploy {
110110
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
111111
} else {
112-
println("Hi there: " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
112+
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
113113
}
114114
println("If this is unexpected, please log in with password and setup Gitea under another user.")
115115
return nil

custom/conf/app.ini.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ ACCESS_TOKEN_EXPIRATION_TIME=3600
726726
REFRESH_TOKEN_EXPIRATION_TIME=730
727727
; Check if refresh token got already used
728728
INVALIDATE_REFRESH_TOKENS=false
729-
; OAuth2 authentication secret for access and refresh tokens, change this a unique string.
729+
; OAuth2 authentication secret for access and refresh tokens, change this to a unique string.
730730
JWT_SECRET=Bk0yK7Y9g_p56v86KaHqjSbxvNvu3SbKoOdOt2ZcXvU
731731

732732
[i18n]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
132132
- `START_SSH_SERVER`: **false**: When enabled, use the built-in SSH server.
133133
- `SSH_DOMAIN`: **%(DOMAIN)s**: Domain name of this server, used for displayed clone URL.
134134
- `SSH_PORT`: **22**: SSH port displayed in clone URL.
135+
- `SSH_LISTEN_HOST`: **0.0.0.0**: Listen address for the built-in SSH server.
135136
- `SSH_LISTEN_PORT`: **%(SSH\_PORT)s**: Port for the built-in SSH server.
136137
- `OFFLINE_MODE`: **false**: Disables use of CDN for static files and Gravatar for profile pictures.
137138
- `DISABLE_ROUTER_LOG`: **false**: Mute printing of the router log.
@@ -155,7 +156,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
155156
## Database (`database`)
156157

157158
- `DB_TYPE`: **mysql**: The database type in use \[mysql, postgres, mssql, sqlite3\].
158-
- `HOST`: **127.0.0.1:3306**: Database host address and port.
159+
- `HOST`: **127.0.0.1:3306**: Database host address and port or absolute path for unix socket \[mysql, postgres\] (ex: /var/run/mysqld/mysqld.sock).
159160
- `NAME`: **gitea**: Database name.
160161
- `USER`: **root**: Database username.
161162
- `PASSWD`: **\<empty\>**: Database user password. Use \`your password\` for quoting if you use special characters in the password.

docs/content/doc/advanced/external-renderers.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ menu:
1717

1818
Gitea supports custom file renderings (i.e., Jupyter notebooks, asciidoc, etc.) through external binaries,
1919
it is just a matter of:
20+
2021
* installing external binaries
2122
* add some configuration to your `app.ini` file
2223
* restart your Gitea instance

integrations/pull_merge_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func testPullCleanUp(t *testing.T, session *TestSession, user, repo, pullnum str
5454

5555
func TestPullMerge(t *testing.T) {
5656
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
57+
hookTasks, err := models.HookTasks(1, 1) //Retrieve previous hook number
58+
assert.NoError(t, err)
59+
hookTasksLenBefore := len(hookTasks)
60+
5761
session := loginUser(t, "user1")
5862
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
5963
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
@@ -63,11 +67,19 @@ func TestPullMerge(t *testing.T) {
6367
elem := strings.Split(test.RedirectURL(resp), "/")
6468
assert.EqualValues(t, "pulls", elem[3])
6569
testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleMerge)
70+
71+
hookTasks, err = models.HookTasks(1, 1)
72+
assert.NoError(t, err)
73+
assert.Len(t, hookTasks, hookTasksLenBefore+1)
6674
})
6775
}
6876

6977
func TestPullRebase(t *testing.T) {
7078
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
79+
hookTasks, err := models.HookTasks(1, 1) //Retrieve previous hook number
80+
assert.NoError(t, err)
81+
hookTasksLenBefore := len(hookTasks)
82+
7183
session := loginUser(t, "user1")
7284
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
7385
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
@@ -77,12 +89,21 @@ func TestPullRebase(t *testing.T) {
7789
elem := strings.Split(test.RedirectURL(resp), "/")
7890
assert.EqualValues(t, "pulls", elem[3])
7991
testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleRebase)
92+
93+
hookTasks, err = models.HookTasks(1, 1)
94+
assert.NoError(t, err)
95+
assert.Len(t, hookTasks, hookTasksLenBefore+1)
8096
})
8197
}
8298

8399
func TestPullRebaseMerge(t *testing.T) {
84100
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
85101
prepareTestEnv(t)
102+
103+
hookTasks, err := models.HookTasks(1, 1) //Retrieve previous hook number
104+
assert.NoError(t, err)
105+
hookTasksLenBefore := len(hookTasks)
106+
86107
session := loginUser(t, "user1")
87108
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
88109
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
@@ -92,12 +113,21 @@ func TestPullRebaseMerge(t *testing.T) {
92113
elem := strings.Split(test.RedirectURL(resp), "/")
93114
assert.EqualValues(t, "pulls", elem[3])
94115
testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleRebaseMerge)
116+
117+
hookTasks, err = models.HookTasks(1, 1)
118+
assert.NoError(t, err)
119+
assert.Len(t, hookTasks, hookTasksLenBefore+1)
95120
})
96121
}
97122

98123
func TestPullSquash(t *testing.T) {
99124
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
100125
prepareTestEnv(t)
126+
127+
hookTasks, err := models.HookTasks(1, 1) //Retrieve previous hook number
128+
assert.NoError(t, err)
129+
hookTasksLenBefore := len(hookTasks)
130+
101131
session := loginUser(t, "user1")
102132
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
103133
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
@@ -108,6 +138,10 @@ func TestPullSquash(t *testing.T) {
108138
elem := strings.Split(test.RedirectURL(resp), "/")
109139
assert.EqualValues(t, "pulls", elem[3])
110140
testPullMerge(t, session, elem[1], elem[2], elem[4], models.MergeStyleSquash)
141+
142+
hookTasks, err = models.HookTasks(1, 1)
143+
assert.NoError(t, err)
144+
assert.Len(t, hookTasks, hookTasksLenBefore+1)
111145
})
112146
}
113147

integrations/repo_commits_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
package integrations
66

77
import (
8+
"encoding/json"
89
"net/http"
10+
"net/http/httptest"
911
"path"
1012
"testing"
1113

14+
"code.gitea.io/gitea/modules/setting"
1215
api "code.gitea.io/gitea/modules/structs"
1316

1417
"github.com/stretchr/testify/assert"
@@ -67,6 +70,29 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
6770
for _, class := range classes {
6871
assert.True(t, sel.HasClass(class))
6972
}
73+
74+
//By SHA
75+
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)+"/statuses")
76+
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
77+
//By Ref
78+
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/master/statuses")
79+
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
80+
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/v1.1/statuses")
81+
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
82+
}
83+
84+
func testRepoCommitsWithStatus(t *testing.T, resp *httptest.ResponseRecorder, state string) {
85+
decoder := json.NewDecoder(resp.Body)
86+
statuses := []*api.Status{}
87+
assert.NoError(t, decoder.Decode(&statuses))
88+
assert.Len(t, statuses, 1)
89+
for _, s := range statuses {
90+
assert.Equal(t, api.StatusState(state), s.State)
91+
assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", s.URL)
92+
assert.Equal(t, "http://test.ci/", s.TargetURL)
93+
assert.Equal(t, "", s.Description)
94+
assert.Equal(t, "testci", s.Context)
95+
}
7096
}
7197

7298
func TestRepoCommitsWithStatusPending(t *testing.T) {

models/commit_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (status *CommitStatus) loadRepo(e Engine) (err error) {
8989
// APIURL returns the absolute APIURL to this commit-status.
9090
func (status *CommitStatus) APIURL() string {
9191
_ = status.loadRepo(x)
92-
return fmt.Sprintf("%sapi/v1/%s/statuses/%s",
92+
return fmt.Sprintf("%sapi/v1/repos/%s/statuses/%s",
9393
setting.AppURL, status.Repo.FullName(), status.SHA)
9494
}
9595

models/commit_status_test.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,25 @@ func TestGetCommitStatuses(t *testing.T) {
2020
statuses, maxResults, err := GetCommitStatuses(repo1, sha1, &CommitStatusOptions{})
2121
assert.NoError(t, err)
2222
assert.Equal(t, int(maxResults), 5)
23-
if assert.Len(t, statuses, 5) {
24-
assert.Equal(t, statuses[0].Context, "ci/awesomeness")
25-
assert.Equal(t, statuses[0].State, CommitStatusPending)
23+
assert.Len(t, statuses, 5)
2624

27-
assert.Equal(t, statuses[1].Context, "cov/awesomeness")
28-
assert.Equal(t, statuses[1].State, CommitStatusWarning)
25+
assert.Equal(t, "ci/awesomeness", statuses[0].Context)
26+
assert.Equal(t, CommitStatusPending, statuses[0].State)
27+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL())
2928

30-
assert.Equal(t, statuses[2].Context, "cov/awesomeness")
31-
assert.Equal(t, statuses[2].State, CommitStatusSuccess)
29+
assert.Equal(t, "cov/awesomeness", statuses[1].Context)
30+
assert.Equal(t, CommitStatusWarning, statuses[1].State)
31+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL())
3232

33-
assert.Equal(t, statuses[3].Context, "ci/awesomeness")
34-
assert.Equal(t, statuses[3].State, CommitStatusFailure)
33+
assert.Equal(t, "cov/awesomeness", statuses[2].Context)
34+
assert.Equal(t, CommitStatusSuccess, statuses[2].State)
35+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL())
3536

36-
assert.Equal(t, statuses[4].Context, "deploy/awesomeness")
37-
assert.Equal(t, statuses[4].State, CommitStatusError)
38-
}
37+
assert.Equal(t, "ci/awesomeness", statuses[3].Context)
38+
assert.Equal(t, CommitStatusFailure, statuses[3].State)
39+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[3].APIURL())
40+
41+
assert.Equal(t, "deploy/awesomeness", statuses[4].Context)
42+
assert.Equal(t, CommitStatusError, statuses[4].State)
43+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL())
3944
}

models/webhook.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ func DeliverHooks() {
890890
for _, t := range tasks {
891891
if err = t.deliver(); err != nil {
892892
log.Error("deliver: %v", err)
893-
continue
894893
}
895894
}
896895

0 commit comments

Comments
 (0)