You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
735 B

  1. // Copyright 2017 The Gitea 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 private
  5. import (
  6. "code.gitea.io/gitea/models"
  7. macaron "gopkg.in/macaron.v1"
  8. )
  9. // GetProtectedBranchBy get protected branch information
  10. func GetProtectedBranchBy(ctx *macaron.Context) {
  11. repoID := ctx.ParamsInt64(":id")
  12. branchName := ctx.Params("*")
  13. protectBranch, err := models.GetProtectedBranchBy(repoID, branchName)
  14. if err != nil {
  15. ctx.JSON(500, map[string]interface{}{
  16. "err": err.Error(),
  17. })
  18. return
  19. } else if protectBranch != nil {
  20. ctx.JSON(200, protectBranch)
  21. } else {
  22. ctx.JSON(200, &models.ProtectedBranch{
  23. CanPush: true,
  24. })
  25. }
  26. }