@@ -11,6 +11,7 @@ import (
11
11
"code.gitea.io/gitea/models/db"
12
12
"code.gitea.io/gitea/models/perm"
13
13
"code.gitea.io/gitea/models/unit"
14
+ "code.gitea.io/gitea/modules/git"
14
15
"code.gitea.io/gitea/modules/log"
15
16
"code.gitea.io/gitea/modules/metrics"
16
17
"code.gitea.io/gitea/modules/public"
@@ -1156,11 +1157,9 @@ func registerRoutes(m *web.Router) {
1156
1157
1157
1158
m .Group ("/{username}/{reponame}" , func () {
1158
1159
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 )
1164
1163
m .Get ("/compare" , repo .MustBeNotEmpty , repo .SetEditorconfigIfExists , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff )
1165
1164
m .Combo ("/compare/*" , repo .MustBeNotEmpty , repo .SetEditorconfigIfExists ).
1166
1165
Get (repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
@@ -1313,9 +1312,9 @@ func registerRoutes(m *web.Router) {
1313
1312
1314
1313
m .Group ("/branches" , func () {
1315
1314
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 )
1319
1318
}, web .Bind (forms.NewBranchForm {}))
1320
1319
m .Post ("/delete" , repo .DeleteBranchPost )
1321
1320
m .Post ("/restore" , repo .RestoreBranchPost )
@@ -1334,7 +1333,7 @@ func registerRoutes(m *web.Router) {
1334
1333
m .Get (".rss" , feedEnabled , repo .TagsListFeedRSS )
1335
1334
m .Get (".atom" , feedEnabled , repo .TagsListFeedAtom )
1336
1335
}, 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 }))
1338
1337
m .Post ("/tags/delete" , repo .DeleteTag , reqSignIn ,
1339
1338
repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoCodeWriter , context .RepoRef ())
1340
1339
}, optSignIn , context .RepoAssignment , reqRepoCodeReader )
@@ -1348,7 +1347,7 @@ func registerRoutes(m *web.Router) {
1348
1347
m .Get (".rss" , feedEnabled , repo .ReleasesFeedRSS )
1349
1348
m .Get (".atom" , feedEnabled , repo .ReleasesFeedAtom )
1350
1349
}, 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 }))
1352
1351
m .Get ("/releases/attachments/{uuid}" , repo .MustBeNotEmpty , repo .GetAttachment )
1353
1352
m .Get ("/releases/download/{vTag}/{fileName}" , repo .MustBeNotEmpty , repo .RedirectDownload )
1354
1353
m .Group ("/releases" , func () {
@@ -1521,42 +1520,42 @@ func registerRoutes(m *web.Router) {
1521
1520
}, repo .MustBeNotEmpty , context .RepoRef ())
1522
1521
1523
1522
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 )
1527
1526
m .Get ("/blob/{sha}" , repo .DownloadByIDOrLFS )
1528
1527
// "/*" route is deprecated, and kept for backward compatibility
1529
- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .SingleDownloadOrLFS )
1528
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownloadOrLFS )
1530
1529
}, repo .MustBeNotEmpty )
1531
1530
1532
1531
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 )
1536
1535
m .Get ("/blob/{sha}" , repo .DownloadByID )
1537
1536
// "/*" route is deprecated, and kept for backward compatibility
1538
- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .SingleDownload )
1537
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownload )
1539
1538
}, repo .MustBeNotEmpty )
1540
1539
1541
1540
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 )
1545
1544
m .Get ("/blob/{sha}" , repo .RenderFile )
1546
1545
}, repo .MustBeNotEmpty )
1547
1546
1548
1547
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 )
1552
1551
// "/*" route is deprecated, and kept for backward compatibility
1553
- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .RefCommits )
1552
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .RefCommits )
1554
1553
}, repo .MustBeNotEmpty )
1555
1554
1556
1555
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 )
1560
1559
}, repo .MustBeNotEmpty )
1561
1560
1562
1561
m .Get ("/blob_excerpt/{sha}" , repo .SetEditorconfigIfExists , repo .SetDiffViewStyle , repo .ExcerptBlob )
@@ -1568,20 +1567,20 @@ func registerRoutes(m *web.Router) {
1568
1567
m .Get ("/cherry-pick/{sha:([a-f0-9]{7,64})$}" , repo .SetEditorconfigIfExists , repo .CherryPick )
1569
1568
}, repo .MustBeNotEmpty , context .RepoRef ())
1570
1569
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 )
1573
1572
1574
1573
m .Group ("/src" , func () {
1575
1574
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
1580
1579
}, repo .SetEditorconfigIfExists )
1581
1580
1582
1581
m .Get ("/forks" , context .RepoRef (), repo .Forks )
1583
1582
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 )
1585
1584
}, optSignIn , context .RepoAssignment , reqRepoCodeReader )
1586
1585
// end "/{username}/{reponame}": repo code
1587
1586
0 commit comments