mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-17 17:32:56 +02:00
Merge branch 'add-file-tree-to-file-view-page' of github.com:kerwin612/gitea into kerwin612-add-file-tree-to-file-view-page
This commit is contained in:
commit
fe656586f5
@ -22,6 +22,7 @@
|
||||
content_type: 1 # json
|
||||
events: '{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}'
|
||||
is_active: true
|
||||
|
||||
-
|
||||
id: 4
|
||||
repo_id: 2
|
||||
@ -29,3 +30,23 @@
|
||||
content_type: 1 # json
|
||||
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
|
||||
is_active: true
|
||||
|
||||
-
|
||||
id: 5
|
||||
repo_id: 0
|
||||
owner_id: 0
|
||||
url: www.example.com/url5
|
||||
content_type: 1 # json
|
||||
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
|
||||
is_active: true
|
||||
is_system_webhook: true
|
||||
|
||||
-
|
||||
id: 6
|
||||
repo_id: 0
|
||||
owner_id: 0
|
||||
url: www.example.com/url6
|
||||
content_type: 1 # json
|
||||
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
|
||||
is_active: true
|
||||
is_system_webhook: false
|
||||
|
@ -11,6 +11,19 @@ import (
|
||||
"code.gitea.io/gitea/modules/optional"
|
||||
)
|
||||
|
||||
// GetSystemOrDefaultWebhooks returns webhooks by given argument or all if argument is missing.
|
||||
func GetSystemOrDefaultWebhooks(ctx context.Context, isSystemWebhook optional.Option[bool]) ([]*Webhook, error) {
|
||||
webhooks := make([]*Webhook, 0, 5)
|
||||
if !isSystemWebhook.Has() {
|
||||
return webhooks, db.GetEngine(ctx).Where("repo_id=? AND owner_id=?", 0, 0).
|
||||
Find(&webhooks)
|
||||
}
|
||||
|
||||
return webhooks, db.GetEngine(ctx).
|
||||
Where("repo_id=? AND owner_id=? AND is_system_webhook=?", 0, 0, isSystemWebhook.Value()).
|
||||
Find(&webhooks)
|
||||
}
|
||||
|
||||
// GetDefaultWebhooks returns all admin-default webhooks.
|
||||
func GetDefaultWebhooks(ctx context.Context) ([]*Webhook, error) {
|
||||
webhooks := make([]*Webhook, 0, 5)
|
||||
|
37
models/webhook/webhook_system_test.go
Normal file
37
models/webhook/webhook_system_test.go
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package webhook
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/optional"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetSystemOrDefaultWebhooks(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
hooks, err := GetSystemOrDefaultWebhooks(db.DefaultContext, optional.None[bool]())
|
||||
assert.NoError(t, err)
|
||||
if assert.Len(t, hooks, 2) {
|
||||
assert.Equal(t, int64(5), hooks[0].ID)
|
||||
assert.Equal(t, int64(6), hooks[1].ID)
|
||||
}
|
||||
|
||||
hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(true))
|
||||
assert.NoError(t, err)
|
||||
if assert.Len(t, hooks, 1) {
|
||||
assert.Equal(t, int64(5), hooks[0].ID)
|
||||
}
|
||||
|
||||
hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(false))
|
||||
assert.NoError(t, err)
|
||||
if assert.Len(t, hooks, 1) {
|
||||
assert.Equal(t, int64(6), hooks[0].ID)
|
||||
}
|
||||
}
|
@ -1115,9 +1115,6 @@ blame.ignore_revs=Ignorování revizí v <a href="%s">.git-blame-ignorerevs</a>.
|
||||
blame.ignore_revs.failed=Nepodařilo se ignorovat revize v <a href="%s">.git-blame-ignore-revs</a>.
|
||||
user_search_tooltip=Zobrazí maximálně 30 uživatelů
|
||||
|
||||
tree_path_not_found_commit=Cesta %[1]s v commitu %[2]s neexistuje
|
||||
tree_path_not_found_branch=Cesta %[1]s ve větvi %[2]s neexistuje
|
||||
tree_path_not_found_tag=Cesta %[1]s ve značce %[2]s neexistuje
|
||||
|
||||
transfer.accept=Přijmout převod
|
||||
transfer.accept_desc=Převést do „%s“
|
||||
|
@ -1111,9 +1111,6 @@ blame.ignore_revs=Revisionen in <a href="%s">.git-blame-ignore-revs</a> werden i
|
||||
blame.ignore_revs.failed=Fehler beim Ignorieren der Revisionen in <a href="%s">.git-blame-ignore-revs</a>.
|
||||
user_search_tooltip=Zeigt maximal 30 Benutzer
|
||||
|
||||
tree_path_not_found_commit=Pfad %[1]s existiert nicht in Commit%[2]s
|
||||
tree_path_not_found_branch=Pfad %[1]s existiert nicht in Branch %[2]s
|
||||
tree_path_not_found_tag=Pfad %[1]s existiert nicht in Tag %[2]s
|
||||
|
||||
transfer.accept=Übertragung Akzeptieren
|
||||
transfer.accept_desc=`Übertragung nach "%s"`
|
||||
|
@ -992,9 +992,6 @@ blame_prior=Προβολή ευθύνης πριν από αυτή την αλλ
|
||||
blame.ignore_revs=Αγνόηση των αναθεωρήσεων στο <a href="%s">.git-blame-ignore-revs</a>. Πατήστε <a href="%s">εδώ</a> για να το παρακάμψετε και να δείτε την κανονική προβολή ευθυνών.
|
||||
blame.ignore_revs.failed=Αποτυχία αγνόησης των αναθεωρήσεων στο <a href="%s">.git-blame-ignore-revs</a>.
|
||||
|
||||
tree_path_not_found_commit=Η διαδρομή %[1]s δεν υπάρχει στην υποβολή %[2]s
|
||||
tree_path_not_found_branch=Η διαδρομή %[1]s δεν υπάρχει στον κλάδο %[2]s
|
||||
tree_path_not_found_tag=Η διαδρομή %[1]s δεν υπάρχει στην ετικέτα %[2]s
|
||||
|
||||
transfer.accept=Αποδοχή Μεταφοράς
|
||||
transfer.reject=Απόρριψη Μεταφοράς
|
||||
|
@ -982,9 +982,6 @@ blame_prior=Ver la culpa antes de este cambio
|
||||
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.
|
||||
blame.ignore_revs.failed=No se pudieron ignorar las revisiones en <a href="%s">.git-blame-ignore-revs</a>.
|
||||
|
||||
tree_path_not_found_commit=La ruta %[1]s no existe en el commit %[2]s
|
||||
tree_path_not_found_branch=La ruta %[1]s no existe en la rama %[2]s
|
||||
tree_path_not_found_tag=La ruta %[1]s no existe en la etiqueta %[2]s
|
||||
|
||||
transfer.accept=Aceptar transferencia
|
||||
transfer.reject=Rechazar transferencia
|
||||
|
@ -1115,9 +1115,6 @@ blame.ignore_revs=Les révisions dans <a href="%s">.git-blame-ignore-revs</a> so
|
||||
blame.ignore_revs.failed=Impossible d'ignorer les révisions dans <a href="%s">.git-blame-ignore-revs</a>.
|
||||
user_search_tooltip=Affiche un maximum de 30 utilisateurs
|
||||
|
||||
tree_path_not_found_commit=Le chemin %[1]s n’existe pas dans la révision %[2]s.
|
||||
tree_path_not_found_branch=Le chemin %[1]s n’existe pas dans la branche %[2]s.
|
||||
tree_path_not_found_tag=Le chemin %[1]s n’existe pas dans l’étiquette %[2]s.
|
||||
|
||||
transfer.accept=Accepter le transfert
|
||||
transfer.accept_desc=Transférer à « %s »
|
||||
|
@ -1115,9 +1115,6 @@ blame.ignore_revs=Ag déanamh neamhairde de leasuithe i <a href="%s">.git-blame-
|
||||
blame.ignore_revs.failed=Theip ar neamhaird a dhéanamh ar leasuithe i <a href="%s">.git-blame-ignore-revs</a>.
|
||||
user_search_tooltip=Taispeáint uasmhéid de 30 úsáideoir
|
||||
|
||||
tree_path_not_found_commit=Níl cosán %[1]s ann i dtiomantas %[2]s
|
||||
tree_path_not_found_branch=Níl cosán %[1]s ann i mbrainse %[2]s
|
||||
tree_path_not_found_tag=Níl cosán %[1]s ann i gclib %[2]s
|
||||
|
||||
transfer.accept=Glac le hAistriú
|
||||
transfer.accept_desc=Aistriú chuig “%s”
|
||||
|
@ -1109,9 +1109,6 @@ blame_prior=この変更より前のBlameを表示
|
||||
blame.ignore_revs=<a href="%s">.git-blame-ignore-revs</a> で指定されたリビジョンは除外しています。 これを迂回して通常のBlame表示を見るには <a href="%s">ここ</a>をクリック。
|
||||
blame.ignore_revs.failed=<a href="%s">.git-blame-ignore-revs</a> によるリビジョンの無視は失敗しました。
|
||||
|
||||
tree_path_not_found_commit=パス %[1]s はコミット %[2]s に存在しません
|
||||
tree_path_not_found_branch=パス %[1]s はブランチ %[2]s に存在しません
|
||||
tree_path_not_found_tag=パス %[1]s はタグ %[2]s に存在しません
|
||||
|
||||
transfer.accept=移転を承認
|
||||
transfer.accept_desc=`"%s" に移転`
|
||||
|
@ -997,9 +997,6 @@ blame_prior=Aplūkot vainīgo par izmaiņām pirms šīs revīzijas
|
||||
blame.ignore_revs=Neņem vērā izmaiņas no <a href="%s">.git-blame-ignore-revs</a>. Nospiediet <a href="%s">šeit, lai to apietu</a> un redzētu visu izmaiņu skatu.
|
||||
blame.ignore_revs.failed=Neizdevās neņemt vērā izmaiņas no <a href="%s">.git-blam-ignore-revs</a>.
|
||||
|
||||
tree_path_not_found_commit=Revīzijā %[2]s neeksistē ceļš %[1]s
|
||||
tree_path_not_found_branch=Atzarā %[2]s nepastāv ceļš %[1]s
|
||||
tree_path_not_found_tag=Tagā %[2]s nepastāv ceļš %[1]s
|
||||
|
||||
transfer.accept=Apstiprināt īpašnieka maiņu
|
||||
transfer.reject=Noraidīt īpašnieka maiņu
|
||||
|
@ -1115,9 +1115,6 @@ blame.ignore_revs=Ignorando as revisões em <a href="%s">.git-blame-ignore-revs<
|
||||
blame.ignore_revs.failed=Falhou ao ignorar as revisões em <a href="%s">.git-blame-ignore-revs</a>.
|
||||
user_search_tooltip=Mostra um máximo de 30 utilizadores
|
||||
|
||||
tree_path_not_found_commit=A localização %[1]s não existe no cometimento %[2]s
|
||||
tree_path_not_found_branch=A localização %[1]s não existe no ramo %[2]s
|
||||
tree_path_not_found_tag=A localização %[1]s não existe na etiqueta %[2]s
|
||||
|
||||
transfer.accept=Aceitar transferência
|
||||
transfer.accept_desc=`Transferir para "%s"`
|
||||
|
@ -978,8 +978,6 @@ delete_preexisting_content=Удалить файлы из %s
|
||||
delete_preexisting_success=Удалены непринятые файлы в %s
|
||||
blame_prior=Показать авторство предшествующих изменений
|
||||
|
||||
tree_path_not_found_commit=Путь %[1]s не существует в коммите %[2]s
|
||||
tree_path_not_found_branch=Путь %[1]s не существует в ветке %[2]s
|
||||
|
||||
transfer.accept=Принять трансфер
|
||||
transfer.reject=Отказаться от перемещения
|
||||
|
@ -1083,9 +1083,6 @@ blame_prior=Bu değişiklikten önceki suçu görüntüle
|
||||
blame.ignore_revs=<a href="%s">.git-blame-ignore-revs</a> dosyasındaki sürümler yok sayılıyor. Bunun yerine normal sorumlu görüntüsü için <a href="%s">buraya tıklayın</a>.
|
||||
blame.ignore_revs.failed=<a href="%s">.git-blame-ignore-revs</a> dosyasındaki sürümler yok sayılamadı.
|
||||
|
||||
tree_path_not_found_commit=%[1] yolu, %[2]s işlemesinde mevcut değil
|
||||
tree_path_not_found_branch=%[1] yolu, %[2]s dalında mevcut değil
|
||||
tree_path_not_found_tag=%[1] yolu, %[2]s etiketinde mevcut değil
|
||||
|
||||
transfer.accept=Aktarımı Kabul Et
|
||||
transfer.reject=Aktarımı Reddet
|
||||
|
@ -1111,9 +1111,6 @@ blame.ignore_revs=忽略 <a href="%s">.git-blame-ignore-revs</a> 的修订。点
|
||||
blame.ignore_revs.failed=忽略 <a href="%s">.git-blame-ignore-revs</a> 版本失败。
|
||||
user_search_tooltip=最多显示30名用户
|
||||
|
||||
tree_path_not_found_commit=路径%[1]s 在提交 %[2]s 中不存在
|
||||
tree_path_not_found_branch=路径 %[1]s 不存在于分支 %[2]s 中。
|
||||
tree_path_not_found_tag=路径 %[1]s 不存在于标签 %[2]s 中
|
||||
|
||||
transfer.accept=接受转移
|
||||
transfer.accept_desc=`转移到 "%s"`
|
||||
|
@ -1108,9 +1108,6 @@ blame.ignore_revs=忽略 <a href="%s">.git-blame-ignore-revs</a> 中的修訂。
|
||||
blame.ignore_revs.failed=忽略 <a href="%s">.git-blame-ignore-revs</a> 中的修訂失敗。
|
||||
user_search_tooltip=顯示最多 30 個使用者
|
||||
|
||||
tree_path_not_found_commit=路徑 %[1]s 在提交 %[2]s 中不存在
|
||||
tree_path_not_found_branch=路徑 %[1]s 在分支 %[2]s 中不存在
|
||||
tree_path_not_found_tag=路徑 %[1]s 在標籤 %[2]s 中不存在
|
||||
|
||||
transfer.accept=同意轉移
|
||||
transfer.accept_desc=轉移到「%s」
|
||||
|
55
package-lock.json
generated
55
package-lock.json
generated
@ -67,7 +67,6 @@
|
||||
"devDependencies": {
|
||||
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
|
||||
"@playwright/test": "1.49.1",
|
||||
"@silverwind/vue-tsc": "2.1.13",
|
||||
"@stoplight/spectral-cli": "6.14.2",
|
||||
"@stylistic/eslint-plugin-js": "2.12.1",
|
||||
"@stylistic/stylelint-plugin": "3.1.1",
|
||||
@ -112,7 +111,8 @@
|
||||
"type-fest": "4.30.2",
|
||||
"updates": "16.4.1",
|
||||
"vite-string-plugin": "1.3.4",
|
||||
"vitest": "2.1.8"
|
||||
"vitest": "2.1.8",
|
||||
"vue-tsc": "2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18.0.0"
|
||||
@ -3643,24 +3643,6 @@
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@silverwind/vue-tsc": {
|
||||
"version": "2.1.13",
|
||||
"resolved": "https://registry.npmjs.org/@silverwind/vue-tsc/-/vue-tsc-2.1.13.tgz",
|
||||
"integrity": "sha512-ejFxz1KZiUGAESbC+eURnjqt0N95qkU9eZU7W15wgF9zV+v2FEu3ZLduuXTC7D/Sg6lL1R/QjPfUbxbAbBQOsw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/typescript": "~2.4.11",
|
||||
"@vue/language-core": "2.1.10",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
"bin": {
|
||||
"vue-tsc": "bin/vue-tsc.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@silverwind/vue3-calendar-heatmap": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@silverwind/vue3-calendar-heatmap/-/vue3-calendar-heatmap-2.0.6.tgz",
|
||||
@ -5251,17 +5233,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/language-core": {
|
||||
"version": "2.1.10",
|
||||
"resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-2.1.10.tgz",
|
||||
"integrity": "sha512-DAI289d0K3AB5TUG3xDp9OuQ71CnrujQwJrQnfuZDwo6eGNf0UoRlPuaVNO+Zrn65PC3j0oB2i7mNmVPggeGeQ==",
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-2.2.0.tgz",
|
||||
"integrity": "sha512-O1ZZFaaBGkKbsRfnVH1ifOK1/1BUkyK+3SQsfnh6PmMmD4qJcTU8godCeA96jjDRTL6zgnK7YzCHfaUlH2r0Mw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/language-core": "~2.4.8",
|
||||
"@volar/language-core": "~2.4.11",
|
||||
"@vue/compiler-dom": "^3.5.0",
|
||||
"@vue/compiler-vue2": "^2.7.16",
|
||||
"@vue/shared": "^3.5.0",
|
||||
"alien-signals": "^0.2.0",
|
||||
"alien-signals": "^0.4.9",
|
||||
"minimatch": "^9.0.3",
|
||||
"muggle-string": "^0.4.1",
|
||||
"path-browserify": "^1.0.1"
|
||||
@ -5664,9 +5646,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/alien-signals": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-0.2.2.tgz",
|
||||
"integrity": "sha512-cZIRkbERILsBOXTQmMrxc9hgpxglstn69zm+F1ARf4aPAzdAFYd6sBq87ErO0Fj3DV94tglcyHG5kQz9nDC/8A==",
|
||||
"version": "0.4.14",
|
||||
"resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-0.4.14.tgz",
|
||||
"integrity": "sha512-itUAVzhczTmP2U5yX67xVpsbbOiquusbWVyA9N+sy6+r6YVbFkahXvNCeEPWEOMhwDYwbVbGHFkVL03N9I5g+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
@ -14526,6 +14508,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vue-tsc": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-2.2.0.tgz",
|
||||
"integrity": "sha512-gtmM1sUuJ8aSb0KoAFmK9yMxb8TxjewmxqTJ1aKphD5Cbu0rULFY6+UQT51zW7SpUcenfPUuflKyVwyx9Qdnxg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@volar/typescript": "~2.4.11",
|
||||
"@vue/language-core": "2.2.0"
|
||||
},
|
||||
"bin": {
|
||||
"vue-tsc": "bin/vue-tsc.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/watchpack": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz",
|
||||
|
@ -66,7 +66,6 @@
|
||||
"devDependencies": {
|
||||
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
|
||||
"@playwright/test": "1.49.1",
|
||||
"@silverwind/vue-tsc": "2.1.13",
|
||||
"@stoplight/spectral-cli": "6.14.2",
|
||||
"@stylistic/eslint-plugin-js": "2.12.1",
|
||||
"@stylistic/stylelint-plugin": "3.1.1",
|
||||
@ -111,7 +110,8 @@
|
||||
"type-fest": "4.30.2",
|
||||
"updates": "16.4.1",
|
||||
"vite-string-plugin": "1.3.4",
|
||||
"vitest": "2.1.8"
|
||||
"vitest": "2.1.8",
|
||||
"vue-tsc": "2.2.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"defaults"
|
||||
|
@ -34,11 +34,30 @@ func ListHooks(ctx *context.APIContext) {
|
||||
// in: query
|
||||
// description: page size of results
|
||||
// type: integer
|
||||
// - type: string
|
||||
// enum:
|
||||
// - system
|
||||
// - default
|
||||
// - all
|
||||
// description: system, default or both kinds of webhooks
|
||||
// name: type
|
||||
// default: system
|
||||
// in: query
|
||||
//
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/HookList"
|
||||
|
||||
sysHooks, err := webhook.GetSystemWebhooks(ctx, optional.None[bool]())
|
||||
// for compatibility the default value is true
|
||||
isSystemWebhook := optional.Some(true)
|
||||
typeValue := ctx.FormString("type")
|
||||
if typeValue == "default" {
|
||||
isSystemWebhook = optional.Some(false)
|
||||
} else if typeValue == "all" {
|
||||
isSystemWebhook = optional.None[bool]()
|
||||
}
|
||||
|
||||
sysHooks, err := webhook.GetSystemOrDefaultWebhooks(ctx, isSystemWebhook)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetSystemWebhooks", err)
|
||||
return
|
||||
|
@ -21,7 +21,13 @@ import (
|
||||
|
||||
// RenderFile renders a file by repos path
|
||||
func RenderFile(ctx *context.Context) {
|
||||
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
|
||||
var blob *git.Blob
|
||||
var err error
|
||||
if ctx.Repo.TreePath != "" {
|
||||
blob, err = ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
|
||||
} else {
|
||||
blob, err = ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
|
||||
}
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound("GetBlobByPath", err)
|
||||
|
@ -1530,7 +1530,7 @@ func registerRoutes(m *web.Router) {
|
||||
m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.SingleDownloadOrLFS)
|
||||
m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.SingleDownloadOrLFS)
|
||||
m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.SingleDownloadOrLFS)
|
||||
m.Get("/blob/{sha}", context.RepoRefByType(context.RepoRefBlob), repo.DownloadByIDOrLFS)
|
||||
m.Get("/blob/{sha}", repo.DownloadByIDOrLFS)
|
||||
// "/*" route is deprecated, and kept for backward compatibility
|
||||
m.Get("/*", context.RepoRefByType(context.RepoRefUnknown), repo.SingleDownloadOrLFS)
|
||||
}, repo.MustBeNotEmpty)
|
||||
@ -1539,7 +1539,7 @@ func registerRoutes(m *web.Router) {
|
||||
m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.SingleDownload)
|
||||
m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.SingleDownload)
|
||||
m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.SingleDownload)
|
||||
m.Get("/blob/{sha}", context.RepoRefByType(context.RepoRefBlob), repo.DownloadByID)
|
||||
m.Get("/blob/{sha}", repo.DownloadByID)
|
||||
// "/*" route is deprecated, and kept for backward compatibility
|
||||
m.Get("/*", context.RepoRefByType(context.RepoRefUnknown), repo.SingleDownload)
|
||||
}, repo.MustBeNotEmpty)
|
||||
@ -1548,7 +1548,7 @@ func registerRoutes(m *web.Router) {
|
||||
m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.RenderFile)
|
||||
m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.RenderFile)
|
||||
m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.RenderFile)
|
||||
m.Get("/blob/{sha}", context.RepoRefByType(context.RepoRefBlob), repo.RenderFile)
|
||||
m.Get("/blob/{sha}", repo.RenderFile)
|
||||
}, repo.MustBeNotEmpty)
|
||||
|
||||
m.Group("/commits", func() {
|
||||
|
@ -686,7 +686,6 @@ const (
|
||||
RepoRefBranch
|
||||
RepoRefTag
|
||||
RepoRefCommit
|
||||
RepoRefBlob
|
||||
)
|
||||
|
||||
const headRefName = "HEAD"
|
||||
@ -725,9 +724,6 @@ func getRefNameLegacy(ctx *Base, repo *Repository, reqPath, extraRef string) (st
|
||||
repo.TreePath = strings.Join(reqRefPathParts[1:], "/")
|
||||
return reqRefPathParts[0], RepoRefCommit
|
||||
}
|
||||
if refName := getRefName(ctx, repo, reqPath, RepoRefBlob); refName != "" {
|
||||
return refName, RepoRefBlob
|
||||
}
|
||||
// FIXME: the old code falls back to default branch if "ref" doesn't exist, there could be an edge case:
|
||||
// "README?ref=no-such" would read the README file from the default branch, but the user might expect a 404
|
||||
repo.TreePath = reqPath
|
||||
@ -785,12 +781,6 @@ func getRefName(ctx *Base, repo *Repository, path string, pathType RepoRefType)
|
||||
repo.TreePath = strings.Join(parts[1:], "/")
|
||||
return commit.ID.String()
|
||||
}
|
||||
case RepoRefBlob:
|
||||
_, err := repo.GitRepo.GetBlob(path)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return path
|
||||
default:
|
||||
panic(fmt.Sprintf("Unrecognized path type: %v", pathType))
|
||||
}
|
||||
|
12
templates/swagger/v1_json.tmpl
generated
12
templates/swagger/v1_json.tmpl
generated
@ -234,6 +234,18 @@
|
||||
"description": "page size of results",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"system",
|
||||
"default",
|
||||
"all"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "system",
|
||||
"description": "system, default or both kinds of webhooks",
|
||||
"name": "type",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user