Skip to content

Commit caf776e

Browse files
authored
Merge branch 'master' into fuzz2
2 parents 6bd9f05 + bc1cf6e commit caf776e

Some content is hidden

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

71 files changed

+464
-242
lines changed

integrations/auth_ldap_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ func TestLDAPUserSync(t *testing.T) {
172172
assert.Equal(t, u.UserName, strings.TrimSpace(tds.Find("td:nth-child(2) a").Text()))
173173
assert.Equal(t, u.Email, strings.TrimSpace(tds.Find("td:nth-child(3) span").Text()))
174174
if u.IsAdmin {
175-
assert.True(t, tds.Find("td:nth-child(5) i").HasClass("fa-check-square-o"))
175+
assert.True(t, tds.Find("td:nth-child(5) svg").HasClass("octicon-check"))
176176
} else {
177-
assert.True(t, tds.Find("td:nth-child(5) i").HasClass("fa-square-o"))
177+
assert.True(t, tds.Find("td:nth-child(5) svg").HasClass("octicon-x"))
178178
}
179179
if u.IsRestricted {
180-
assert.True(t, tds.Find("td:nth-child(6) i").HasClass("fa-check-square-o"))
180+
assert.True(t, tds.Find("td:nth-child(6) svg").HasClass("octicon-check"))
181181
} else {
182-
assert.True(t, tds.Find("td:nth-child(6) i").HasClass("fa-square-o"))
182+
assert.True(t, tds.Find("td:nth-child(6) svg").HasClass("octicon-x"))
183183
}
184184
}
185185

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ var migrations = []Migration{
267267
NewMigration("Add block on official review requests branch protection", addBlockOnOfficialReviewRequests),
268268
// v161 -> v162
269269
NewMigration("Convert task type from int to string", convertTaskTypeToString),
270+
// v162 -> v163
271+
NewMigration("Convert webhook task type from int to string", convertWebhookTaskTypeToString),
270272
}
271273

272274
// GetCurrentDBVersion returns the current db version

models/migrations/v162.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2020 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 migrations
6+
7+
import (
8+
"xorm.io/xorm"
9+
)
10+
11+
func convertWebhookTaskTypeToString(x *xorm.Engine) error {
12+
const (
13+
GOGS int = iota + 1
14+
SLACK
15+
GITEA
16+
DISCORD
17+
DINGTALK
18+
TELEGRAM
19+
MSTEAMS
20+
FEISHU
21+
MATRIX
22+
)
23+
24+
var hookTaskTypes = map[int]string{
25+
GITEA: "gitea",
26+
GOGS: "gogs",
27+
SLACK: "slack",
28+
DISCORD: "discord",
29+
DINGTALK: "dingtalk",
30+
TELEGRAM: "telegram",
31+
MSTEAMS: "msteams",
32+
FEISHU: "feishu",
33+
MATRIX: "matrix",
34+
}
35+
36+
type Webhook struct {
37+
Type string `xorm:"char(16) index"`
38+
}
39+
if err := x.Sync2(new(Webhook)); err != nil {
40+
return err
41+
}
42+
43+
for i, s := range hookTaskTypes {
44+
if _, err := x.Exec("UPDATE webhook set type = ? where hook_task_type=?", s, i); err != nil {
45+
return err
46+
}
47+
}
48+
49+
sess := x.NewSession()
50+
defer sess.Close()
51+
if err := sess.Begin(); err != nil {
52+
return err
53+
}
54+
if err := dropTableColumns(sess, "webhook", "hook_task_type"); err != nil {
55+
return err
56+
}
57+
58+
return sess.Commit()
59+
}

models/repo_generate.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,17 @@ func GenerateWebhooks(ctx DBContext, templateRepo, generateRepo *Repository) err
117117

