// get repository
repo, err := models.GetRepositoryByName(user.Id, params["reponame"])
if err != nil {
- if redirect {
+ if err == models.ErrRepoNotExist {
+ ctx.Handle(404, "RepoAssignment", err)
+ } else if redirect {
ctx.Redirect("/")
return
}
import (
"fmt"
+ "net/url"
"github.com/codegangsta/martini"
var posterId int64 = 0
if ctx.Query("type") == "created_by" {
if !ctx.IsSigned {
+ ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI))
ctx.Redirect("/user/login/", 302)
+ return
}
posterId = ctx.User.Id
ctx.Data["ViewType"] = "created_by"
ctx.Data["Branches"] = brs
var commitId string
- if !models.IsBranchExist(userName, repoName, branchName) {
+ isViewBranch := models.IsBranchExist(userName, repoName, branchName)
+ if !isViewBranch {
commitId = branchName
}
+ ctx.Data["IsViewBranch"] = isViewBranch
repoFile, err := models.GetTargetFile(userName, repoName,
branchName, commitId, treename)
<ul class="nav navbar-nav">
<li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="/{{.RepositoryLink}}">Source</a></li>
{{if not .IsBareRepo}}
- <li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="/{{.RepositoryLink}}/commits/{{.Branchname}}">Commits</a></li>
+ {{if .IsViewBranch}}<li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="/{{.RepositoryLink}}/commits/{{.Branchname}}">Commits</a></li>{{end}}
<!-- <li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="/{{.RepositoryLink}}/branches">Branches</a></li> -->
<!-- <li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li> -->
<li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="/{{.RepositoryLink}}/issues">Issues <!--<span class="badge">42</span>--></a></li>