From 306aa5bffe7868207ed7b773c1aedbf3f0a659ad Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 10 Apr 2014 22:03:31 -0400 Subject: Add support default branch --- modules/middleware/repo.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'modules/middleware') diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 2139742c70..ae9f04b113 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -76,7 +76,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { ctx.Redirect("/") return } - ctx.Handle(404, "RepoAssignment", err) + ctx.Handle(500, "RepoAssignment", err) return } repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues @@ -86,7 +86,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { gitRepo, err := git.OpenRepository(models.RepoPath(userName, repoName)) if err != nil { - ctx.Handle(404, "RepoAssignment Invalid repo "+models.RepoPath(userName, repoName), err) + ctx.Handle(500, "RepoAssignment Invalid repo "+models.RepoPath(userName, repoName), err) return } ctx.Repo.GitRepo = gitRepo @@ -138,7 +138,10 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { } } else { - branchName = "master" + branchName = ctx.Repo.Repository.DefaultBranch + if len(branchName) == 0 { + branchName = "master" + } goto detect } @@ -157,6 +160,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { } ctx.Data["BranchName"] = ctx.Repo.BranchName + ctx.Data["Branches"], _ = models.GetBranches(ctx.User.Name, ctx.Repo.Repository.Name) ctx.Data["CommitId"] = ctx.Repo.CommitId ctx.Data["IsRepositoryWatching"] = ctx.Repo.IsWatching } -- cgit v1.2.3