Skip to content

Commit 3fe082a

Browse files
authored
Remove dead code: RepoRef (#34131)
The RepoRef is a no-op since Refactor ref type (#33242) (Jan 14)
1 parent e94f8d5 commit 3fe082a

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

routers/web/web.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ func registerWebRoutes(m *web.Router) {
12111211
m.Get("/comments/{id}/attachments", repo.GetCommentAttachments)
12121212
m.Get("/labels", repo.RetrieveLabelsForList, repo.Labels)
12131213
m.Get("/milestones", repo.Milestones)
1214-
m.Get("/milestone/{id}", context.RepoRef(), repo.MilestoneIssuesAndPulls)
1214+
m.Get("/milestone/{id}", repo.MilestoneIssuesAndPulls)
12151215
m.Get("/issues/suggestions", repo.IssueSuggestions)
12161216
}, optSignIn, context.RepoAssignment, reqRepoIssuesOrPullsReader) // issue/pull attachments, labels, milestones
12171217
// end "/{username}/{reponame}": view milestone, label, issue, pull, etc
@@ -1225,9 +1225,9 @@ func registerWebRoutes(m *web.Router) {
12251225
m.Group("/{username}/{reponame}", func() { // edit issues, pulls, labels, milestones, etc
12261226
m.Group("/issues", func() {
12271227
m.Group("/new", func() {
1228-
m.Combo("").Get(context.RepoRef(), repo.NewIssue).
1228+
m.Combo("").Get(repo.NewIssue).
12291229
Post(web.Bind(forms.CreateIssueForm{}), repo.NewIssuePost)
1230-
m.Get("/choose", context.RepoRef(), repo.NewIssueChooseTemplate)
1230+
m.Get("/choose", repo.NewIssueChooseTemplate)
12311231
})
12321232
m.Get("/search", repo.SearchRepoIssuesJSON)
12331233
}, reqUnitIssuesReader)
@@ -1290,7 +1290,7 @@ func registerWebRoutes(m *web.Router) {
12901290
m.Post("/edit", web.Bind(forms.CreateLabelForm{}), repo.UpdateLabel)
12911291
m.Post("/delete", repo.DeleteLabel)
12921292
m.Post("/initialize", web.Bind(forms.InitializeLabelsForm{}), repo.InitializeLabels)
1293-
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
1293+
}, reqRepoIssuesOrPullsWriter)
12941294

12951295
m.Group("/milestones", func() {
12961296
m.Combo("/new").Get(repo.NewMilestone).
@@ -1299,7 +1299,7 @@ func registerWebRoutes(m *web.Router) {
12991299
m.Post("/{id}/edit", web.Bind(forms.CreateMilestoneForm{}), repo.EditMilestonePost)
13001300
m.Post("/{id}/{action}", repo.ChangeMilestoneStatus)
13011301
m.Post("/delete", repo.DeleteMilestone)
1302-
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
1302+
}, reqRepoIssuesOrPullsWriter)
13031303

13041304
// FIXME: many "pulls" requests are sent to "issues" endpoints incorrectly, need to move these routes to the proper place
13051305
m.Group("/issues", func() {
@@ -1377,7 +1377,7 @@ func registerWebRoutes(m *web.Router) {
13771377
m.Post("/delete", repo.DeleteRelease)
13781378
m.Post("/attachments", repo.UploadReleaseAttachment)
13791379
m.Post("/attachments/remove", repo.DeleteAttachment)
1380-
}, reqSignIn, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, context.RepoRef())
1380+
}, reqSignIn, context.RepoMustNotBeArchived(), reqRepoReleaseWriter)
13811381
m.Group("/releases", func() {
13821382
m.Get("/edit/*", repo.EditRelease)
13831383
m.Post("/edit/*", web.Bind(forms.EditReleaseForm{}), repo.EditReleasePost)
@@ -1506,19 +1506,19 @@ func registerWebRoutes(m *web.Router) {
15061506
m.Get(".diff", repo.DownloadPullDiff)
15071507
m.Get(".patch", repo.DownloadPullPatch)
15081508
m.Group("/commits", func() {
1509-
m.Get("", context.RepoRef(), repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewPullCommits)
1510-
m.Get("/list", context.RepoRef(), repo.GetPullCommits)
1511-
m.Get("/{sha:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForSingleCommit)
1509+
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewPullCommits)
1510+
m.Get("/list", repo.GetPullCommits)
1511+
m.Get("/{sha:[a-f0-9]{7,40}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForSingleCommit)
15121512
})
15131513
m.Post("/merge", context.RepoMustNotBeArchived(), web.Bind(forms.MergePullRequestForm{}), repo.MergePullRequest)
15141514
m.Post("/cancel_auto_merge", context.RepoMustNotBeArchived(), repo.CancelAutoMergePullRequest)
15151515
m.Post("/update", repo.UpdatePullRequest)
15161516
m.Post("/set_allow_maintainer_edit", web.Bind(forms.UpdateAllowEditsForm{}), repo.SetAllowEdits)
1517-
m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest)
1517+
m.Post("/cleanup", context.RepoMustNotBeArchived(), repo.CleanUpPullRequest)
15181518
m.Group("/files", func() {
1519-
m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForAllCommitsOfPr)
1520-
m.Get("/{sha:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesStartingFromCommit)
1521-
m.Get("/{shaFrom:[a-f0-9]{7,40}}..{shaTo:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForRange)
1519+
m.Get("", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForAllCommitsOfPr)
1520+
m.Get("/{sha:[a-f0-9]{7,40}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesStartingFromCommit)
1521+
m.Get("/{shaFrom:[a-f0-9]{7,40}}..{shaTo:[a-f0-9]{7,40}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForRange)
15221522
m.Group("/reviews", func() {
15231523
m.Get("/new_comment", repo.RenderNewCodeCommentForm)
15241524
m.Post("/comments", web.Bind(forms.CodeCommentForm{}), repo.SetShowOutdatedComments, repo.CreateCodeComment)
@@ -1605,7 +1605,7 @@ func registerWebRoutes(m *web.Router) {
16051605
m.Get("/tree/*", repo.RedirectRepoTreeToSrc) // redirect "/owner/repo/tree/*" requests to "/owner/repo/src/*"
16061606
m.Get("/blob/*", repo.RedirectRepoBlobToCommit) // redirect "/owner/repo/blob/*" requests to "/owner/repo/src/commit/*"
16071607

1608-
m.Get("/forks", context.RepoRef(), repo.Forks)
1608+
m.Get("/forks", repo.Forks)
16091609
m.Get("/commit/{sha:([a-f0-9]{7,64})}.{ext:patch|diff}", repo.MustBeNotEmpty, repo.RawDiff)
16101610
m.Post("/lastcommit/*", context.RepoRefByType(git.RefTypeCommit), repo.LastCommit)
16111611
}, optSignIn, context.RepoAssignment, reqUnitCodeReader)

services/context/repo.go

-6
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,6 @@ func RepoAssignment(ctx *Context) {
669669

670670
const headRefName = "HEAD"
671671

672-
func RepoRef() func(*Context) {
673-
// old code does: return RepoRefByType(git.RefTypeBranch)
674-
// in most cases, it is an abuse, so we just disable it completely and fix the abuses one by one (if there is anything wrong)
675-
return nil
676-
}
677-
678672
func getRefNameFromPath(repo *Repository, path string, isExist func(string) bool) string {
679673
refName := ""
680674
parts := strings.Split(path, "/")

0 commit comments

Comments
 (0)