@@ -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,8 @@ 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" , repo .TreeList )
1164
1162
m .Get ("/compare" , repo .MustBeNotEmpty , repo .SetEditorconfigIfExists , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff )
1165
1163
m .Combo ("/compare/*" , repo .MustBeNotEmpty , repo .SetEditorconfigIfExists ).
1166
1164
Get (repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
@@ -1313,9 +1311,9 @@ func registerRoutes(m *web.Router) {
1313
1311
1314
1312
m .Group ("/branches" , func () {
1315
1313
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 )
1314
+ m .Post ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .CreateBranch )
1315
+ m .Post ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .CreateBranch )
1316
+ m .Post ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .CreateBranch )
1319
1317
}, web .Bind (forms.NewBranchForm {}))
1320
1318
m .Post ("/delete" , repo .DeleteBranchPost )
1321
1319
m .Post ("/restore" , repo .RestoreBranchPost )
@@ -1334,7 +1332,7 @@ func registerRoutes(m *web.Router) {
1334
1332
m .Get (".rss" , feedEnabled , repo .TagsListFeedRSS )
1335
1333
m .Get (".atom" , feedEnabled , repo .TagsListFeedAtom )
1336
1334
}, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ),
1337
- repo .MustBeNotEmpty , context .RepoRefByType (context . RepoRefTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1335
+ repo .MustBeNotEmpty , context .RepoRefByType (git . RefTypeTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1338
1336
m .Post ("/tags/delete" , repo .DeleteTag , reqSignIn ,
1339
1337
repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoCodeWriter , context .RepoRef ())
1340
1338
}, optSignIn , context .RepoAssignment , reqRepoCodeReader )
@@ -1348,7 +1346,7 @@ func registerRoutes(m *web.Router) {
1348
1346
m .Get (".rss" , feedEnabled , repo .ReleasesFeedRSS )
1349
1347
m .Get (".atom" , feedEnabled , repo .ReleasesFeedAtom )
1350
1348
}, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ),
1351
- repo .MustBeNotEmpty , context .RepoRefByType (context . RepoRefTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1349
+ repo .MustBeNotEmpty , context .RepoRefByType (git . RefTypeTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1352
1350
m .Get ("/releases/attachments/{uuid}" , repo .MustBeNotEmpty , repo .GetAttachment )
1353
1351
m .Get ("/releases/download/{vTag}/{fileName}" , repo .MustBeNotEmpty , repo .RedirectDownload )
1354
1352
m .Group ("/releases" , func () {
@@ -1521,42 +1519,42 @@ func registerRoutes(m *web.Router) {
1521
1519
}, repo .MustBeNotEmpty , context .RepoRef ())
1522
1520
1523
1521
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 )
1522
+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .SingleDownloadOrLFS )
1523
+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .SingleDownloadOrLFS )
1524
+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .SingleDownloadOrLFS )
1527
1525
m .Get ("/blob/{sha}" , repo .DownloadByIDOrLFS )
1528
1526
// "/*" route is deprecated, and kept for backward compatibility
1529
- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .SingleDownloadOrLFS )
1527
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownloadOrLFS )
1530
1528
}, repo .MustBeNotEmpty )
1531
1529
1532
1530
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 )
1531
+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .SingleDownload )
1532
+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .SingleDownload )
1533
+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .SingleDownload )
1536
1534
m .Get ("/blob/{sha}" , repo .DownloadByID )
1537
1535
// "/*" route is deprecated, and kept for backward compatibility
1538
- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .SingleDownload )
1536
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownload )
1539
1537
}, repo .MustBeNotEmpty )
1540
1538
1541
1539
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 )
1540
+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .RenderFile )
1541
+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .RenderFile )
1542
+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .RenderFile )
1545
1543
m .Get ("/blob/{sha}" , repo .RenderFile )
1546
1544
}, repo .MustBeNotEmpty )
1547
1545
1548
1546
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 )
1547
+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .RefCommits )
1548
+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .RefCommits )
1549
+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .RefCommits )
1552
1550
// "/*" route is deprecated, and kept for backward compatibility
1553
- m .Get ("/*" , context .RepoRefByType (context . RepoRefUnknown ), repo .RefCommits )
1551
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .RefCommits )
1554
1552
}, repo .MustBeNotEmpty )
1555
1553
1556
1554
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 )
1555
+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .RefBlame )
1556
+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .RefBlame )
1557
+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .RefBlame )
1560
1558
}, repo .MustBeNotEmpty )
1561
1559
1562
1560
m .Get ("/blob_excerpt/{sha}" , repo .SetEditorconfigIfExists , repo .SetDiffViewStyle , repo .ExcerptBlob )
@@ -1568,20 +1566,20 @@ func registerRoutes(m *web.Router) {
1568
1566
m .Get ("/cherry-pick/{sha:([a-f0-9]{7,64})$}" , repo .SetEditorconfigIfExists , repo .CherryPick )
1569
1567
}, repo .MustBeNotEmpty , context .RepoRef ())
1570
1568
1571
- m .Get ("/rss/branch/*" , context .RepoRefByType (context . RepoRefBranch ), feedEnabled , feed .RenderBranchFeed )
1572
- m .Get ("/atom/branch/*" , context .RepoRefByType (context . RepoRefBranch ), feedEnabled , feed .RenderBranchFeed )
1569
+ m .Get ("/rss/branch/*" , context .RepoRefByType (git . RefTypeBranch ), feedEnabled , feed .RenderBranchFeed )
1570
+ m .Get ("/atom/branch/*" , context .RepoRefByType (git . RefTypeBranch ), feedEnabled , feed .RenderBranchFeed )
1573
1571
1574
1572
m .Group ("/src" , func () {
1575
1573
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
1574
+ m .Get ("/branch/*" , context .RepoRefByType (git . RefTypeBranch ), repo .Home )
1575
+ m .Get ("/tag/*" , context .RepoRefByType (git . RefTypeTag ), repo .Home )
1576
+ m .Get ("/commit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .Home )
1577
+ m .Get ("/*" , context .RepoRefByType ("" ), repo .Home ) // "/*" route is deprecated, and kept for backward compatibility
1580
1578
}, repo .SetEditorconfigIfExists )
1581
1579
1582
1580
m .Get ("/forks" , context .RepoRef (), repo .Forks )
1583
1581
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 )
1582
+ m .Post ("/lastcommit/*" , context .RepoRefByType (git . RefTypeCommit ), repo .LastCommit )
1585
1583
}, optSignIn , context .RepoAssignment , reqRepoCodeReader )
1586
1584
// end "/{username}/{reponame}": repo code
1587
1585
0 commit comments