Skip to content

Commit 7c721df

Browse files
authored
Merge branch 'master' into fix_8872
2 parents 527fb48 + d2aee2a commit 7c721df

File tree

19 files changed

+279
-119
lines changed

19 files changed

+279
-119
lines changed

custom/conf/app.ini.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ DELIVER_TIMEOUT = 5
511511
SKIP_TLS_VERIFY = false
512512
; Number of history information in each page
513513
PAGING_NUM = 10
514+
; Proxy server URL, support http://, https//, socks://, blank will follow environment http_proxy/https_proxy
515+
PROXY_URL =
516+
; Comma separated list of host names requiring proxy. Glob patterns (*) are accepted; use ** to match all hosts.
517+
PROXY_HOSTS =
514518

515519
[mailer]
516520
ENABLED = false

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ relation to port exhaustion.
312312
- `DELIVER_TIMEOUT`: **5**: Delivery timeout (sec) for shooting webhooks.
313313
- `SKIP_TLS_VERIFY`: **false**: Allow insecure certification.
314314
- `PAGING_NUM`: **10**: Number of webhook history events that are shown in one page.
315+
- `PROXY_URL`: ****: Proxy server URL, support http://, https//, socks://, blank will follow environment http_proxy/https_proxy
316+
- `PROXY_HOSTS`: ****: Comma separated list of host names requiring proxy. Glob patterns (*) are accepted; use ** to match all hosts.
315317

316318
## Mailer (`mailer`)
317319

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ menu:
129129
- `DELIVER_TIMEOUT`: 请求webhooks的超时时间,单位秒。
130130
- `SKIP_TLS_VERIFY`: 是否允许不安全的证书。
131131
- `PAGING_NUM`: 每页显示的Webhook 历史数量。
132+
- `PROXY_URL`: ****: 代理服务器网址,支持 http://, https//, socks://, 为空将使用环境变量中的 http_proxy/https_proxy 设置。
133+
- `PROXY_HOSTS`: ****: 逗号分隔的需要代理的域名或IP地址。支持 * 号匹配符,使用 ** 匹配所有域名和IP地址。
132134

