Skip to content

Commit c57011e

Browse files
committed
more code comment info and cleanup
1 parent 8f83720 commit c57011e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

routers/web/repo/view.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ func checkHomeCodeViewable(ctx *context.Context) {
722722
}
723723
}
724724

725-
// TODO: ctx.Repo.Repository.DefaultUnit has to be respected here ... but we need to let code unit have it's own subpath ...
726725
var firstUnit *unit_model.Unit
727726
for _, repoUnitType := range ctx.Repo.Permission.ReadableUnitTypes() {
728727
if repoUnitType == unit_model.TypeCode {
@@ -773,7 +772,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
773772
}
774773
}
775774

776-
// HomeWithFeedCheck render repository home page or return feed
775+
// HomeWithFeedCheck redirect to default unit or return feed
777776
func HomeWithFeedCheck(ctx *context.Context) {
778777
if setting.Other.EnableFeed {
779778
isFeed, _, showFeedType := feed.GetFeedType(ctx.PathParam(":reponame"), ctx.Req)
@@ -794,11 +793,11 @@ func HomeWithFeedCheck(ctx *context.Context) {
794793
if defaultURI == "/" { // support legacy code units
795794
defaultURI = "/code"
796795
}
797-
ctx.Redirect(ctx.Repo.RepoLink + defaultURI)
796+
ctx.Redirect(ctx.Repo.RepoLink+defaultURI, http.StatusMovedPermanently)
798797
}
799798

800-
// Home render repository home page
801-
func Home(ctx *context.Context) {
799+
// CodeHome render repository home page
800+
func CodeHome(ctx *context.Context) {
802801
checkHomeCodeViewable(ctx)
803802
if ctx.Written() {
804803
return

routers/web/web.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,10 @@ func registerRoutes(m *web.Router) {
11391139
)
11401140
// end "/{username}/{reponame}/settings"
11411141

1142-
// user/org home, including rss feeds
1142+
// user/org home, witch either redirects to default unit or return rss feeds
11431143
m.Get("/{username}/{reponame}", ignSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.HomeWithFeedCheck)
1144-
m.Get("/{username}/{reponame}/code", ignSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.Home)
1144+
// show the code unit's home view
1145+
m.Get("/{username}/{reponame}/code", ignSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.CodeHome)
11451146

11461147
// TODO: maybe it should relax the permission to allow "any access"
11471148
m.Post("/{username}/{reponame}/markup", ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypeCode, unit.TypeIssues, unit.TypePullRequests, unit.TypeReleases, unit.TypeWiki), web.Bind(structs.MarkupOption{}), misc.Markup)

0 commit comments

Comments
 (0)