Skip to content

Commit fe65658

Browse files
committed
Merge branch 'add-file-tree-to-file-view-page' of github.com:kerwin612/gitea into kerwin612-add-file-tree-to-file-view-page
2 parents bdd78df + 4f90719 commit fe65658

23 files changed

+142
-83
lines changed

models/fixtures/webhook.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,31 @@
2222
content_type: 1 # json
2323
events: '{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}'
2424
is_active: true
25+
2526
-
2627
id: 4
2728
repo_id: 2
2829
url: www.example.com/url4
2930
content_type: 1 # json
3031
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
3132
is_active: true
33+
34+
-
35+
id: 5
36+
repo_id: 0
37+
owner_id: 0
38+
url: www.example.com/url5
39+
content_type: 1 # json
40+
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
41+
is_active: true
42+
is_system_webhook: true
43+
44+
-
45+
id: 6
46+
repo_id: 0
47+
owner_id: 0
48+
url: www.example.com/url6
49+
content_type: 1 # json
50+
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
51+
is_active: true
52+
is_system_webhook: false

models/webhook/webhook_system.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ import (
1111
"code.gitea.io/gitea/modules/optional"
1212
)
1313

14+
// GetSystemOrDefaultWebhooks returns webhooks by given argument or all if argument is missing.
15+
func GetSystemOrDefaultWebhooks(ctx context.Context, isSystemWebhook optional.Option[bool]) ([]*Webhook, error) {
16+
webhooks := make([]*Webhook, 0, 5)
17+
if !isSystemWebhook.Has() {
18+
return webhooks, db.GetEngine(ctx).Where("repo_id=? AND owner_id=?", 0, 0).
19+
Find(&webhooks)
20+
}
21+
22+
return webhooks, db.GetEngine(ctx).
23+
Where("repo_id=? AND owner_id=? AND is_system_webhook=?", 0, 0, isSystemWebhook.Value()).
24+
Find(&webhooks)
25+
}
26+
1427
// GetDefaultWebhooks returns all admin-default webhooks.
1528
func GetDefaultWebhooks(ctx context.Context) ([]*Webhook, error) {
1629
webhooks := make([]*Webhook, 0, 5)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2017 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package webhook
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/db"
10+
"code.gitea.io/gitea/models/unittest"
11+
"code.gitea.io/gitea/modules/optional"
12+
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestGetSystemOrDefaultWebhooks(t *testing.T) {
17+
assert.NoError(t, unittest.PrepareTestDatabase())
18+
19+
hooks, err := GetSystemOrDefaultWebhooks(db.DefaultContext, optional.None[bool]())
20+
assert.NoError(t, err)
21+
if assert.Len(t, hooks, 2) {
22+
assert.Equal(t, int64(5), hooks[0].ID)
23+
assert.Equal(t, int64(6), hooks[1].ID)
24+
}
25+
26+
hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(true))
27+
assert.NoError(t, err)
28+
if assert.Len(t, hooks, 1) {
29+
assert.Equal(t, int64(5), hooks[0].ID)
30+
}
31+
32+
hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(false))
33+
assert.NoError(t, err)
34+
if assert.Len(t, hooks, 1) {
35+
assert.Equal(t, int64(6), hooks[0].ID)
36+
}
37+
}

options/locale/locale_cs-CZ.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Ignorování revizí v <a href="%s">.git-blame-ignorerevs</a>.
11151115
blame.ignore_revs.failed=Nepodařilo se ignorovat revize v <a href="%s">.git-blame-ignore-revs</a>.
11161116
user_search_tooltip=Zobrazí maximálně 30 uživatelů
11171117

1118-
tree_path_not_found_commit=Cesta %[1]s v commitu %[2]s neexistuje
1119-
tree_path_not_found_branch=Cesta %[1]s ve větvi %[2]s neexistuje
1120-
tree_path_not_found_tag=Cesta %[1]s ve značce %[2]s neexistuje
11211118

11221119
transfer.accept=Přijmout převod
11231120
transfer.accept_desc=Převést do „%s“

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,6 @@ blame.ignore_revs=Revisionen in <a href="%s">.git-blame-ignore-revs</a> werden i
11111111
blame.ignore_revs.failed=Fehler beim Ignorieren der Revisionen in <a href="%s">.git-blame-ignore-revs</a>.
11121112
user_search_tooltip=Zeigt maximal 30 Benutzer
11131113
1114-
tree_path_not_found_commit=Pfad %[1]s existiert nicht in Commit%[2]s
1115-
tree_path_not_found_branch=Pfad %[1]s existiert nicht in Branch %[2]s
1116-
tree_path_not_found_tag=Pfad %[1]s existiert nicht in Tag %[2]s
11171114
11181115
transfer.accept=Übertragung Akzeptieren
11191116
transfer.accept_desc=`Übertragung nach "%s"`