133135
## Mailer (`mailer`)
134136

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
date: "2019-03-11T21:45:00+00:00"
3+
title: "高级: 第三方工具"
4+
slug: "third-party-tools"
5+
weight: 50
6+
toc: true
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "advanced"
11+
name: "第三方工具"
12+
weight: 50
13+
identifier: "third-party-tools"
14+
---
15+
16+
# 第三方工具列表
17+
**注意:** 这些工具并没有经过Gitea的检验,在这里列出它们只是为了便捷.
18+
19+
*此列表并不是完整的列表,可以随时咨询如何添加!*
20+
21+
### 持续集成
22+
[BuildKite 连接器](https://github.com/techknowlogick/gitea-buildkite-connector)
23+
[Jenkins 插件](https://github.com/jenkinsci/gitea-plugin)
24+
[Gitea搭配Drone](https://docs.drone.io/installation/gitea)
25+
26+
27+
### 迁移
28+
[Gitea安装脚本](https://git.coolaj86.com/coolaj86/gitea-installer.sh)
29+
[GitHub迁移](https://gitea.com/gitea/migrator)
30+
31+
32+
### 移动端
33+
[安卓客户端GitNex](https://gitlab.com/mmarif4u/gitnex)
34+
35+
### 编辑器扩展
36+
- [Gitea的Visual Studio扩展](https://github.com/maikebing/Gitea.VisualStudio)[Visual Studio 扩展市场](https://marketplace.visualstudio.com/items?itemName=MysticBoy.GiteaExtensionforVisualStudio) 下载

integrations/api_repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func testAPIRepoMigrateConflict(t *testing.T, u *url.URL) {
334334
resp := httpContext.Session.MakeRequest(t, req, http.StatusConflict)
335335
respJSON := map[string]string{}
336336
DecodeJSON(t, resp, &respJSON)
337-
assert.Equal(t, respJSON["message"], "The repository with the same name already exists.")
337+
assert.Equal(t, "The repository with the same name already exists.", respJSON["message"])
338338
})
339339
}
340340

models/action.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -283,49 +283,6 @@ func (a *Action) GetIssueContent() string {
283283
return issue.Content
284284
}
285285

286-
func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
287-
if err = notifyWatchers(e, &Action{
288-
ActUserID: u.ID,
289-
ActUser: u,
290-
OpType: ActionCreateRepo,
291-
RepoID: repo.ID,
292-
Repo: repo,
293-
IsPrivate: repo.IsPrivate,
294-
}); err != nil {
295-
return fmt.Errorf("notify watchers '%d/%d': %v", u.ID, repo.ID, err)
296-
}
297-
298-
log.Trace("action.newRepoAction: %s/%s", u.Name, repo.Name)
299-
return err
300-
}
301-
302-
// NewRepoAction adds new action for creating repository.
303-
func NewRepoAction(u *User, repo *Repository) (err error) {
304-
return newRepoAction(x, u, repo)
305-
}
306-
307-
func renameRepoAction(e Engine, actUser *User, oldRepoName string, repo *Repository) (err error) {
308-
if err = notifyWatchers(e, &Action{
309-
ActUserID: actUser.ID,
310-
ActUser: actUser,
311-
OpType: ActionRenameRepo,
312-
RepoID: repo.ID,
313-
Repo: repo,
314-
IsPrivate: repo.IsPrivate,
315-
Content: oldRepoName,
316-
}); err != nil {
317-
return fmt.Errorf("notify watchers: %v", err)
318-
}
319-
320-
log.Trace("action.renameRepoAction: %s/%s", actUser.Name, repo.Name)
321-
return nil
322-
}
323-
324-
// RenameRepoAction adds new action for renaming a repository.
325-
func RenameRepoAction(actUser *User, oldRepoName string, repo *Repository) error {
326-
return renameRepoAction(x, actUser, oldRepoName, repo)
327-
}
328-
329286
// PushCommit represents a commit in a push operation.
330287
type PushCommit struct {
331288
Sha1 string

models/action_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package models
22

33
import (
44
"path"
5-
"strings"
65
"testing"
76

87
"code.gitea.io/gitea/modules/setting"
@@ -28,58 +27,6 @@ func TestAction_GetRepoLink(t *testing.T) {
2827
assert.Equal(t, expected, action.GetRepoLink())
2928
}
3029

31-
func TestNewRepoAction(t *testing.T) {
32-
assert.NoError(t, PrepareTestDatabase())
33-
34-
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
35-
repo := AssertExistsAndLoadBean(t, &Repository{OwnerID: user.ID}).(*Repository)
36-
repo.Owner = user
37-
38-
actionBean := &Action{
39-
OpType: ActionCreateRepo,
40-
ActUserID: user.ID,
41-
RepoID: repo.ID,
42-
ActUser: user,
43-
Repo: repo,
44-
IsPrivate: repo.IsPrivate,
45-
}
46-
47-
AssertNotExistsBean(t, actionBean)
48-
assert.NoError(t, NewRepoAction(user, repo))
49-
AssertExistsAndLoadBean(t, actionBean)
50-
CheckConsistencyFor(t, &Action{})
51-
}
52-
53-
func TestRenameRepoAction(t *testing.T) {
54-
assert.NoError(t, PrepareTestDatabase())
55-
56-
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
57-
repo := AssertExistsAndLoadBean(t, &Repository{OwnerID: user.ID}).(*Repository)
58-
repo.Owner = user
59-
60-
oldRepoName := repo.Name
61-
const newRepoName = "newRepoName"
62-
repo.Name = newRepoName
63-
repo.LowerName = strings.ToLower(newRepoName)
64-
65-
actionBean := &Action{
66-
OpType: ActionRenameRepo,
67-
ActUserID: user.ID,
68-
ActUser: user,
69-
RepoID: repo.ID,
70-
Repo: repo,
71-
IsPrivate: repo.IsPrivate,
72-
Content: oldRepoName,
73-
}
74-
AssertNotExistsBean(t, actionBean)
75-
assert.NoError(t, RenameRepoAction(user, oldRepoName, repo))
76-
AssertExistsAndLoadBean(t, actionBean)
77-
78-
_, err := x.ID(repo.ID).Cols("name", "lower_name").Update(repo)
79-
assert.NoError(t, err)
80-
CheckConsistencyFor(t, &Action{})
81-
}
82-
8330
func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
8431
pushCommits := NewPushCommits()
8532
pushCommits.Commits = []*PushCommit{

models/repo.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,8 +1469,15 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
14691469
return fmt.Errorf("watchRepo: %v", err)
14701470
}
14711471
}
1472-
if err = newRepoAction(e, doer, repo); err != nil {
1473-
return fmt.Errorf("newRepoAction: %v", err)
1472+
if err = notifyWatchers(e, &Action{
1473+
ActUserID: doer.ID,
1474+
ActUser: doer,
1475+
OpType: ActionCreateRepo,
1476+
RepoID: repo.ID,
1477+
Repo: repo,
1478+
IsPrivate: repo.IsPrivate,
1479+
}); err != nil {
1480+
return fmt.Errorf("notify watchers '%d/%d': %v", doer.ID, repo.ID, err)
14741481
}
14751482

14761483
if err = copyDefaultWebhooksToRepo(e, repo.ID); err != nil {
@@ -2833,3 +2840,9 @@ func (repo *Repository) GetTreePathLock(treePath string) (*LFSLock, error) {
28332840
}
28342841
return nil, nil
28352842
}
2843+
2844+
// UpdateRepositoryCols updates repository's columns
2845+
func UpdateRepositoryCols(repo *Repository, cols ...string) error {
2846+
_, err := x.ID(repo.ID).Cols(cols...).Update(repo)
2847+
return err
2848+
}

modules/notification/action/action.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
_ base.Notifier = &actionNotifier{}
2121
)
2222

23-
// NewNotifier create a new webhookNotifier notifier
23+
// NewNotifier create a new actionNotifier notifier
2424
func NewNotifier() base.Notifier {
2525
return &actionNotifier{}
2626
}
@@ -75,3 +75,19 @@ func (a *actionNotifier) NotifyNewPullRequest(pull *models.PullRequest) {
7575
log.Error("NotifyWatchers: %v", err)
7676
}
7777
}
78+
79+
func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldName string) {
80+
if err := models.NotifyWatchers(&models.Action{
81+
ActUserID: doer.ID,
82+
ActUser: doer,
83+
OpType: models.ActionRenameRepo,
84+
RepoID: repo.ID,
85+
Repo: repo,
86+
IsPrivate: repo.IsPrivate,
87+
Content: oldName,
88+
}); err != nil {
89+
log.Error("notify watchers: %v", err)
90+
} else {
91+
log.Trace("action.renameRepoAction: %s/%s", doer.Name, repo.Name)
92+
}
93+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 action
6+
7+
import (
8+
"path/filepath"
9+
"strings"
10+
"testing"
11+
12+
"code.gitea.io/gitea/models"
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestMain(m *testing.M) {
17+
models.MainTest(m, filepath.Join("..", "..", ".."))
18+
}
19+
20+
func TestRenameRepoAction(t *testing.T) {
21+
assert.NoError(t, models.PrepareTestDatabase())
22+
23+
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
24+
repo := models.AssertExistsAndLoadBean(t, &models.Repository{OwnerID: user.ID}).(*models.Repository)
25+
repo.Owner = user
26+
27+
oldRepoName := repo.Name
28+
const newRepoName = "newRepoName"
29+
repo.Name = newRepoName
30+
repo.LowerName = strings.ToLower(newRepoName)
31+
32+
actionBean := &models.Action{
33+
OpType: models.ActionRenameRepo,
34+
ActUserID: user.ID,
35+
ActUser: user,
36+
RepoID: repo.ID,
37+
Repo: repo,
38+
IsPrivate: repo.IsPrivate,
39+
Content: oldRepoName,
40+
}
41+
models.AssertNotExistsBean(t, actionBean)
42+
43+
NewNotifier().NotifyRenameRepository(user, repo, oldRepoName)
44+
45+
models.AssertExistsAndLoadBean(t, actionBean)
46+
models.CheckConsistencyFor(t, &models.Action{})
47+
}

modules/notification/base/notifier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Notifier interface {
1717
NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository)
1818
NotifyDeleteRepository(doer *models.User, repo *models.Repository)
1919
NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository)
20+
NotifyRenameRepository(doer *models.User, repo *models.Repository, oldName string)
2021

2122
NotifyNewIssue(*models.Issue)
2223
NotifyIssueChangeStatus(*models.User, *models.Issue, bool)

modules/notification/base/null.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (*NullNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repo
6666
func (*NullNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) {
6767
}
6868

69+
// NotifyRenameRepository places a place holder function
70+
func (*NullNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldName string) {
71+
}
72+
6973
// NotifyNewRelease places a place holder function
7074
func (*NullNotifier) NotifyNewRelease(rel *models.Release) {
7175
}

modules/notification/notification.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ func NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) {
115115
}
116116
}
117117

118+
// NotifyRenameRepository notifies repository renamed
119+
func NotifyRenameRepository(doer *models.User, repo *models.Repository, oldName string) {
120+
for _, notifier := range notifiers {
121+
notifier.NotifyRenameRepository(doer, repo, oldName)
122+
}
123+
}
124+
118125
// NotifyNewRelease notifies new release to notifiers
119126
func NotifyNewRelease(rel *models.Release) {
120127
for _, notifier := range notifiers {

modules/setting/webhook.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
package setting
66

7+
import (
8+
"net/url"
9+
10+
"code.gitea.io/gitea/modules/log"
11+
)
12+
713
var (
814
// Webhook settings
915
Webhook = struct {
@@ -12,11 +18,16 @@ var (
1218
SkipTLSVerify bool
1319
Types []string
1420
PagingNum int
21+
ProxyURL string
22+
ProxyURLFixed *url.URL
23+
ProxyHosts []string
1524
}{
1625
QueueLength: 1000,
1726
DeliverTimeout: 5,
1827
SkipTLSVerify: false,
1928
PagingNum: 10,
29+
ProxyURL: "",
30+
ProxyHosts: []string{},
2031
}
2132
)
2233

@@ -27,4 +38,14 @@ func newWebhookService() {
2738
Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
2839
Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams"}
2940
Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
41+
Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("")
42+
if Webhook.ProxyURL != "" {
43+
var err error
44+
Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL)
45+
if err != nil {
46+
log.Error("Webhook PROXY_URL is not valid")
47+
Webhook.ProxyURL = ""
48+
}
49+
}
50+
Webhook.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",")
3051
}

modules/task/migrate.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ func runMigrateTask(t *models.Task) (err error) {
9797
opts.MigrateToRepoID = t.RepoID
9898
repo, err := migrations.MigrateRepository(t.Doer, t.Owner.Name, *opts)
9999
if err == nil {
100-
notification.NotifyMigrateRepository(t.Doer, t.Owner, repo)
101-
102100
log.Trace("Repository migrated [%d]: %s/%s", repo.ID, t.Owner.Name, repo.Name)
103101
return nil
104102
}

0 commit comments

Comments
 (0)