repo_branch.go 776 B

1234567891011121314151617181920212223242526
  1. // Copyright 2016 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 gogs
  5. import (
  6. "fmt"
  7. )
  8. // Branch represents a repository branch.
  9. type Branch struct {
  10. Name string `json:"name"`
  11. Commit *PayloadCommit `json:"commit"`
  12. }
  13. func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) {
  14. branches := make([]*Branch, 0, 10)
  15. return branches, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches", user, repo), nil, nil, &branches)
  16. }
  17. func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, error) {
  18. b := new(Branch)
  19. return b, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches/%s", user, repo, branch), nil, nil, &b)
  20. }