options/locale/locale_el-GR.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,6 @@ blame_prior=Προβολή ευθύνης πριν από αυτή την αλλ
992992
blame.ignore_revs=Αγνόηση των αναθεωρήσεων στο <a href="%s">.git-blame-ignore-revs</a>. Πατήστε <a href="%s">εδώ</a> για να το παρακάμψετε και να δείτε την κανονική προβολή ευθυνών.
993993
blame.ignore_revs.failed=Αποτυχία αγνόησης των αναθεωρήσεων στο <a href="%s">.git-blame-ignore-revs</a>.
994994

995-
tree_path_not_found_commit=Η διαδρομή %[1]s δεν υπάρχει στην υποβολή %[2]s
996-
tree_path_not_found_branch=Η διαδρομή %[1]s δεν υπάρχει στον κλάδο %[2]s
997-
tree_path_not_found_tag=Η διαδρομή %[1]s δεν υπάρχει στην ετικέτα %[2]s
998995

999996
transfer.accept=Αποδοχή Μεταφοράς
1000997
transfer.reject=Απόρριψη Μεταφοράς

options/locale/locale_es-ES.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,6 @@ blame_prior=Ver la culpa antes de este cambio
982982
blame.ignore_revs=Ignorando revisiones en <a href="%s">.git-blame-ignore-revs</a>. Haga clic <a href="%s">aquí para saltar</a> y para a la vista normal.
983983
blame.ignore_revs.failed=No se pudieron ignorar las revisiones en <a href="%s">.git-blame-ignore-revs</a>.
984984

985-
tree_path_not_found_commit=La ruta %[1]s no existe en el commit %[2]s
986-
tree_path_not_found_branch=La ruta %[1]s no existe en la rama %[2]s
987-
tree_path_not_found_tag=La ruta %[1]s no existe en la etiqueta %[2]s
988985

989986
transfer.accept=Aceptar transferencia
990987
transfer.reject=Rechazar transferencia

options/locale/locale_fr-FR.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Les révisions dans <a href="%s">.git-blame-ignore-revs</a> so
11151115
blame.ignore_revs.failed=Impossible d'ignorer les révisions dans <a href="%s">.git-blame-ignore-revs</a>.
11161116
user_search_tooltip=Affiche un maximum de 30 utilisateurs
11171117

1118-
tree_path_not_found_commit=Le chemin %[1]s n’existe pas dans la révision %[2]s.
1119-
tree_path_not_found_branch=Le chemin %[1]s n’existe pas dans la branche %[2]s.
1120-
tree_path_not_found_tag=Le chemin %[1]s n’existe pas dans l’étiquette %[2]s.
11211118

11221119
transfer.accept=Accepter le transfert
11231120
transfer.accept_desc=Transférer à « %s »

options/locale/locale_ga-IE.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Ag déanamh neamhairde de leasuithe i <a href="%s">.git-blame-
11151115
blame.ignore_revs.failed=Theip ar neamhaird a dhéanamh ar leasuithe i <a href="%s">.git-blame-ignore-revs</a>.
11161116
user_search_tooltip=Taispeáint uasmhéid de 30 úsáideoir
11171117
1118-
tree_path_not_found_commit=Níl cosán %[1]s ann i dtiomantas %[2]s
1119-
tree_path_not_found_branch=Níl cosán %[1]s ann i mbrainse %[2]s
1120-
tree_path_not_found_tag=Níl cosán %[1]s ann i gclib %[2]s
11211118
11221119
transfer.accept=Glac le hAistriú
11231120
transfer.accept_desc=Aistriú chuig “%s”

options/locale/locale_ja-JP.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,6 @@ blame_prior=この変更より前のBlameを表示
11091109
blame.ignore_revs=<a href="%s">.git-blame-ignore-revs</a> で指定されたリビジョンは除外しています。 これを迂回して通常のBlame表示を見るには <a href="%s">ここ</a>をクリック。
11101110
blame.ignore_revs.failed=<a href="%s">.git-blame-ignore-revs</a> によるリビジョンの無視は失敗しました。
11111111

1112-
tree_path_not_found_commit=パス %[1]s はコミット %[2]s に存在しません
1113-
tree_path_not_found_branch=パス %[1]s はブランチ %[2]s に存在しません
1114-
tree_path_not_found_tag=パス %[1]s はタグ %[2]s に存在しません
11151112

11161113
transfer.accept=移転を承認
11171114
transfer.accept_desc=`"%s" に移転`

0 commit comments

Comments
 (0)