summaryrefslogtreecommitdiffstats
path: root/modules/middleware
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-01 12:03:10 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-01 12:03:10 -0400
commit75109bbd653f69e4a924b6654e564341e4bcf229 (patch)
treefa3a334790fc5ed244ffa9fd0fff6ea8733a3a25 /modules/middleware
parent0a187dbef5d2480f8d47b8013f6e21e06ea18cbd (diff)
downloadgitea-75109bbd653f69e4a924b6654e564341e4bcf229.tar.gz
gitea-75109bbd653f69e4a924b6654e564341e4bcf229.zip
Fix panic when no master branch
Diffstat (limited to 'modules/middleware')
-rw-r--r--modules/middleware/repo.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index e31deac557..c31090b4d5 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -194,9 +194,17 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
}
} else {
- refName = ctx.Repo.Repository.DefaultBranch
if len(refName) == 0 {
- refName = "master"
+ if gitRepo.IsBranchExist(ctx.Repo.Repository.DefaultBranch) {
+ refName = ctx.Repo.Repository.DefaultBranch
+ } else {
+ brs, err := gitRepo.GetBranches()
+ if err != nil {
+ ctx.Handle(500, "RepoAssignment(GetBranches))", err)
+ return
+ }
+ refName = brs[0]
+ }
}
goto detect
}