Skip to content

Commit 01d5b5e

Browse files
committed
Merge pull request #15 from sapk/master
Add branch representation and API calls
2 parents 2f4342d + 25f8ed6 commit 01d5b5e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

repo_branches.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package gogs
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
type Branch struct {
8+
Name string `json:"name"`
9+
Commit *PayloadCommit `json:"commit"`
10+
}
11+
12+
func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) {
13+
branches := make([]*Branch, 0, 10)
14+
return branches, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches", user, repo), nil, nil, &branches)
15+
}
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+
}

0 commit comments

Comments
 (0)