|
|
@ -101,7 +101,7 @@ func buildAuthGroup() *auth_service.Group { |
|
|
|
group.Add(&auth_service.Basic{}) // FIXME: this should be removed and only applied in download and git/lfs routers
|
|
|
|
group.Add(&auth_service.Basic{}) // FIXME: this should be removed and only applied in download and git/lfs routers
|
|
|
|
|
|
|
|
|
|
|
|
if setting.Service.EnableReverseProxyAuth { |
|
|
|
if setting.Service.EnableReverseProxyAuth { |
|
|
|
group.Add(&auth_service.ReverseProxy{}) // reverseproxy should before Session, otherwise the header will be ignored if user has login
|
|
|
|
group.Add(&auth_service.ReverseProxy{}) // reverse-proxy should before Session, otherwise the header will be ignored if user has login
|
|
|
|
} |
|
|
|
} |
|
|
|
group.Add(&auth_service.Session{}) |
|
|
|
group.Add(&auth_service.Session{}) |
|
|
|
|
|
|
|
|
|
|
@ -816,21 +816,24 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Post("/{username}", reqSignIn, context.UserAssignmentWeb(), user.Action) |
|
|
|
m.Post("/{username}", reqSignIn, context.UserAssignmentWeb(), user.Action) |
|
|
|
|
|
|
|
|
|
|
|
reqRepoAdmin := context.RequireRepoAdmin() |
|
|
|
reqRepoAdmin := context.RequireRepoAdmin() |
|
|
|
reqRepoCodeWriter := context.RequireRepoWriter(unit.TypeCode) |
|
|
|
reqRepoCodeWriter := context.RequireUnitWriter(unit.TypeCode) |
|
|
|
canEnableEditor := context.CanEnableEditor() |
|
|
|
canEnableEditor := context.CanEnableEditor() |
|
|
|
reqRepoCodeReader := context.RequireRepoReader(unit.TypeCode) |
|
|
|
reqRepoReleaseWriter := context.RequireUnitWriter(unit.TypeReleases) |
|
|
|
reqRepoReleaseWriter := context.RequireRepoWriter(unit.TypeReleases) |
|
|
|
reqRepoReleaseReader := context.RequireUnitReader(unit.TypeReleases) |
|
|
|
reqRepoReleaseReader := context.RequireRepoReader(unit.TypeReleases) |
|
|
|
reqRepoIssuesOrPullsWriter := context.RequireUnitWriter(unit.TypeIssues, unit.TypePullRequests) |
|
|
|
reqRepoWikiReader := context.RequireRepoReader(unit.TypeWiki) |
|
|
|
reqRepoIssuesOrPullsReader := context.RequireUnitReader(unit.TypeIssues, unit.TypePullRequests) |
|
|
|
reqRepoWikiWriter := context.RequireRepoWriter(unit.TypeWiki) |
|
|
|
reqRepoProjectsReader := context.RequireUnitReader(unit.TypeProjects) |
|
|
|
reqRepoIssueReader := context.RequireRepoReader(unit.TypeIssues) |
|
|
|
reqRepoProjectsWriter := context.RequireUnitWriter(unit.TypeProjects) |
|
|
|
reqRepoPullsReader := context.RequireRepoReader(unit.TypePullRequests) |
|
|
|
reqRepoActionsReader := context.RequireUnitReader(unit.TypeActions) |
|
|
|
reqRepoIssuesOrPullsWriter := context.RequireRepoWriterOr(unit.TypeIssues, unit.TypePullRequests) |
|
|
|
reqRepoActionsWriter := context.RequireUnitWriter(unit.TypeActions) |
|
|
|
reqRepoIssuesOrPullsReader := context.RequireRepoReaderOr(unit.TypeIssues, unit.TypePullRequests) |
|
|
|
|
|
|
|
reqRepoProjectsReader := context.RequireRepoReader(unit.TypeProjects) |
|
|
|
// the legacy names "reqRepoXxx" should be renamed to the correct name "reqUnitXxx", these permissions are for units, not repos
|
|
|
|
reqRepoProjectsWriter := context.RequireRepoWriter(unit.TypeProjects) |
|
|
|
reqUnitsWithMarkdown := context.RequireUnitReader(unit.TypeCode, unit.TypeIssues, unit.TypePullRequests, unit.TypeReleases, unit.TypeWiki) |
|
|
|
reqRepoActionsReader := context.RequireRepoReader(unit.TypeActions) |
|
|
|
reqUnitCodeReader := context.RequireUnitReader(unit.TypeCode) |
|
|
|
reqRepoActionsWriter := context.RequireRepoWriter(unit.TypeActions) |
|
|
|
reqUnitIssuesReader := context.RequireUnitReader(unit.TypeIssues) |
|
|
|
|
|
|
|
reqUnitPullsReader := context.RequireUnitReader(unit.TypePullRequests) |
|
|
|
|
|
|
|
reqUnitWikiReader := context.RequireUnitReader(unit.TypeWiki) |
|
|
|
|
|
|
|
reqUnitWikiWriter := context.RequireUnitWriter(unit.TypeWiki) |
|
|
|
|
|
|
|
|
|
|
|
reqPackageAccess := func(accessMode perm.AccessMode) func(ctx *context.Context) { |
|
|
|
reqPackageAccess := func(accessMode perm.AccessMode) func(ctx *context.Context) { |
|
|
|
return func(ctx *context.Context) { |
|
|
|
return func(ctx *context.Context) { |
|
|
@ -1053,7 +1056,7 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Group("/migrate", func() { |
|
|
|
m.Group("/migrate", func() { |
|
|
|
m.Get("/status", repo.MigrateStatus) |
|
|
|
m.Get("/status", repo.MigrateStatus) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, optSignIn, context.RepoAssignment, reqRepoCodeReader) |
|
|
|
}, optSignIn, context.RepoAssignment, reqUnitCodeReader) |
|
|
|
// end "/{username}/{reponame}/-": migrate
|
|
|
|
// end "/{username}/{reponame}/-": migrate
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}/settings", func() { |
|
|
|
m.Group("/{username}/{reponame}/settings", func() { |
|
|
@ -1151,8 +1154,7 @@ func registerRoutes(m *web.Router) { |
|
|
|
// user/org home, including rss feeds
|
|
|
|
// user/org home, including rss feeds
|
|
|
|
m.Get("/{username}/{reponame}", optSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.Home) |
|
|
|
m.Get("/{username}/{reponame}", optSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.Home) |
|
|
|
|
|
|
|
|
|
|
|
// TODO: maybe it should relax the permission to allow "any access"
|
|
|
|
m.Post("/{username}/{reponame}/markup", optSignIn, context.RepoAssignment, reqUnitsWithMarkdown, web.Bind(structs.MarkupOption{}), misc.Markup) |
|
|
|
m.Post("/{username}/{reponame}/markup", optSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypeCode, unit.TypeIssues, unit.TypePullRequests, unit.TypeReleases, unit.TypeWiki), web.Bind(structs.MarkupOption{}), misc.Markup) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Get("/find/*", repo.FindFiles) |
|
|
|
m.Get("/find/*", repo.FindFiles) |
|
|
@ -1164,41 +1166,40 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Get("/compare", repo.MustBeNotEmpty, repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff) |
|
|
|
m.Get("/compare", repo.MustBeNotEmpty, repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff) |
|
|
|
m.Combo("/compare/*", repo.MustBeNotEmpty, repo.SetEditorconfigIfExists). |
|
|
|
m.Combo("/compare/*", repo.MustBeNotEmpty, repo.SetEditorconfigIfExists). |
|
|
|
Get(repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff). |
|
|
|
Get(repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff). |
|
|
|
Post(reqSignIn, context.RepoMustNotBeArchived(), reqRepoPullsReader, repo.MustAllowPulls, web.Bind(forms.CreateIssueForm{}), repo.SetWhitespaceBehavior, repo.CompareAndPullRequestPost) |
|
|
|
Post(reqSignIn, context.RepoMustNotBeArchived(), reqUnitPullsReader, repo.MustAllowPulls, web.Bind(forms.CreateIssueForm{}), repo.SetWhitespaceBehavior, repo.CompareAndPullRequestPost) |
|
|
|
}, optSignIn, context.RepoAssignment, reqRepoCodeReader) |
|
|
|
}, optSignIn, context.RepoAssignment, reqUnitCodeReader) |
|
|
|
// end "/{username}/{reponame}": repo code: find, compare, list
|
|
|
|
// end "/{username}/{reponame}": repo code: find, compare, list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addIssuesPullsViewRoutes := func() { |
|
|
|
|
|
|
|
// for /{username}/{reponame}/issues" or "/{username}/{reponame}/pulls"
|
|
|
|
|
|
|
|
m.Get("/posters", repo.IssuePullPosters) |
|
|
|
|
|
|
|
m.Group("/{index}", func() { |
|
|
|
|
|
|
|
m.Get("/info", repo.GetIssueInfo) |
|
|
|
|
|
|
|
m.Get("/attachments", repo.GetIssueAttachments) |
|
|
|
|
|
|
|
m.Get("/attachments/{uuid}", repo.GetAttachment) |
|
|
|
|
|
|
|
m.Group("/content-history", func() { |
|
|
|
|
|
|
|
m.Get("/overview", repo.GetContentHistoryOverview) |
|
|
|
|
|
|
|
m.Get("/list", repo.GetContentHistoryList) |
|
|
|
|
|
|
|
m.Get("/detail", repo.GetContentHistoryDetail) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Get("/issues/posters", repo.IssuePosters) // it can't use {type:issues|pulls} because it would conflict with other routes like "/pulls/{index}"
|
|
|
|
|
|
|
|
m.Get("/pulls/posters", repo.PullPosters) |
|
|
|
|
|
|
|
m.Get("/comments/{id}/attachments", repo.GetCommentAttachments) |
|
|
|
m.Get("/comments/{id}/attachments", repo.GetCommentAttachments) |
|
|
|
m.Get("/labels", repo.RetrieveLabelsForList, repo.Labels) |
|
|
|
m.Get("/labels", repo.RetrieveLabelsForList, repo.Labels) |
|
|
|
m.Get("/milestones", repo.Milestones) |
|
|
|
m.Get("/milestones", repo.Milestones) |
|
|
|
m.Get("/milestone/{id}", context.RepoRef(), repo.MilestoneIssuesAndPulls) |
|
|
|
m.Get("/milestone/{id}", context.RepoRef(), repo.MilestoneIssuesAndPulls) |
|
|
|
m.Group("/{type:issues|pulls}", func() { |
|
|
|
|
|
|
|
m.Group("/{index}", func() { |
|
|
|
|
|
|
|
m.Get("/info", repo.GetIssueInfo) |
|
|
|
|
|
|
|
m.Get("/attachments", repo.GetIssueAttachments) |
|
|
|
|
|
|
|
m.Get("/attachments/{uuid}", repo.GetAttachment) |
|
|
|
|
|
|
|
m.Group("/content-history", func() { |
|
|
|
|
|
|
|
m.Get("/overview", repo.GetContentHistoryOverview) |
|
|
|
|
|
|
|
m.Get("/list", repo.GetContentHistoryList) |
|
|
|
|
|
|
|
m.Get("/detail", repo.GetContentHistoryDetail) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, context.RepoRef()) |
|
|
|
|
|
|
|
m.Get("/issues/suggestions", repo.IssueSuggestions) |
|
|
|
m.Get("/issues/suggestions", repo.IssueSuggestions) |
|
|
|
}, optSignIn, context.RepoAssignment, reqRepoIssuesOrPullsReader) |
|
|
|
}, optSignIn, context.RepoAssignment, reqRepoIssuesOrPullsReader) // issue/pull attachments, labels, milestones
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}/{type:issues}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitIssuesReader) |
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}/{type:pulls}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitPullsReader) |
|
|
|
// end "/{username}/{reponame}": view milestone, label, issue, pull, etc
|
|
|
|
// end "/{username}/{reponame}": view milestone, label, issue, pull, etc
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/{username}/{reponame}/{type:issues}", func() { |
|
|
|
m.Group("/{type:issues|pulls}", func() { |
|
|
|
m.Get("", repo.Issues) |
|
|
|
m.Get("", repo.Issues) |
|
|
|
m.Get("/{index}", repo.ViewIssue) |
|
|
|
m.Group("/{index}", func() { |
|
|
|
}, optSignIn, context.RepoAssignment, context.RequireUnitReader(unit.TypeIssues, unit.TypeExternalTracker)) |
|
|
|
m.Get("", repo.ViewIssue) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, optSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypeIssues, unit.TypePullRequests, unit.TypeExternalTracker)) |
|
|
|
|
|
|
|
// end "/{username}/{reponame}": issue/pull list, issue/pull view, external tracker
|
|
|
|
// end "/{username}/{reponame}": issue/pull list, issue/pull view, external tracker
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { // edit issues, pulls, labels, milestones, etc
|
|
|
|
m.Group("/{username}/{reponame}", func() { // edit issues, pulls, labels, milestones, etc
|
|
|
@ -1209,11 +1210,10 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Get("/choose", context.RepoRef(), repo.NewIssueChooseTemplate) |
|
|
|
m.Get("/choose", context.RepoRef(), repo.NewIssueChooseTemplate) |
|
|
|
}) |
|
|
|
}) |
|
|
|
m.Get("/search", repo.SearchRepoIssuesJSON) |
|
|
|
m.Get("/search", repo.SearchRepoIssuesJSON) |
|
|
|
}, context.RepoMustNotBeArchived(), reqRepoIssueReader) |
|
|
|
}, reqUnitIssuesReader) |
|
|
|
|
|
|
|
|
|
|
|
// FIXME: should use different URLs but mostly same logic for comments of issue and pull request.
|
|
|
|
addIssuesPullsRoutes := func() { |
|
|
|
// So they can apply their own enable/disable logic on routers.
|
|
|
|
// for "/{username}/{reponame}/issues" or "/{username}/{reponame}/pulls"
|
|
|
|
m.Group("/{type:issues|pulls}", func() { |
|
|
|
|
|
|
|
m.Group("/{index}", func() { |
|
|
|
m.Group("/{index}", func() { |
|
|
|
m.Post("/title", repo.UpdateIssueTitle) |
|
|
|
m.Post("/title", repo.UpdateIssueTitle) |
|
|
|
m.Post("/content", repo.UpdateIssueContent) |
|
|
|
m.Post("/content", repo.UpdateIssueContent) |
|
|
@ -1240,39 +1240,37 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Post("/lock", reqRepoIssuesOrPullsWriter, web.Bind(forms.IssueLockForm{}), repo.LockIssue) |
|
|
|
m.Post("/lock", reqRepoIssuesOrPullsWriter, web.Bind(forms.IssueLockForm{}), repo.LockIssue) |
|
|
|
m.Post("/unlock", reqRepoIssuesOrPullsWriter, repo.UnlockIssue) |
|
|
|
m.Post("/unlock", reqRepoIssuesOrPullsWriter, repo.UnlockIssue) |
|
|
|
m.Post("/delete", reqRepoAdmin, repo.DeleteIssue) |
|
|
|
m.Post("/delete", reqRepoAdmin, repo.DeleteIssue) |
|
|
|
}, context.RepoMustNotBeArchived()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{index}", func() { |
|
|
|
|
|
|
|
m.Post("/content-history/soft-delete", repo.SoftDeleteContentHistory) |
|
|
|
m.Post("/content-history/soft-delete", repo.SoftDeleteContentHistory) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
m.Post("/labels", reqRepoIssuesOrPullsWriter, repo.UpdateIssueLabel) |
|
|
|
m.Post("/attachments", repo.UploadIssueAttachment) |
|
|
|
m.Post("/milestone", reqRepoIssuesOrPullsWriter, repo.UpdateIssueMilestone) |
|
|
|
m.Post("/attachments/remove", repo.DeleteAttachment) |
|
|
|
|
|
|
|
|
|
|
|
m.Post("/projects", reqRepoIssuesOrPullsWriter, reqRepoProjectsReader, repo.UpdateIssueProject) |
|
|
|
m.Post("/projects", reqRepoIssuesOrPullsWriter, reqRepoProjectsReader, repo.UpdateIssueProject) |
|
|
|
m.Post("/assignee", reqRepoIssuesOrPullsWriter, repo.UpdateIssueAssignee) |
|
|
|
m.Post("/assignee", reqRepoIssuesOrPullsWriter, repo.UpdateIssueAssignee) |
|
|
|
m.Post("/request_review", repo.UpdatePullReviewRequest) |
|
|
|
|
|
|
|
m.Post("/dismiss_review", reqRepoAdmin, web.Bind(forms.DismissReviewForm{}), repo.DismissReview) |
|
|
|
|
|
|
|
m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus) |
|
|
|
m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus) |
|
|
|
m.Post("/delete", reqRepoAdmin, repo.BatchDeleteIssues) |
|
|
|
m.Post("/delete", reqRepoAdmin, repo.BatchDeleteIssues) |
|
|
|
m.Post("/resolve_conversation", repo.SetShowOutdatedComments, repo.UpdateResolveConversation) |
|
|
|
|
|
|
|
m.Post("/attachments", repo.UploadIssueAttachment) |
|
|
|
|
|
|
|
m.Post("/attachments/remove", repo.DeleteAttachment) |
|
|
|
|
|
|
|
m.Delete("/unpin/{index}", reqRepoAdmin, repo.IssueUnpin) |
|
|
|
m.Delete("/unpin/{index}", reqRepoAdmin, repo.IssueUnpin) |
|
|
|
m.Post("/move_pin", reqRepoAdmin, repo.IssuePinMove) |
|
|
|
m.Post("/move_pin", reqRepoAdmin, repo.IssuePinMove) |
|
|
|
}, context.RepoMustNotBeArchived()) |
|
|
|
} |
|
|
|
|
|
|
|
m.Group("/{type:issues}", addIssuesPullsRoutes, reqUnitIssuesReader, context.RepoMustNotBeArchived()) |
|
|
|
|
|
|
|
m.Group("/{type:pulls}", addIssuesPullsRoutes, reqUnitPullsReader, context.RepoMustNotBeArchived()) |
|
|
|
|
|
|
|
|
|
|
|
m.Group("/comments/{id}", func() { |
|
|
|
m.Group("/comments/{id}", func() { |
|
|
|
m.Post("", repo.UpdateCommentContent) |
|
|
|
m.Post("", repo.UpdateCommentContent) |
|
|
|
m.Post("/delete", repo.DeleteComment) |
|
|
|
m.Post("/delete", repo.DeleteComment) |
|
|
|
m.Post("/reactions/{action}", web.Bind(forms.ReactionForm{}), repo.ChangeCommentReaction) |
|
|
|
m.Post("/reactions/{action}", web.Bind(forms.ReactionForm{}), repo.ChangeCommentReaction) |
|
|
|
}, context.RepoMustNotBeArchived()) |
|
|
|
}, reqRepoIssuesOrPullsReader) // edit issue/pull comment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.Post("/labels", reqRepoIssuesOrPullsWriter, repo.UpdateIssueLabel) |
|
|
|
m.Group("/labels", func() { |
|
|
|
m.Group("/labels", func() { |
|
|
|
m.Post("/new", web.Bind(forms.CreateLabelForm{}), repo.NewLabel) |
|
|
|
m.Post("/new", web.Bind(forms.CreateLabelForm{}), repo.NewLabel) |
|
|
|
m.Post("/edit", web.Bind(forms.CreateLabelForm{}), repo.UpdateLabel) |
|
|
|
m.Post("/edit", web.Bind(forms.CreateLabelForm{}), repo.UpdateLabel) |
|
|
|
m.Post("/delete", repo.DeleteLabel) |
|
|
|
m.Post("/delete", repo.DeleteLabel) |
|
|
|
m.Post("/initialize", web.Bind(forms.InitializeLabelsForm{}), repo.InitializeLabels) |
|
|
|
m.Post("/initialize", web.Bind(forms.InitializeLabelsForm{}), repo.InitializeLabels) |
|
|
|
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef()) |
|
|
|
}, reqRepoIssuesOrPullsWriter, context.RepoRef()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.Post("/milestone", reqRepoIssuesOrPullsWriter, repo.UpdateIssueMilestone) |
|
|
|
m.Group("/milestones", func() { |
|
|
|
m.Group("/milestones", func() { |
|
|
|
m.Combo("/new").Get(repo.NewMilestone). |
|
|
|
m.Combo("/new").Get(repo.NewMilestone). |
|
|
|
Post(web.Bind(forms.CreateMilestoneForm{}), repo.NewMilestonePost) |
|
|
|
Post(web.Bind(forms.CreateMilestoneForm{}), repo.NewMilestonePost) |
|
|
@ -1280,11 +1278,15 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Post("/{id}/edit", web.Bind(forms.CreateMilestoneForm{}), repo.EditMilestonePost) |
|
|
|
m.Post("/{id}/edit", web.Bind(forms.CreateMilestoneForm{}), repo.EditMilestonePost) |
|
|
|
m.Post("/{id}/{action}", repo.ChangeMilestoneStatus) |
|
|
|
m.Post("/{id}/{action}", repo.ChangeMilestoneStatus) |
|
|
|
m.Post("/delete", repo.DeleteMilestone) |
|
|
|
m.Post("/delete", repo.DeleteMilestone) |
|
|
|
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef()) |
|
|
|
}, reqRepoIssuesOrPullsWriter, context.RepoRef()) |
|
|
|
m.Group("/pull", func() { |
|
|
|
|
|
|
|
m.Post("/{index}/target_branch", repo.UpdatePullRequestTarget) |
|
|
|
m.Group("", func() { |
|
|
|
}, context.RepoMustNotBeArchived()) |
|
|
|
m.Post("/request_review", repo.UpdatePullReviewRequest) |
|
|
|
}, reqSignIn, context.RepoAssignment, reqRepoIssuesOrPullsReader) |
|
|
|
m.Post("/dismiss_review", reqRepoAdmin, web.Bind(forms.DismissReviewForm{}), repo.DismissReview) |
|
|
|
|
|
|
|
m.Post("/resolve_conversation", repo.SetShowOutdatedComments, repo.UpdateResolveConversation) |
|
|
|
|
|
|
|
m.Post("/pull/{index}/target_branch", repo.UpdatePullRequestTarget) |
|
|
|
|
|
|
|
}, reqUnitPullsReader) |
|
|
|
|
|
|
|
}, reqSignIn, context.RepoAssignment, context.RepoMustNotBeArchived()) |
|
|
|
// end "/{username}/{reponame}": create or edit issues, pulls, labels, milestones
|
|
|
|
// end "/{username}/{reponame}": create or edit issues, pulls, labels, milestones
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { // repo code
|
|
|
|
m.Group("/{username}/{reponame}", func() { // repo code
|
|
|
@ -1324,7 +1326,7 @@ func registerRoutes(m *web.Router) { |
|
|
|
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty) |
|
|
|
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty) |
|
|
|
|
|
|
|
|
|
|
|
m.Combo("/fork").Get(repo.Fork).Post(web.Bind(forms.CreateRepoForm{}), repo.ForkPost) |
|
|
|
m.Combo("/fork").Get(repo.Fork).Post(web.Bind(forms.CreateRepoForm{}), repo.ForkPost) |
|
|
|
}, reqSignIn, context.RepoAssignment, reqRepoCodeReader) |
|
|
|
}, reqSignIn, context.RepoAssignment, reqUnitCodeReader) |
|
|
|
// end "/{username}/{reponame}": repo code
|
|
|
|
// end "/{username}/{reponame}": repo code
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { // repo tags
|
|
|
|
m.Group("/{username}/{reponame}", func() { // repo tags
|
|
|
@ -1337,7 +1339,7 @@ func registerRoutes(m *web.Router) { |
|
|
|
repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, context.RepoRefByTypeOptions{IgnoreNotExistErr: true})) |
|
|
|
repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, context.RepoRefByTypeOptions{IgnoreNotExistErr: true})) |
|
|
|
m.Post("/tags/delete", repo.DeleteTag, reqSignIn, |
|
|
|
m.Post("/tags/delete", repo.DeleteTag, reqSignIn, |
|
|
|
repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef()) |
|
|
|
repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef()) |
|
|
|
}, optSignIn, context.RepoAssignment, reqRepoCodeReader) |
|
|
|
}, optSignIn, context.RepoAssignment, reqUnitCodeReader) |
|
|
|
// end "/{username}/{reponame}": repo tags
|
|
|
|
// end "/{username}/{reponame}": repo tags
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { // repo releases
|
|
|
|
m.Group("/{username}/{reponame}", func() { // repo releases
|
|
|
@ -1440,43 +1442,48 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Group("/{username}/{reponame}/wiki", func() { |
|
|
|
m.Group("/{username}/{reponame}/wiki", func() { |
|
|
|
m.Combo(""). |
|
|
|
m.Combo(""). |
|
|
|
Get(repo.Wiki). |
|
|
|
Get(repo.Wiki). |
|
|
|
Post(context.RepoMustNotBeArchived(), reqSignIn, reqRepoWikiWriter, web.Bind(forms.NewWikiForm{}), repo.WikiPost) |
|
|
|
Post(context.RepoMustNotBeArchived(), reqSignIn, reqUnitWikiWriter, web.Bind(forms.NewWikiForm{}), repo.WikiPost) |
|
|
|
m.Combo("/*"). |
|
|
|
m.Combo("/*"). |
|
|
|
Get(repo.Wiki). |
|
|
|
Get(repo.Wiki). |
|
|
|
Post(context.RepoMustNotBeArchived(), reqSignIn, reqRepoWikiWriter, web.Bind(forms.NewWikiForm{}), repo.WikiPost) |
|
|
|
Post(context.RepoMustNotBeArchived(), reqSignIn, reqUnitWikiWriter, web.Bind(forms.NewWikiForm{}), repo.WikiPost) |
|
|
|
m.Get("/blob_excerpt/{sha}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ExcerptBlob) |
|
|
|
m.Get("/blob_excerpt/{sha}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ExcerptBlob) |
|
|
|
m.Get("/commit/{sha:[a-f0-9]{7,64}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff) |
|
|
|
m.Get("/commit/{sha:[a-f0-9]{7,64}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff) |
|
|
|
m.Get("/commit/{sha:[a-f0-9]{7,64}}.{ext:patch|diff}", repo.RawDiff) |
|
|
|
m.Get("/commit/{sha:[a-f0-9]{7,64}}.{ext:patch|diff}", repo.RawDiff) |
|
|
|
m.Get("/raw/*", repo.WikiRaw) |
|
|
|
m.Get("/raw/*", repo.WikiRaw) |
|
|
|
}, optSignIn, context.RepoAssignment, repo.MustEnableWiki, reqRepoWikiReader, func(ctx *context.Context) { |
|
|
|
}, optSignIn, context.RepoAssignment, repo.MustEnableWiki, reqUnitWikiReader, func(ctx *context.Context) { |
|
|
|
ctx.Data["PageIsWiki"] = true |
|
|
|
ctx.Data["PageIsWiki"] = true |
|
|
|
ctx.Data["CloneButtonOriginLink"] = ctx.Repo.Repository.WikiCloneLink(ctx, ctx.Doer) |
|
|
|
ctx.Data["CloneButtonOriginLink"] = ctx.Repo.Repository.WikiCloneLink(ctx, ctx.Doer) |
|
|
|
}) |
|
|
|
}) |
|
|
|
// end "/{username}/{reponame}/wiki"
|
|
|
|
// end "/{username}/{reponame}/wiki"
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}/activity", func() { |
|
|
|
m.Group("/{username}/{reponame}/activity", func() { |
|
|
|
|
|
|
|
// activity has its own permission checks
|
|
|
|
m.Get("", repo.Activity) |
|
|
|
m.Get("", repo.Activity) |
|
|
|
m.Get("/{period}", repo.Activity) |
|
|
|
m.Get("/{period}", repo.Activity) |
|
|
|
m.Group("/contributors", func() { |
|
|
|
|
|
|
|
m.Get("", repo.Contributors) |
|
|
|
m.Group("", func() { |
|
|
|
m.Get("/data", repo.ContributorsData) |
|
|
|
m.Group("/contributors", func() { |
|
|
|
}) |
|
|
|
m.Get("", repo.Contributors) |
|
|
|
m.Group("/code-frequency", func() { |
|
|
|
m.Get("/data", repo.ContributorsData) |
|
|
|
m.Get("", repo.CodeFrequency) |
|
|
|
}) |
|
|
|
m.Get("/data", repo.CodeFrequencyData) |
|
|
|
m.Group("/code-frequency", func() { |
|
|
|
}) |
|
|
|
m.Get("", repo.CodeFrequency) |
|
|
|
m.Group("/recent-commits", func() { |
|
|
|
m.Get("/data", repo.CodeFrequencyData) |
|
|
|
m.Get("", repo.RecentCommits) |
|
|
|
}) |
|
|
|
m.Get("/data", repo.RecentCommitsData) |
|
|
|
m.Group("/recent-commits", func() { |
|
|
|
}) |
|
|
|
m.Get("", repo.RecentCommits) |
|
|
|
|
|
|
|
m.Get("/data", repo.RecentCommitsData) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, reqUnitCodeReader) |
|
|
|
}, |
|
|
|
}, |
|
|
|
optSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases), |
|
|
|
optSignIn, context.RepoAssignment, repo.MustBeNotEmpty, |
|
|
|
context.RepoRef(), repo.MustBeNotEmpty, |
|
|
|
context.RequireUnitReader(unit.TypeCode, unit.TypeIssues, unit.TypePullRequests, unit.TypeReleases), |
|
|
|
) |
|
|
|
) |
|
|
|
// end "/{username}/{reponame}/activity"
|
|
|
|
// end "/{username}/{reponame}/activity"
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/pulls/{index}", func() { |
|
|
|
m.Get("/{type:pulls}", repo.Issues) |
|
|
|
|
|
|
|
m.Group("/{type:pulls}/{index}", func() { |
|
|
|
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewIssue) |
|
|
|
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewIssue) |
|
|
|
m.Get(".diff", repo.DownloadPullDiff) |
|
|
|
m.Get(".diff", repo.DownloadPullDiff) |
|
|
|
m.Get(".patch", repo.DownloadPullPatch) |
|
|
|
m.Get(".patch", repo.DownloadPullPatch) |
|
|
@ -1501,7 +1508,7 @@ func registerRoutes(m *web.Router) { |
|
|
|
}, context.RepoMustNotBeArchived()) |
|
|
|
}, context.RepoMustNotBeArchived()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, optSignIn, context.RepoAssignment, repo.MustAllowPulls, reqRepoPullsReader) |
|
|
|
}, optSignIn, context.RepoAssignment, repo.MustAllowPulls, reqUnitPullsReader) |
|
|
|
// end "/{username}/{reponame}/pulls/{index}": repo pull request
|
|
|
|
// end "/{username}/{reponame}/pulls/{index}": repo pull request
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
@ -1582,13 +1589,13 @@ func registerRoutes(m *web.Router) { |
|
|
|
m.Get("/forks", context.RepoRef(), repo.Forks) |
|
|
|
m.Get("/forks", context.RepoRef(), repo.Forks) |
|
|
|
m.Get("/commit/{sha:([a-f0-9]{7,64})}.{ext:patch|diff}", repo.MustBeNotEmpty, repo.RawDiff) |
|
|
|
m.Get("/commit/{sha:([a-f0-9]{7,64})}.{ext:patch|diff}", repo.MustBeNotEmpty, repo.RawDiff) |
|
|
|
m.Post("/lastcommit/*", context.RepoRefByType(context.RepoRefCommit), repo.LastCommit) |
|
|
|
m.Post("/lastcommit/*", context.RepoRefByType(context.RepoRefCommit), repo.LastCommit) |
|
|
|
}, optSignIn, context.RepoAssignment, reqRepoCodeReader) |
|
|
|
}, optSignIn, context.RepoAssignment, reqUnitCodeReader) |
|
|
|
// end "/{username}/{reponame}": repo code
|
|
|
|
// end "/{username}/{reponame}": repo code
|
|
|
|
|
|
|
|
|
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Group("/{username}/{reponame}", func() { |
|
|
|
m.Get("/stars", repo.Stars) |
|
|
|
m.Get("/stars", repo.Stars) |
|
|
|
m.Get("/watchers", repo.Watchers) |
|
|
|
m.Get("/watchers", repo.Watchers) |
|
|
|
m.Get("/search", reqRepoCodeReader, repo.Search) |
|
|
|
m.Get("/search", reqUnitCodeReader, repo.Search) |
|
|
|
m.Post("/action/{action}", reqSignIn, repo.Action) |
|
|
|
m.Post("/action/{action}", reqSignIn, repo.Action) |
|
|
|
}, optSignIn, context.RepoAssignment, context.RepoRef()) |
|
|
|
}, optSignIn, context.RepoAssignment, context.RepoRef()) |
|
|
|
|
|
|
|
|
|
|
|