aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/view.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-05-18 22:54:24 +0800
committerGitHub <noreply@github.com>2017-05-18 22:54:24 +0800
commitfd6034aaf23af1ce03bcba0babcbe7675ce093ee (patch)
tree9720f416facdef02a76bd56ca50669cc1f17eb88 /routers/repo/view.go
parent5db5e16ab61f25f21cb17ee4895679b9830641a5 (diff)
downloadgitea-fd6034aaf23af1ce03bcba0babcbe7675ce093ee.tar.gz
gitea-fd6034aaf23af1ce03bcba0babcbe7675ce093ee.zip
Add units to team (#947)
* add units to team * fix lint * finish team setting backend * finished permission controll on routes * fix import blank line * add unit check on ssh/http pull and push and fix test failed * fix fixtures data * remove unused code
Diffstat (limited to 'routers/repo/view.go')
-rw-r--r--routers/repo/view.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go
index a4f15ae5de..17aa8701e2 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -252,6 +252,25 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
// Home render repository home page
func Home(ctx *context.Context) {
+ if len(ctx.Repo.Repository.Units) > 0 {
+ tp := ctx.Repo.Repository.Units[0].Type
+ if tp == models.UnitTypeCode {
+ renderCode(ctx)
+ return
+ }
+
+ unit, ok := models.Units[tp]
+ if ok {
+ ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/%s%s",
+ ctx.Repo.Repository.FullName(), unit.URI))
+ return
+ }
+ }
+
+ ctx.Handle(404, "Home", fmt.Errorf(ctx.Tr("units.error.no_unit_allowed_repo")))
+}
+
+func renderCode(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
if ctx.Repo.Repository.IsBare {