branch.go 932 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "github.com/codegangsta/martini"
  7. "github.com/gogits/gogs/models"
  8. "github.com/gogits/gogs/modules/middleware"
  9. )
  10. func Branches(ctx *middleware.Context, params martini.Params) {
  11. if !ctx.Repo.IsValid {
  12. return
  13. }
  14. brs, err := models.GetBranches(params["username"], params["reponame"])
  15. if err != nil {
  16. ctx.Handle(200, "repo.Branches", err)
  17. return
  18. } else if len(brs) == 0 {
  19. ctx.Handle(404, "repo.Branches", nil)
  20. return
  21. }
  22. ctx.Data["Username"] = params["username"]
  23. ctx.Data["Reponame"] = params["reponame"]
  24. if len(params["branchname"]) == 0 {
  25. params["branchname"] = "master"
  26. }
  27. ctx.Data["Branchname"] = params["branchname"]
  28. ctx.Data["Branches"] = brs
  29. ctx.Data["IsRepoToolbarBranches"] = true
  30. ctx.HTML(200, "repo/branches")
  31. }