mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-30 18:44:27 +00:00
Add repo branches endpoint (#481)
* add repo branches endpoint * add branches func to remotes
This commit is contained in:
@@ -424,6 +424,25 @@ func (c *Gitea) Deactivate(ctx context.Context, u *model.User, r *model.Repo, li
|
||||
return nil
|
||||
}
|
||||
|
||||
// Branches returns the names of all branches for the named repository.
|
||||
func (c *Gitea) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]string, error) {
|
||||
client, err := c.newClientToken(ctx, u.Token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
giteaBranches, _, err := client.ListRepoBranches(r.Owner, r.Name, gitea.ListRepoBranchesOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
branches := make([]string, 0)
|
||||
for _, branch := range giteaBranches {
|
||||
branches = append(branches, branch.Name)
|
||||
}
|
||||
return branches, nil
|
||||
}
|
||||
|
||||
// Hook parses the incoming Gitea hook and returns the Repository and Build
|
||||
// details. If the hook is unsupported nil values are returned.
|
||||
func (c *Gitea) Hook(r *http.Request) (*model.Repo, *model.Build, error) {
|
||||
|
||||
Reference in New Issue
Block a user