118118
for _, templateWebhook := range templateWebhooks {
119119
generateWebhook := &Webhook{
120-
RepoID: generateRepo.ID,
121-
URL: templateWebhook.URL,
122-
HTTPMethod: templateWebhook.HTTPMethod,
123-
ContentType: templateWebhook.ContentType,
124-
Secret: templateWebhook.Secret,
125-
HookEvent: templateWebhook.HookEvent,
126-
IsActive: templateWebhook.IsActive,
127-
HookTaskType: templateWebhook.HookTaskType,
128-
OrgID: templateWebhook.OrgID,
129-
Events: templateWebhook.Events,
130-
Meta: templateWebhook.Meta,
120+
RepoID: generateRepo.ID,
121+
URL: templateWebhook.URL,
122+
HTTPMethod: templateWebhook.HTTPMethod,
123+
ContentType: templateWebhook.ContentType,
124+
Secret: templateWebhook.Secret,
125+
HookEvent: templateWebhook.HookEvent,
126+
IsActive: templateWebhook.IsActive,
127+
Type: templateWebhook.Type,
128+
OrgID: templateWebhook.OrgID,
129+
Events: templateWebhook.Events,
130+
Meta: templateWebhook.Meta,
131131
}
132132
if err := createWebhook(ctx.e, generateWebhook); err != nil {
133133
return err

models/webhook.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ type Webhook struct {
110110
Secret string `xorm:"TEXT"`
111111
Events string `xorm:"TEXT"`
112112
*HookEvent `xorm:"-"`
113-
IsSSL bool `xorm:"is_ssl"`
114-
IsActive bool `xorm:"INDEX"`
115-
HookTaskType HookTaskType
116-
Meta string `xorm:"TEXT"` // store hook-specific attributes
117-
LastStatus HookStatus // Last delivery status
113+
IsSSL bool `xorm:"is_ssl"`
114+
IsActive bool `xorm:"INDEX"`
115+
Type HookTaskType `xorm:"char(16) 'type'"`
116+
Meta string `xorm:"TEXT"` // store hook-specific attributes
117+
LastStatus HookStatus // Last delivery status
118118

119119
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
120120
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`

modules/convert/convert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
227227
"url": w.URL,
228228
"content_type": w.ContentType.Name(),
229229
}
230-
if w.HookTaskType == models.SLACK {
230+
if w.Type == models.SLACK {
231231
s := webhook.GetSlackHook(w)
232232
config["channel"] = s.Channel
233233
config["username"] = s.Username
@@ -237,7 +237,7 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
237237

238238
return &api.Hook{
239239
ID: w.ID,
240-
Type: string(w.HookTaskType),
240+
Type: string(w.Type),
241241
URL: fmt.Sprintf("%s/settings/hooks/%d", repoLink, w.ID),
242242
Active: w.IsActive,
243243
Config: config,

modules/templates/helper.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,20 @@ func SVG(icon string, others ...interface{}) template.HTML {
550550
}
551551

552552
// Avatar renders user avatars. args: user, size (int), class (string)
553-
func Avatar(user *models.User, others ...interface{}) template.HTML {
553+
func Avatar(item interface{}, others ...interface{}) template.HTML {
554554
size, class := parseOthers(models.DefaultAvatarPixelSize, "ui avatar image", others...)
555555

556-
src := user.RealSizedAvatarLink(size * models.AvatarRenderedSizeFactor)
557-
if src != "" {
558-
return AvatarHTML(src, size, class, user.DisplayName())
556+
if user, ok := item.(*models.User); ok {
557+
src := user.RealSizedAvatarLink(size * models.AvatarRenderedSizeFactor)
558+
if src != "" {
559+
return AvatarHTML(src, size, class, user.DisplayName())
560+
}
561+
}
562+
if user, ok := item.(*models.Collaborator); ok {
563+
src := user.RealSizedAvatarLink(size * models.AvatarRenderedSizeFactor)
564+
if src != "" {
565+
return AvatarHTML(src, size, class, user.DisplayName())
566+
}
559567
}
560568
return template.HTML("")
561569
}

options/locale/locale_bg-BG.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ write=Пиши
7979
preview=Преглед
8080
loading=Зареждане…
8181

82+
8283
error404=Страницата, която се опитвате да достъпите, <strong>не съществува</strong> или <strong>не сте оторизирани</strong> да я достъпите.
8384

8485
[error]
@@ -782,6 +783,7 @@ pulls.merge_pull_request=Обедини заявка за сливане
782783
pulls.status_checks_success=Всички проверявания бяха успешни
783784
pulls.update_branch=Осъвременяване на клона
784785

786+
785787
milestones.new=Нов етап
786788
milestones.open_tab=%d отворени
787789
milestones.close_tab=%d затворени

options/locale/locale_cs-CZ.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ write=Zapsat
8686
preview=Náhled
8787
loading=Načítá se…
8888

89+
8990
error404=Stránka, kterou se snažíte zobrazit, buď <strong>neexistuje</strong>, nebo <strong>nemáte oprávnění</strong> ji zobrazit.
9091

9192
[error]
@@ -1282,6 +1283,7 @@ pulls.outdated_with_base_branch=Tato větev je zastaralá oproti základní vět
12821283
pulls.closed_at=`uzavřel(a) tento požadavek na natažení <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12831284
pulls.reopened_at=`znovuotevřel(a) tento požadavek na natažení <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12841285

1286+
12851287
milestones.new=Nový milník
12861288
milestones.open_tab=%d otevřených
12871289
milestones.close_tab=%d zavřených

options/locale/locale_de-DE.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ write=Verfassen
8686
preview=Vorschau
8787
loading=Laden…
8888

89+
8990
error404=Die Seite, die du gerade versuchst aufzurufen, <strong>existiert entweder nicht</strong> oder <strong>du bist nicht berechtigt</strong>, diese anzusehen.
9091

9192
[error]
@@ -1281,6 +1282,7 @@ pulls.outdated_with_base_branch=Dieser Branch enthält nicht die neusten Commits
12811282
pulls.closed_at=`hat diesen Pull-Request <a id="%[1]s" href="#%[1]s">%[2]s</a> geschlossen`
12821283
pulls.reopened_at=`hat diesen Pull-Request <a id="%[1]s" href="#%[1]s">%[2]s</a> wieder geöffnet`
12831284

1285+
12841286
milestones.new=Neuer Meilenstein
12851287
milestones.open_tab=%d offen
12861288
milestones.close_tab=%d geschlossen

options/locale/locale_en-US.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ write = Write
8686
preview = Preview
8787
loading = Loading…
8888

89+
step1 = Step 1:
90+
step2 = Step 2:
91+
8992
error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it.
9093

9194
[error]
@@ -1296,6 +1299,10 @@ pulls.update_not_allowed = You are not allowed to update branch
12961299
pulls.outdated_with_base_branch = This branch is out-of-date with the base branch
12971300
pulls.closed_at = `closed this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12981301
pulls.reopened_at = `reopened this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
1302+
pulls.merge_instruction_hint = `You can also view <a class="show-instruction">command line instructions</a>.`
1303+
1304+
pulls.merge_instruction_step1_desc = From your project repository, check out a new branch and test the changes.
1305+
pulls.merge_instruction_step2_desc = Merge the changes and update on Gitea.
12991306
13001307
milestones.new = New Milestone
13011308
milestones.open_tab = %d Open

options/locale/locale_es-ES.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ write=Escribir
8686
preview=Vista previa
8787
loading=Cargando…
8888

89+
8990
error404=La página a la que está intentando acceder o <strong>no existe</strong> o <strong>no está autorizado</strong> para verla.
9091

9192
[error]
@@ -1296,6 +1297,7 @@ pulls.outdated_with_base_branch=Esta rama está desactualizada con la rama base
12961297
pulls.closed_at=`cerró este pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12971298
pulls.reopened_at=`reabrió este pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12981299

1300+
12991301
milestones.new=Nuevo hito
13001302
milestones.open_tab=%d abiertas
13011303
milestones.close_tab=%d cerradas

options/locale/locale_fa-IR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ write=نوشتن
8484
preview=پیش نمایش
8585
loading=بارگذاری…
8686

87+
8788
error404=صفحه موردنظر شما یا <strong>وجود ندارد</strong> یا <strong>شما دسترسی کافی</strong> برای مشاهده آن را ندارید.
8889

8990
[error]
@@ -1175,6 +1176,7 @@ pulls.status_checks_success=تمامی بررسی‎ها موفق بودند
11751176
pulls.update_branch=بروزرسانی شاخه
11761177
pulls.update_branch_success=شاخه به موفقیت بروز شد
11771178

1179+
11781180
milestones.new=نقطه عطف جدید
11791181
milestones.open_tab=%d باز شد
11801182
milestones.close_tab=%d بسته

options/locale/locale_fi-FI.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ write=Kirjoita
7878
preview=Esikatselu
7979
loading=Ladataan…
8080

81+
8182
error404=Sivu, jota yrität nähdä, joko <strong>ei löydy</strong> tai <strong>et ole oikeutettu</strong> katsomaan sitä.
8283

8384
[error]
@@ -765,6 +766,7 @@ pulls.can_auto_merge_desc=Tämä pull-pyyntö voidaan yhdistää automaattisesti
765766
pulls.merge_pull_request=Yhdistä Pull-pyyntö
766767
; </summary><code>%[2]s<br>%[3]s</code></details>
767768

769+
768770
milestones.new=Uusi merkkipaalu
769771
milestones.open_tab=%d avoinna
770772
milestones.close_tab=%d suljettu

options/locale/locale_fr-FR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ write=Écrire
8080
preview=Aperçu
8181
loading=Chargement…
8282
83+
8384
error404=La page que vous essayez d'atteindre <strong>n'existe pas</strong> ou <strong>vous n'êtes pas autorisé</strong> à la voir.
8485

8586
[error]
@@ -1142,6 +1143,7 @@ pulls.outdated_with_base_branch=Cette branche est désynchronisée avec la branc
11421143
pulls.closed_at=`a fermé cette pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
11431144
pulls.reopened_at=`a réouvert cette pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
11441145

1146+
11451147
milestones.new=Nouveau jalon
11461148
milestones.open_tab=%d Ouvert
11471149
milestones.close_tab=%d Fermé

options/locale/locale_hu-HU.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ write=Írás
7979
preview=Előnézet
8080
loading=Betöltés…
8181

82+
8283
error404=Az elérni kívánt oldal vagy <strong>nem létezik</strong>, vagy <strong>nincs jogosultsága</strong> a megtekintéséhez.
8384

8485
[error]
@@ -959,6 +960,7 @@ pulls.squash_merge_pull_request=Squash és egyesítés
959960
pulls.status_checking=Néhány ellenőrzés függőben van
960961
pulls.status_checks_success=Minden ellenőrzés sikeres volt
961962
963+
962964
milestones.new=Új mérföldkő
963965
milestones.open_tab=%d Nyitott
964966
milestones.close_tab=%d Zárt

options/locale/locale_id-ID.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ preview=Pratinjau
8080
loading=Memuat…
8181

8282

83+
8384
[error]
8485

8586
[startpage]
@@ -858,6 +859,7 @@ pulls.rebase_merge_pull_request=Membuat Ulang Dasar dan Menggabungkan
858859
pulls.squash_merge_pull_request=Tindih dan Gabungkan
859860
; </summary><code>%[2]s<br>%[3]s</code></details>
860861

862+
861863
milestones.new=Milestone Baru
862864
milestones.open_tab=%d Terbuka
863865
milestones.close_tab=%d Tertutup

options/locale/locale_it-IT.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ write=Scrivi
8686
preview=Anteprima
8787
loading=Caricamento…
8888
89+
8990
error404=La pagina che stai cercando di raggiungere <strong>non esiste</strong> oppure <strong>non sei autorizzato</strong> a visualizzarla.
9091
9192
[error]
@@ -1250,6 +1251,7 @@ pulls.update_branch_success=Brench aggiornato con successo
12501251
pulls.update_not_allowed=Non sei abilitato ad aggiornare il branch
12511252
pulls.outdated_with_base_branch=Questo brench non è aggiornato con il branch di base
12521253

1254+
12531255
milestones.new=Nuova Milestone
12541256
milestones.open_tab=%d Aperti
12551257
milestones.close_tab=%d Chiusi

options/locale/locale_ja-JP.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ write=書き込み
8686
preview=プレビュー
8787
loading=読み込み中…
8888

89+
8990
error404=アクセスしようとしたページは<strong>存在しない</strong>か、閲覧が<strong>許可されていません</strong>。
9091

9192
[error]
@@ -1295,6 +1296,7 @@ pulls.outdated_with_base_branch=このブランチはベースブランチに対
12951296
pulls.closed_at=`がプルリクエストをクローズ <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12961297
pulls.reopened_at=`がプルリクエストを再オープン <a id="%[1]s" href="#%[1]s">%[2]s</a>`
12971298

1299+
12981300
milestones.new=新しいマイルストーン
12991301
milestones.open_tab=%d件 オープン中
13001302
milestones.close_tab=%d件 クローズ済

options/locale/locale_ko-KR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ preview=미리보기
8080
loading=불러오는 중...
8181

8282

83+
8384
[error]
8485

8586
[startpage]
@@ -882,6 +883,7 @@ pulls.squash_merge_pull_request=스쿼시하고 머지
882883
pulls.invalid_merge_option=이 풀 리퀘스트에서 설정한 머지 옵션을 사용하실 수 없습니다.
883884
; </summary><code>%[2]s<br>%[3]s</code></details>
884885

886+
885887
milestones.new=새로운 마일스톤
886888
milestones.open_tab=%d개 열림
887889
milestones.close_tab=%d개 닫힘

0 commit comments

Comments
 (0)