diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-11-05 14:35:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-05 06:35:54 +0000 |
commit | 61c35590c793449d3133b00f58302b5cce90d69c (patch) | |
tree | b546a0aa29f9d906ad7ab3e8b28e746d23016577 /routers/web | |
parent | 4a469c8e1b3c1d153316aec9fd8cbdd3e1dd54e8 (diff) | |
download | gitea-61c35590c793449d3133b00f58302b5cce90d69c.tar.gz gitea-61c35590c793449d3133b00f58302b5cce90d69c.zip |
Refactor RepoRefByType (#32413)
1. clarify the "filepath" could(should) contain "{ref}"
2. remove unclear RepoRefLegacy and RepoRefAny, use RepoRefUnknown to guess
3. by the way, avoid using AppURL
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/goget.go | 2 | ||||
-rw-r--r-- | routers/web/web.go | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/routers/web/goget.go b/routers/web/goget.go index 8d5612ebfe..3714dd8eb0 100644 --- a/routers/web/goget.go +++ b/routers/web/goget.go @@ -65,7 +65,7 @@ func goGet(ctx *context.Context) { insecure = "--insecure " } - goGetImport := context.ComposeGoGetImport(ownerName, trimmedRepoName) + goGetImport := context.ComposeGoGetImport(ctx, ownerName, trimmedRepoName) var cloneURL string if setting.Repository.GoGetCloneURLProtocol == "ssh" { diff --git a/routers/web/web.go b/routers/web/web.go index 83d116babd..69ed4bd8e4 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1323,7 +1323,7 @@ func registerRoutes(m *web.Router) { m.Get(".rss", feedEnabled, repo.TagsListFeedRSS) m.Get(".atom", feedEnabled, repo.TagsListFeedAtom) }, ctxDataSet("EnableFeed", setting.Other.EnableFeed), - repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, true)) + repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, context.RepoRefByTypeOptions{IgnoreNotExistErr: true})) m.Post("/tags/delete", repo.DeleteTag, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef()) }, ignSignIn, context.RepoAssignment, reqRepoCodeReader) @@ -1337,7 +1337,7 @@ func registerRoutes(m *web.Router) { m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS) m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom) }, ctxDataSet("EnableFeed", setting.Other.EnableFeed), - repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, true)) + repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, context.RepoRefByTypeOptions{IgnoreNotExistErr: true})) m.Get("/releases/attachments/{uuid}", repo.MustBeNotEmpty, repo.GetAttachment) m.Get("/releases/download/{vTag}/{fileName}", repo.MustBeNotEmpty, repo.RedirectDownload) m.Group("/releases", func() { @@ -1535,7 +1535,7 @@ func registerRoutes(m *web.Router) { m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.SingleDownloadOrLFS) m.Get("/blob/{sha}", context.RepoRefByType(context.RepoRefBlob), repo.DownloadByIDOrLFS) // "/*" route is deprecated, and kept for backward compatibility - m.Get("/*", context.RepoRefByType(context.RepoRefLegacy), repo.SingleDownloadOrLFS) + m.Get("/*", context.RepoRefByType(context.RepoRefUnknown), repo.SingleDownloadOrLFS) }, repo.MustBeNotEmpty) m.Group("/raw", func() { @@ -1544,7 +1544,7 @@ func registerRoutes(m *web.Router) { m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.SingleDownload) m.Get("/blob/{sha}", context.RepoRefByType(context.RepoRefBlob), repo.DownloadByID) // "/*" route is deprecated, and kept for backward compatibility - m.Get("/*", context.RepoRefByType(context.RepoRefLegacy), repo.SingleDownload) + m.Get("/*", context.RepoRefByType(context.RepoRefUnknown), repo.SingleDownload) }, repo.MustBeNotEmpty) m.Group("/render", func() { @@ -1559,7 +1559,7 @@ func registerRoutes(m *web.Router) { m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.RefCommits) m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.RefCommits) // "/*" route is deprecated, and kept for backward compatibility - m.Get("/*", context.RepoRefByType(context.RepoRefLegacy), repo.RefCommits) + m.Get("/*", context.RepoRefByType(context.RepoRefUnknown), repo.RefCommits) }, repo.MustBeNotEmpty) m.Group("/blame", func() { @@ -1582,7 +1582,7 @@ func registerRoutes(m *web.Router) { m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.Home) m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.Home) m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.Home) - m.Get("/*", context.RepoRefByType(context.RepoRefLegacy), repo.Home) // "/*" route is deprecated, and kept for backward compatibility + m.Get("/*", context.RepoRefByType(context.RepoRefUnknown), repo.Home) // "/*" route is deprecated, and kept for backward compatibility }, repo.SetEditorconfigIfExists) m.Get("/forks", context.RepoRef(), repo.Forks) |