Skip to content

Commit 2ec5dc1

Browse files
ethantkoenigappleboy
authored andcommitted
Fix 404 for external tracking issues (#1852)
* Fix 404 for external tracking issues * Fix 404 for new/upload file
1 parent b900c04 commit 2ec5dc1

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

routers/repo/issue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ func DeleteComment(ctx *context.Context) {
965965

966966
// Milestones render milestones page
967967
func Milestones(ctx *context.Context) {
968+
MustEnableIssues(ctx)
969+
if ctx.Written() {
970+
return
971+
}
968972
ctx.Data["Title"] = ctx.Tr("repo.milestones")
969973
ctx.Data["PageIsIssueList"] = true
970974
ctx.Data["PageIsMilestones"] = true

routers/repo/issue_label.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const (
1818

1919
// Labels render issue's labels page
2020
func Labels(ctx *context.Context) {
21+
MustEnableIssues(ctx)
22+
if ctx.Written() {
23+
return
24+
}
2125
ctx.Data["Title"] = ctx.Tr("repo.labels")
2226
ctx.Data["PageIsIssueList"] = true
2327
ctx.Data["PageIsLabels"] = true

routers/routes/routes.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,25 +473,26 @@ func RegisterRoutes(m *macaron.Macaron) {
473473
m.Post("/milestone", repo.UpdateIssueMilestone, reqRepoWriter)
474474
m.Post("/assignee", repo.UpdateIssueAssignee, reqRepoWriter)
475475
m.Post("/status", repo.UpdateIssueStatus, reqRepoWriter)
476-
})
476+
}, context.CheckUnit(models.UnitTypeIssues))
477477
m.Group("/comments/:id", func() {
478478
m.Post("", repo.UpdateCommentContent)
479479
m.Post("/delete", repo.DeleteComment)
480-
})
480+
}, context.CheckUnit(models.UnitTypeIssues))
481481
m.Group("/labels", func() {
482482
m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
483483
m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
484484
m.Post("/delete", repo.DeleteLabel)
485485
m.Post("/initialize", bindIgnErr(auth.InitializeLabelsForm{}), repo.InitializeLabels)
486-
}, reqRepoWriter, context.RepoRef())
486+
}, reqRepoWriter, context.RepoRef(), context.CheckUnit(models.UnitTypeIssues))
487487
m.Group("/milestones", func() {
488488
m.Combo("/new").Get(repo.NewMilestone).
489489
Post(bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
490490
m.Get("/:id/edit", repo.EditMilestone)
491491
m.Post("/:id/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.EditMilestonePost)
492492
m.Get("/:id/:action", repo.ChangeMilestonStatus)
493493
m.Post("/delete", repo.DeleteMilestone)
494-
}, reqRepoWriter, context.RepoRef())
494+
}, reqRepoWriter, context.RepoRef(), context.CheckUnit(models.UnitTypeIssues))
495+
495496

496497
m.Combo("/compare/*", repo.MustAllowPulls, repo.SetEditorconfigIfExists).
497498
Get(repo.CompareAndPullRequest).
@@ -523,7 +524,7 @@ func RegisterRoutes(m *macaron.Macaron) {
523524
return
524525
}
525526
})
526-
}, reqSignIn, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits(), context.CheckUnit(models.UnitTypeIssues))
527+
}, reqSignIn, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits())
527528

528529
// Releases
529530
m.Group("/:username/:reponame", func() {
@@ -558,7 +559,7 @@ func RegisterRoutes(m *macaron.Macaron) {
558559
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
559560
m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
560561
m.Get("/milestones", repo.Milestones)
561-
}, context.RepoRef(), context.CheckUnit(models.UnitTypeIssues))
562+
}, context.RepoRef())
562563

563564
// m.Get("/branches", repo.Branches)
564565
m.Post("/branches/:name/delete", reqSignIn, reqRepoWriter, repo.MustBeNotBare, repo.DeleteBranchPost)

0 commit comments

Comments
 (0)