@@ -1153,7 +1153,7 @@ func registerRoutes(m *web.Router) {
11531153 // end "/{username}/{reponame}/settings"
11541154
11551155 // user/org home, including rss feeds
1156- m .Get ("/{username}/{reponame}" , optSignIn , context .RepoAssignment , context .RepoRef ( ), repo .SetEditorconfigIfExists , repo .Home )
1156+ m .Get ("/{username}/{reponame}" , optSignIn , context .RepoAssignment , context .RepoRefByType ( git . RefTypeBranch ), repo .SetEditorconfigIfExists , repo .Home )
11571157
11581158 m .Post ("/{username}/{reponame}/markup" , optSignIn , context .RepoAssignment , reqUnitsWithMarkdown , web .Bind (structs.MarkupOption {}), misc .Markup )
11591159
@@ -1293,26 +1293,31 @@ func registerRoutes(m *web.Router) {
12931293 m .Group ("/{username}/{reponame}" , func () { // repo code
12941294 m .Group ("" , func () {
12951295 m .Group ("" , func () {
1296- m .Combo ("/_edit/*" ).Get (repo .EditFile ).
1296+ m .Combo ("/_edit/*" , context .RepoRefByType (git .RefTypeBranch )).
1297+ Get (repo .EditFile ).
12971298 Post (web .Bind (forms.EditRepoFileForm {}), repo .EditFilePost )
1298- m .Combo ("/_new/*" ).Get (repo .NewFile ).
1299+ m .Combo ("/_new/*" , context .RepoRefByType (git .RefTypeBranch )).
1300+ Get (repo .NewFile ).
12991301 Post (web .Bind (forms.EditRepoFileForm {}), repo .NewFilePost )
1300- m .Post ("/_preview/*" , web .Bind (forms.EditPreviewDiffForm {}), repo .DiffPreviewPost )
1301- m .Combo ("/_delete/*" ).Get (repo .DeleteFile ).
1302+ m .Post ("/_preview/*" , context .RepoRefByType (git .RefTypeBranch ), web .Bind (forms.EditPreviewDiffForm {}), repo .DiffPreviewPost )
1303+ m .Combo ("/_delete/*" , context .RepoRefByType (git .RefTypeBranch )).
1304+ Get (repo .DeleteFile ).
13021305 Post (web .Bind (forms.DeleteRepoFileForm {}), repo .DeleteFilePost )
1303- m .Combo ("/_upload/*" , repo .MustBeAbleToUpload ).
1306+ m .Combo ("/_upload/*" , context . RepoRefByType ( git . RefTypeBranch ), repo .MustBeAbleToUpload ).
13041307 Get (repo .UploadFile ).
13051308 Post (web .Bind (forms.UploadRepoFileForm {}), repo .UploadFilePost )
1306- m .Combo ("/_diffpatch/*" ).Get (repo .NewDiffPatch ).
1309+ m .Combo ("/_diffpatch/*" , context .RepoRefByType (git .RefTypeBranch )).
1310+ Get (repo .NewDiffPatch ).
13071311 Post (web .Bind (forms.EditRepoFileForm {}), repo .NewDiffPatchPost )
1308- m .Combo ("/_cherrypick/{sha:([a-f0-9]{7,64})}/*" ).Get (repo .CherryPick ).
1312+ m .Combo ("/_cherrypick/{sha:([a-f0-9]{7,64})}/*" , context .RepoRefByType (git .RefTypeBranch )).
1313+ Get (repo .CherryPick ).
13091314 Post (web .Bind (forms.CherryPickForm {}), repo .CherryPickPost )
13101315 }, repo .MustBeEditable )
13111316 m .Group ("" , func () {
13121317 m .Post ("/upload-file" , repo .UploadFileToServer )
13131318 m .Post ("/upload-remove" , web .Bind (forms.RemoveUploadFileForm {}), repo .RemoveUploadFileFromServer )
13141319 }, repo .MustBeEditable , repo .MustBeAbleToUpload )
1315- }, context . RepoRef (), canEnableEditor , context .RepoMustNotBeArchived ())
1320+ }, canEnableEditor , context .RepoMustNotBeArchived ())
13161321
13171322 m .Group ("/branches" , func () {
13181323 m .Group ("/_new" , func () {
@@ -1333,39 +1338,36 @@ func registerRoutes(m *web.Router) {
13331338 m .Group ("/{username}/{reponame}" , func () { // repo tags
13341339 m .Group ("/tags" , func () {
13351340 m .Get ("" , repo .TagsList )
1336- m .Get ("/list" , repo .GetTagList )
13371341 m .Get (".rss" , feedEnabled , repo .TagsListFeedRSS )
13381342 m .Get (".atom" , feedEnabled , repo .TagsListFeedAtom )
1339- }, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ),
1340- repo .MustBeNotEmpty , context .RepoRefByType (git .RefTypeTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1341- m .Post ("/tags/delete" , repo .DeleteTag , reqSignIn ,
1342- repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoCodeWriter , context .RepoRef ())
1343- }, optSignIn , context .RepoAssignment , reqUnitCodeReader )
1343+ m .Get ("/list" , repo .GetTagList )
1344+ }, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ))
1345+ m .Post ("/tags/delete" , reqSignIn , reqRepoCodeWriter , context .RepoMustNotBeArchived (), repo .DeleteTag )
1346+ }, optSignIn , context .RepoAssignment , repo .MustBeNotEmpty , reqUnitCodeReader )
13441347 // end "/{username}/{reponame}": repo tags
13451348
13461349 m .Group ("/{username}/{reponame}" , func () { // repo releases
13471350 m .Group ("/releases" , func () {
13481351 m .Get ("" , repo .Releases )
1349- m .Get ("/tag/*" , repo .SingleRelease )
1350- m .Get ("/latest" , repo .LatestRelease )
13511352 m .Get (".rss" , feedEnabled , repo .ReleasesFeedRSS )
13521353 m .Get (".atom" , feedEnabled , repo .ReleasesFeedAtom )
1353- }, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ),
1354- repo .MustBeNotEmpty , context .RepoRefByType (git .RefTypeTag , context.RepoRefByTypeOptions {IgnoreNotExistErr : true }))
1355- m .Get ("/releases/attachments/{uuid}" , repo .MustBeNotEmpty , repo .GetAttachment )
1356- m .Get ("/releases/download/{vTag}/{fileName}" , repo .MustBeNotEmpty , repo .RedirectDownload )
1354+ m .Get ("/tag/*" , context .RepoRefByType (git .RefTypeTag ), repo .SingleRelease )
1355+ m .Get ("/latest" , repo .LatestRelease )
1356+ }, ctxDataSet ("EnableFeed" , setting .Other .EnableFeed ))
1357+ m .Get ("/releases/attachments/{uuid}" , repo .GetAttachment )
1358+ m .Get ("/releases/download/{vTag}/{fileName}" , repo .RedirectDownload )
13571359 m .Group ("/releases" , func () {
13581360 m .Get ("/new" , repo .NewRelease )
13591361 m .Post ("/new" , web .Bind (forms.NewReleaseForm {}), repo .NewReleasePost )
13601362 m .Post ("/delete" , repo .DeleteRelease )
13611363 m .Post ("/attachments" , repo .UploadReleaseAttachment )
13621364 m .Post ("/attachments/remove" , repo .DeleteAttachment )
1363- }, reqSignIn , repo . MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoReleaseWriter , context .RepoRef ())
1365+ }, reqSignIn , context .RepoMustNotBeArchived (), reqRepoReleaseWriter , context .RepoRef ())
13641366 m .Group ("/releases" , func () {
13651367 m .Get ("/edit/*" , repo .EditRelease )
13661368 m .Post ("/edit/*" , web .Bind (forms.EditReleaseForm {}), repo .EditReleasePost )
1367- }, reqSignIn , repo . MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoReleaseWriter , repo .CommitInfoCache )
1368- }, optSignIn , context .RepoAssignment , reqRepoReleaseReader )
1369+ }, reqSignIn , context .RepoMustNotBeArchived (), reqRepoReleaseWriter , repo .CommitInfoCache )
1370+ }, optSignIn , context .RepoAssignment , repo . MustBeNotEmpty , reqRepoReleaseReader )
13691371 // end "/{username}/{reponame}": repo releases
13701372
13711373 m .Group ("/{username}/{reponame}" , func () { // to maintain compatibility with old attachments
@@ -1529,21 +1531,19 @@ func registerRoutes(m *web.Router) {
15291531 }, repo .MustBeNotEmpty , context .RepoRef ())
15301532
15311533 m .Group ("/media" , func () {
1534+ m .Get ("/blob/{sha}" , repo .DownloadByIDOrLFS )
15321535 m .Get ("/branch/*" , context .RepoRefByType (git .RefTypeBranch ), repo .SingleDownloadOrLFS )
15331536 m .Get ("/tag/*" , context .RepoRefByType (git .RefTypeTag ), repo .SingleDownloadOrLFS )
15341537 m .Get ("/commit/*" , context .RepoRefByType (git .RefTypeCommit ), repo .SingleDownloadOrLFS )
1535- m .Get ("/blob/{sha}" , repo .DownloadByIDOrLFS )
1536- // "/*" route is deprecated, and kept for backward compatibility
1537- m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownloadOrLFS )
1538+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownloadOrLFS ) // "/*" route is deprecated, and kept for backward compatibility
15381539 }, repo .MustBeNotEmpty )
15391540
15401541 m .Group ("/raw" , func () {
1542+ m .Get ("/blob/{sha}" , repo .DownloadByID )
15411543 m .Get ("/branch/*" , context .RepoRefByType (git .RefTypeBranch ), repo .SingleDownload )
15421544 m .Get ("/tag/*" , context .RepoRefByType (git .RefTypeTag ), repo .SingleDownload )
15431545 m .Get ("/commit/*" , context .RepoRefByType (git .RefTypeCommit ), repo .SingleDownload )
1544- m .Get ("/blob/{sha}" , repo .DownloadByID )
1545- // "/*" route is deprecated, and kept for backward compatibility
1546- m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownload )
1546+ m .Get ("/*" , context .RepoRefByType ("" ), repo .SingleDownload ) // "/*" route is deprecated, and kept for backward compatibility
15471547 }, repo .MustBeNotEmpty )
15481548
15491549 m .Group ("/render" , func () {
@@ -1557,8 +1557,7 @@ func registerRoutes(m *web.Router) {
15571557 m .Get ("/branch/*" , context .RepoRefByType (git .RefTypeBranch ), repo .RefCommits )
15581558 m .Get ("/tag/*" , context .RepoRefByType (git .RefTypeTag ), repo .RefCommits )
15591559 m .Get ("/commit/*" , context .RepoRefByType (git .RefTypeCommit ), repo .RefCommits )
1560- // "/*" route is deprecated, and kept for backward compatibility
1561- m .Get ("/*" , context .RepoRefByType ("" ), repo .RefCommits )
1560+ m .Get ("/*" , context .RepoRefByType ("" ), repo .RefCommits ) // "/*" route is deprecated, and kept for backward compatibility
15621561 }, repo .MustBeNotEmpty )
15631562
15641563 m .Group ("/blame" , func () {
0 commit comments