@@ -11,6 +11,7 @@ import (
1111 "code.gitea.io/gitea/models/db"
1212 "code.gitea.io/gitea/models/perm"
1313 "code.gitea.io/gitea/models/unit"
14+ "code.gitea.io/gitea/modules/git"
1415 "code.gitea.io/gitea/modules/log"
1516 "code.gitea.io/gitea/modules/metrics"
1617 "code.gitea.io/gitea/modules/public"
@@ -1156,11 +1157,9 @@ func registerRoutes(m *web.Router) {
11561157
11571158 m .Group ("/{username}/{reponame}" , func () {
11581159 m .Get ("/find/*" , repo .FindFiles )
1159- m .Group ("/tree-list" , func () {
1160- m .Get ("/branch/*" , context .RepoRefByType (context .RepoRefBranch ), repo .TreeList )
1161- m .Get ("/tag/*" , context .RepoRefByType (context .RepoRefTag ), repo .TreeList )
1162- m .Get ("/commit/*" , context .RepoRefByType (context .RepoRefCommit ), repo .TreeList )
1163- })
1160+ m .Get ("/find" , repo .FindFiles )
1161+ m .Get ("/tree-list/*" , context .RepoRefByQueries (), repo .TreeList )
1162+ m .Get ("/tree-list" , context .RepoRefByQueries (), repo .TreeList )
11641163 m .Get ("/compare" , repo .MustBeNotEmpty , repo .SetEditorconfigIfExists , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff )
11651164 m .Combo ("/compare/*" , repo .MustBeNotEmpty , repo .SetEditorconfigIfExists ).
11661165 Get (repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
@@ -1313,9 +1312,9 @@ func registerRoutes(m *web.Router) {
13131312
13141313 m .Group ("/branches" , func () {
13151314 m .Group ("/_new" , func () {
1316- m .Post ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .CreateBranch )
1317- m .Post ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .CreateBranch )
1318- m .Post ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .CreateBranch )
1315+ m .Post ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .CreateBranch )
1316+ m .Post ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .CreateBranch )
1317+ m .Post ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .CreateBranch )
13191318 }, web .Bind (forms.NewBranchForm {}))
13201319 m .Post ("/delete" , repo .DeleteBranchPost )
13211320 m .Post ("/restore" , repo .RestoreBranchPost )
@@ -1334,7 +1333,7 @@ func registerRoutes(m *web.Router) {
13341333 m .Get (".rss" , feedEnabled , repo .TagsListFeedRSS )
13351334 m .Get (".atom" , feedEnabled , repo .TagsListFeedAtom )
13361335 }, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ),
1337- repo .MustBeNotEmpty , context .RepoRefByType (context . RepoRefTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1336+ repo .MustBeNotEmpty , context .RepoRefByType (git . RefTypeTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
13381337 m .Post ("/tags/delete" , repo .DeleteTag , reqSignIn ,
13391338 repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoCodeWriter , context .RepoRef ())
13401339 }, optSignIn , context .RepoAssignment , reqRepoCodeReader )
@@ -1348,7 +1347,7 @@ func registerRoutes(m *web.Router) {
13481347 m .Get (".rss" , feedEnabled , repo .ReleasesFeedRSS )
13491348 m .Get (".atom" , feedEnabled , repo .ReleasesFeedAtom )
13501349 }, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ),
1351- repo .MustBeNotEmpty , context .RepoRefByType (context . RepoRefTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1350+ repo .MustBeNotEmpty , context .RepoRefByType (git . RefTypeTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
13521351 m .Get ("/releases/attachments/{uuid}" , repo .MustBeNotEmpty , repo .GetAttachment )
13531352 m .Get ("/releases/download/{vTag}/{fileName}" , repo .MustBeNotEmpty , repo .RedirectDownload )
13541353 m .Group ("/releases" , func () {
@@ -1521,42 +1520,42 @@ func registerRoutes(m *web.Router) {
15211520 }, repo .MustBeNotEmpty , context .RepoRef ())
15221521
15231522 m .Group ("/media" , func () {
1524- m .Get ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .SingleDownloadOrLFS )
1525- m .Get ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .SingleDownloadOrLFS )
1526- m .Get ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .SingleDownloadOrLFS )
1523+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .SingleDownloadOrLFS )
1524+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .SingleDownloadOrLFS )
1525+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .SingleDownloadOrLFS )
15271526 m .Get ("/blob/{sha}" , repo .DownloadByIDOrLFS )
15281527 // "/*" route is deprecated, and kept for backward compatibility
1529- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .SingleDownloadOrLFS )
1528+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownloadOrLFS )
15301529 }, repo .MustBeNotEmpty )
15311530
15321531 m .Group ("/raw" , func () {
1533- m .Get ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .SingleDownload )
1534- m .Get ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .SingleDownload )
1535- m .Get ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .SingleDownload )
1532+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .SingleDownload )
1533+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .SingleDownload )
1534+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .SingleDownload )
15361535 m .Get ("/blob/{sha}" , repo .DownloadByID )
15371536 // "/*" route is deprecated, and kept for backward compatibility
1538- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .SingleDownload )
1537+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownload )
15391538 }, repo .MustBeNotEmpty )
15401539
15411540 m .Group ("/render" , func () {
1542- m .Get ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .RenderFile )
1543- m .Get ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .RenderFile )
1544- m .Get ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .RenderFile )
1541+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .RenderFile )
1542+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .RenderFile )
1543+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .RenderFile )
15451544 m .Get ("/blob/{sha}" , repo .RenderFile )
15461545 }, repo .MustBeNotEmpty )
15471546
15481547 m .Group ("/commits" , func () {
1549- m .Get ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .RefCommits )
1550- m .Get ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .RefCommits )
1551- m .Get ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .RefCommits )
1548+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .RefCommits )
1549+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .RefCommits )
1550+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .RefCommits )
15521551 // "/*" route is deprecated, and kept for backward compatibility
1553- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .RefCommits )
1552+ m .Get ("/*" , context .RepoRefByType ("" ), repo .RefCommits )
15541553 }, repo .MustBeNotEmpty )
15551554
15561555 m .Group ("/blame" , func () {
1557- m .Get ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .RefBlame )
1558- m .Get ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .RefBlame )
1559- m .Get ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .RefBlame )
1556+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .RefBlame )
1557+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .RefBlame )
1558+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .RefBlame )
15601559 }, repo .MustBeNotEmpty )
15611560
15621561 m .Get ("/blob_excerpt/{sha}" , repo .SetEditorconfigIfExists , repo .SetDiffViewStyle , repo .ExcerptBlob )
@@ -1568,20 +1567,20 @@ func registerRoutes(m *web.Router) {
15681567 m .Get ("/cherry-pick/{sha:([a-f0-9]{7,64})$}" , repo .SetEditorconfigIfExists , repo .CherryPick )
15691568 }, repo .MustBeNotEmpty , context .RepoRef ())
15701569
1571- m .Get ("/rss/branch/*" , context .RepoRefByType (context . RepoRefBranch ), feedEnabled , feed .RenderBranchFeed )
1572- m .Get ("/atom/branch/*" , context .RepoRefByType (context . RepoRefBranch ), feedEnabled , feed .RenderBranchFeed )
1570+ m .Get ("/rss/branch/*" , context .RepoRefByType (git . RefTypeBranch ), feedEnabled , feed .RenderBranchFeed )
1571+ m .Get ("/atom/branch/*" , context .RepoRefByType (git . RefTypeBranch ), feedEnabled , feed .RenderBranchFeed )
15731572
15741573 m .Group ("/src" , func () {
15751574 m .Get ("" , func (ctx * context.Context ) { ctx .Redirect (ctx .Repo .RepoLink ) }) // there is no "{owner}/{repo}/src" page, so redirect to "{owner}/{repo}" to avoid 404
1576- m .Get ("/branch/*" , context .RepoRefByType (context . RepoRefBranch ), repo .Home )
1577- m .Get ("/tag/*" , context .RepoRefByType (context . RepoRefTag ), repo .Home )
1578- m .Get ("/commit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .Home )
1579- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .Home ) // "/*" route is deprecated, and kept for backward compatibility
1575+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .Home )
1576+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .Home )
1577+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .Home )
1578+ m .Get ("/*" , context .RepoRefByType ("" ), repo .Home ) // "/*" route is deprecated, and kept for backward compatibility
15801579 }, repo .SetEditorconfigIfExists )
15811580
15821581 m .Get ("/forks" , context .RepoRef (), repo .Forks )
15831582 m .Get ("/commit/{sha:([a-f0-9]{7,64})}.{ext:patch|diff}" , repo .MustBeNotEmpty , repo .RawDiff )
1584- m .Post ("/lastcommit/*" , context .RepoRefByType (context . RepoRefCommit ), repo .LastCommit )
1583+ m .Post ("/lastcommit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .LastCommit )
15851584 }, optSignIn , context .RepoAssignment , reqRepoCodeReader )
15861585 // end "/{username}/{reponame}": repo code
15871586
0 commit comments