Add Pagination Options for List Requests #205
|
@ -11,10 +11,16 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AdminListOrgsOptions options for listing admin's organizations
|
||||||
|
type AdminListOrgsOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// AdminListOrgs lists all orgs
|
// AdminListOrgs lists all orgs
|
||||||
func (c *Client) AdminListOrgs() ([]*Organization, error) {
|
func (c *Client) AdminListOrgs(opt AdminListOrgsOptions) ([]*Organization, error) {
|
||||||
orgs := make([]*Organization, 0, 10)
|
opt.setDefaults()
|
||||||
return orgs, c.getParsedResponse("GET", "/admin/orgs", nil, nil, &orgs)
|
orgs := make([]*Organization, 0, opt.PageSize)
|
||||||
|
return orgs, c.getParsedResponse("GET", fmt.Sprintf("/admin/orgs?%s", opt.getURLQuery().Encode()), nil, nil, &orgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminCreateOrg create an organization
|
// AdminCreateOrg create an organization
|
||||||
|
|
|
@ -29,7 +29,7 @@ func TestAdminOrg(t *testing.T) {
|
||||||
assert.NotEmpty(t, newOrg)
|
assert.NotEmpty(t, newOrg)
|
||||||
assert.EqualValues(t, orgName, newOrg.UserName)
|
assert.EqualValues(t, orgName, newOrg.UserName)
|
||||||
|
|
||||||
orgs, err := c.AdminListOrgs()
|
orgs, err := c.AdminListOrgs(AdminListOrgsOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, orgs, 1)
|
assert.Len(t, orgs, 1)
|
||||||
assert.EqualValues(t, newOrg.ID, orgs[0].ID)
|
assert.EqualValues(t, newOrg.ID, orgs[0].ID)
|
||||||
|
|
|
@ -11,10 +11,16 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AdminListUsersOptions options for listing admin users
|
||||||
|
type AdminListUsersOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// AdminListUsers lists all users
|
// AdminListUsers lists all users
|
||||||
func (c *Client) AdminListUsers() ([]*User, error) {
|
func (c *Client) AdminListUsers(opt AdminListUsersOptions) ([]*User, error) {
|
||||||
users := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return users, c.getParsedResponse("GET", "/admin/users", nil, nil, &users)
|
users := make([]*User, 0, opt.PageSize)
|
||||||
|
return users, c.getParsedResponse("GET", fmt.Sprintf("/admin/users?%s", opt.getURLQuery().Encode()), nil, nil, &users)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateUserOption create user options
|
// CreateUserOption create user options
|
||||||
|
|
|
@ -24,11 +24,17 @@ type Attachment struct {
|
||||||
DownloadURL string `json:"browser_download_url"`
|
DownloadURL string `json:"browser_download_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListReleaseAttachmentsOptions options for listing release's attachments
|
||||||
|
type ListReleaseAttachmentsOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListReleaseAttachments list release's attachments
|
// ListReleaseAttachments list release's attachments
|
||||||
func (c *Client) ListReleaseAttachments(user, repo string, release int64) ([]*Attachment, error) {
|
func (c *Client) ListReleaseAttachments(user, repo string, release int64, opt ListReleaseAttachmentsOptions) ([]*Attachment, error) {
|
||||||
attachments := make([]*Attachment, 0, 10)
|
opt.setDefaults()
|
||||||
|
attachments := make([]*Attachment, 0, opt.PageSize)
|
||||||
err := c.getParsedResponse("GET",
|
err := c.getParsedResponse("GET",
|
||||||
fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release),
|
fmt.Sprintf("/repos/%s/%s/releases/%d/assets?%s", user, repo, release, opt.getURLQuery().Encode()),
|
||||||
nil, nil, &attachments)
|
nil, nil, &attachments)
|
||||||
return attachments, err
|
return attachments, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,18 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ListForksOptions options for listing repository's forks
|
||||||
|
type ListForksOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListForks list a repository's forks
|
// ListForks list a repository's forks
|
||||||
func (c *Client) ListForks(user, repo string) ([]*Repository, error) {
|
func (c *Client) ListForks(user string, repo string, opt ListForksOptions) ([]*Repository, error) {
|
||||||
forks := make([]*Repository, 10)
|
opt.setDefaults()
|
||||||
return forks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/forks", user, repo), nil, nil, &forks)
|
forks := make([]*Repository, opt.PageSize)
|
||||||
|
return forks, c.getParsedResponse("GET",
|
||||||
|
fmt.Sprintf("/repos/%s/%s/forks?%s", user, repo, opt.getURLQuery().Encode()),
|
||||||
|
nil, nil, &forks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateForkOption options for creating a fork
|
// CreateForkOption options for creating a fork
|
||||||
|
|
|
@ -17,10 +17,16 @@ type GitHook struct {
|
||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRepoGitHooksOptions options for listing repository's githooks
|
||||||
|
type ListRepoGitHooksOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListRepoGitHooks list all the Git hooks of one repository
|
// ListRepoGitHooks list all the Git hooks of one repository
|
||||||
func (c *Client) ListRepoGitHooks(user, repo string) ([]*GitHook, error) {
|
func (c *Client) ListRepoGitHooks(user, repo string, opt ListRepoGitHooksOptions) ([]*GitHook, error) {
|
||||||
hooks := make([]*GitHook, 0, 10)
|
opt.setDefaults()
|
||||||
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git", user, repo), nil, nil, &hooks)
|
hooks := make([]*GitHook, 0, opt.PageSize)
|
||||||
|
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoGitHook get a Git hook of a repository
|
// GetRepoGitHook get a Git hook of a repository
|
||||||
|
|
|
@ -24,16 +24,23 @@ type Hook struct {
|
||||||
Created time.Time `json:"created_at"`
|
Created time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListHooksOptions options for listing hooks
|
||||||
|
type ListHooksOptions struct {
|
||||||
6543 marked this conversation as resolved
|
|||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListOrgHooks list all the hooks of one organization
|
// ListOrgHooks list all the hooks of one organization
|
||||||
func (c *Client) ListOrgHooks(org string) ([]*Hook, error) {
|
func (c *Client) ListOrgHooks(org string, opt ListHooksOptions) ([]*Hook, error) {
|
||||||
hooks := make([]*Hook, 0, 10)
|
opt.setDefaults()
|
||||||
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks)
|
hooks := make([]*Hook, 0, opt.PageSize)
|
||||||
|
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks?%s", org, opt.getURLQuery().Encode()), nil, nil, &hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoHooks list all the hooks of one repository
|
// ListRepoHooks list all the hooks of one repository
|
||||||
func (c *Client) ListRepoHooks(user, repo string) ([]*Hook, error) {
|
func (c *Client) ListRepoHooks(user, repo string, opt ListHooksOptions) ([]*Hook, error) {
|
||||||
hooks := make([]*Hook, 0, 10)
|
opt.setDefaults()
|
||||||
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks)
|
hooks := make([]*Hook, 0, opt.PageSize)
|
||||||
|
return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrgHook get a hook of an organization
|
// GetOrgHook get a hook of an organization
|
||||||
|
|
|
@ -55,7 +55,7 @@ type Issue struct {
|
||||||
|
|
||||||
// ListIssueOption list issue options
|
// ListIssueOption list issue options
|
||||||
type ListIssueOption struct {
|
type ListIssueOption struct {
|
||||||
Page int
|
ListOptions
|
||||||
State StateType
|
State StateType
|
||||||
Labels []string
|
Labels []string
|
||||||
KeyWord string
|
KeyWord string
|
||||||
|
@ -75,10 +75,7 @@ const (
|
||||||
|
|
||||||
// QueryEncode turns options into querystring argument
|
// QueryEncode turns options into querystring argument
|
||||||
func (opt *ListIssueOption) QueryEncode() string {
|
func (opt *ListIssueOption) QueryEncode() string {
|
||||||
query := make(url.Values)
|
query := opt.getURLQuery()
|
||||||
if opt.Page > 0 {
|
|
||||||
query.Add("page", fmt.Sprintf("%d", opt.Page))
|
|
||||||
}
|
|
||||||
if len(opt.State) > 0 {
|
if len(opt.State) > 0 {
|
||||||
query.Add("state", string(opt.State))
|
query.Add("state", string(opt.State))
|
||||||
}
|
}
|
||||||
|
@ -101,8 +98,10 @@ func (opt *ListIssueOption) QueryEncode() string {
|
||||||
|
|
||||||
// ListIssues returns all issues assigned the authenticated user
|
// ListIssues returns all issues assigned the authenticated user
|
||||||
func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) {
|
func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) {
|
||||||
|
opt.setDefaults()
|
||||||
|
issues := make([]*Issue, 0, opt.PageSize)
|
||||||
|
|
||||||
link, _ := url.Parse("/repos/issues/search")
|
link, _ := url.Parse("/repos/issues/search")
|
||||||
issues := make([]*Issue, 0, 10)
|
|
||||||
link.RawQuery = opt.QueryEncode()
|
link.RawQuery = opt.QueryEncode()
|
||||||
err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues)
|
err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues)
|
||||||
if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil {
|
if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil {
|
||||||
|
@ -117,9 +116,11 @@ func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) {
|
||||||
|
|
||||||
// ListRepoIssues returns all issues for a given repository
|
// ListRepoIssues returns all issues for a given repository
|
||||||
func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) {
|
func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) {
|
||||||
|
opt.setDefaults()
|
||||||
|
issues := make([]*Issue, 0, opt.PageSize)
|
||||||
|
|
||||||
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues", owner, repo))
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues", owner, repo))
|
||||||
link.RawQuery = opt.QueryEncode()
|
link.RawQuery = opt.QueryEncode()
|
||||||
issues := make([]*Issue, 0, 10)
|
|
||||||
err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues)
|
err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues)
|
||||||
if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil {
|
if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil {
|
||||||
for i := 0; i < len(issues); i++ {
|
for i := 0; i < len(issues); i++ {
|
||||||
|
|
|
@ -28,13 +28,14 @@ type Comment struct {
|
||||||
|
|
||||||
// ListIssueCommentOptions list comment options
|
// ListIssueCommentOptions list comment options
|
||||||
type ListIssueCommentOptions struct {
|
type ListIssueCommentOptions struct {
|
||||||
|
ListOptions
|
||||||
Since time.Time
|
Since time.Time
|
||||||
Before time.Time
|
Before time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryEncode turns options into querystring argument
|
// QueryEncode turns options into querystring argument
|
||||||
func (opt *ListIssueCommentOptions) QueryEncode() string {
|
func (opt *ListIssueCommentOptions) QueryEncode() string {
|
||||||
6543 marked this conversation as resolved
6543
commented
can you use ListIssueCommentsOptions for ListRepoIssueComments too? can you use **ListIssueCommentsOptions** for ListRepoIssueComments too?
|
|||||||
query := make(url.Values)
|
query := opt.getURLQuery()
|
||||||
if !opt.Since.IsZero() {
|
if !opt.Since.IsZero() {
|
||||||
query.Add("since", opt.Since.Format(time.RFC3339))
|
query.Add("since", opt.Since.Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
|
@ -46,17 +47,19 @@ func (opt *ListIssueCommentOptions) QueryEncode() string {
|
||||||
|
|
||||||
// ListIssueComments list comments on an issue.
|
// ListIssueComments list comments on an issue.
|
||||||
func (c *Client) ListIssueComments(owner, repo string, index int64, opt ListIssueCommentOptions) ([]*Comment, error) {
|
func (c *Client) ListIssueComments(owner, repo string, index int64, opt ListIssueCommentOptions) ([]*Comment, error) {
|
||||||
|
opt.setDefaults()
|
||||||
6543 marked this conversation as resolved
6543
commented
why make this function unusable for gitea instances below 1.12.0 ?!? why make this function unusable for gitea instances below 1.12.0 ?!?
spawn2kill
commented
fixed fixed
|
|||||||
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index))
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index))
|
||||||
link.RawQuery = opt.QueryEncode()
|
link.RawQuery = opt.QueryEncode()
|
||||||
comments := make([]*Comment, 0, 10)
|
comments := make([]*Comment, 0, opt.PageSize)
|
||||||
return comments, c.getParsedResponse("GET", link.String(), nil, nil, &comments)
|
return comments, c.getParsedResponse("GET", link.String(), nil, nil, &comments)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoIssueComments list comments for a given repo.
|
// ListRepoIssueComments list comments for a given repo.
|
||||||
func (c *Client) ListRepoIssueComments(owner, repo string, opt ListIssueCommentOptions) ([]*Comment, error) {
|
func (c *Client) ListRepoIssueComments(owner, repo string, opt ListIssueCommentOptions) ([]*Comment, error) {
|
||||||
|
opt.setDefaults()
|
||||||
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo))
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo))
|
||||||
link.RawQuery = opt.QueryEncode()
|
link.RawQuery = opt.QueryEncode()
|
||||||
comments := make([]*Comment, 0, 10)
|
comments := make([]*Comment, 0, opt.PageSize)
|
||||||
return comments, c.getParsedResponse("GET", link.String(), nil, nil, &comments)
|
return comments, c.getParsedResponse("GET", link.String(), nil, nil, &comments)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,16 @@ type Label struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListLabelsOptions options for listing repository's labels
|
||||||
|
type ListLabelsOptions struct {
|
||||||
6543 marked this conversation as resolved
6543
commented
ListLabelsOptions for ListRepoLabels() and GetIssueLabels() ListLabelsOptions for ListRepoLabels() and GetIssueLabels()
|
|||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListRepoLabels list labels of one repository
|
// ListRepoLabels list labels of one repository
|
||||||
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
|
func (c *Client) ListRepoLabels(owner, repo string, opt ListLabelsOptions) ([]*Label, error) {
|
||||||
labels := make([]*Label, 0, 10)
|
opt.setDefaults()
|
||||||
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
|
labels := make([]*Label, 0, opt.PageSize)
|
||||||
|
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels?%s", owner, repo, opt.getURLQuery().Encode()), nil, nil, &labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoLabel get one label of repository by repo it
|
// GetRepoLabel get one label of repository by repo it
|
||||||
|
@ -77,9 +83,9 @@ func (c *Client) DeleteLabel(owner, repo string, id int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIssueLabels get labels of one issue via issue id
|
// GetIssueLabels get labels of one issue via issue id
|
||||||
func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) {
|
func (c *Client) GetIssueLabels(owner, repo string, index int64, opts ListLabelsOptions) ([]*Label, error) {
|
||||||
labels := make([]*Label, 0, 5)
|
labels := make([]*Label, 0, 5)
|
||||||
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels)
|
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels?%s", owner, repo, index, opts.getURLQuery().Encode()), nil, nil, &labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IssueLabelsOption a collection of labels
|
// IssueLabelsOption a collection of labels
|
||||||
|
|
|
@ -33,13 +33,7 @@ type ListMilestoneOption struct {
|
||||||
|
|
||||||
// QueryEncode turns options into querystring argument
|
// QueryEncode turns options into querystring argument
|
||||||
func (opt *ListMilestoneOption) QueryEncode() string {
|
func (opt *ListMilestoneOption) QueryEncode() string {
|
||||||
query := make(url.Values)
|
query := opt.getURLQuery()
|
||||||
if opt.Page > 0 {
|
|
||||||
query.Add("page", fmt.Sprintf("%d", opt.Page))
|
|
||||||
}
|
|
||||||
if opt.PageSize > 0 {
|
|
||||||
query.Add("limit", fmt.Sprintf("%d", opt.PageSize))
|
|
||||||
}
|
|
||||||
if opt.State != "" {
|
if opt.State != "" {
|
||||||
query.Add("state", string(opt.State))
|
query.Add("state", string(opt.State))
|
||||||
}
|
}
|
||||||
|
@ -48,9 +42,11 @@ func (opt *ListMilestoneOption) QueryEncode() string {
|
||||||
|
|
||||||
// ListRepoMilestones list all the milestones of one repository
|
// ListRepoMilestones list all the milestones of one repository
|
||||||
func (c *Client) ListRepoMilestones(owner, repo string, opt ListMilestoneOption) ([]*Milestone, error) {
|
func (c *Client) ListRepoMilestones(owner, repo string, opt ListMilestoneOption) ([]*Milestone, error) {
|
||||||
|
opt.setDefaults()
|
||||||
|
milestones := make([]*Milestone, 0, opt.PageSize)
|
||||||
|
|
||||||
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/milestones", owner, repo))
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/milestones", owner, repo))
|
||||||
link.RawQuery = opt.QueryEncode()
|
link.RawQuery = opt.QueryEncode()
|
||||||
milestones := make([]*Milestone, 0, 10)
|
|
||||||
return milestones, c.getParsedResponse("GET", link.String(), nil, nil, &milestones)
|
return milestones, c.getParsedResponse("GET", link.String(), nil, nil, &milestones)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ func TestIssue(t *testing.T) {
|
||||||
c := newTestClient()
|
c := newTestClient()
|
||||||
|
|
||||||
createIssue(t, c)
|
createIssue(t, c)
|
||||||
|
// Little sleep in order to give some time for gitea to properly store all information on database. Without this sleep, CI is a bit unstable
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
editIssues(t, c)
|
editIssues(t, c)
|
||||||
listIssues(t, c)
|
listIssues(t, c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,6 @@ func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, error)
|
||||||
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×)
|
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListTrackedTimes list tracked times of a single issue for a given repository
|
|
||||||
func (c *Client) ListTrackedTimes(owner, repo string, index int64) ([]*TrackedTime, error) {
|
|
||||||
times := make([]*TrackedTime, 0, 10)
|
|
||||||
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, ×)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMyTrackedTimes list tracked times of the current user
|
// GetMyTrackedTimes list tracked times of the current user
|
||||||
func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, error) {
|
func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, error) {
|
||||||
times := make([]*TrackedTime, 0, 10)
|
times := make([]*TrackedTime, 0, 10)
|
||||||
|
@ -70,6 +64,18 @@ func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*T
|
||||||
jsonHeader, bytes.NewReader(body), t)
|
jsonHeader, bytes.NewReader(body), t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListTrackedTimesOptions options for listing repository's tracked times
|
||||||
|
type ListTrackedTimesOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTrackedTimes list tracked times of a single issue for a given repository
|
||||||
|
func (c *Client) ListTrackedTimes(owner, repo string, index int64, opt ListTrackedTimesOptions) ([]*TrackedTime, error) {
|
||||||
|
opt.setDefaults()
|
||||||
|
times := make([]*TrackedTime, 0, opt.PageSize)
|
||||||
|
return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times?%s", owner, repo, index, opt.getURLQuery().Encode()), nil, nil, ×)
|
||||||
|
}
|
||||||
|
|
||||||
// ResetIssueTime reset tracked time of a single issue for a given repository
|
// ResetIssueTime reset tracked time of a single issue for a given repository
|
||||||
func (c *Client) ResetIssueTime(owner, repo string, index int64) error {
|
func (c *Client) ResetIssueTime(owner, repo string, index int64) error {
|
||||||
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil)
|
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil)
|
||||||
|
|
|
@ -4,8 +4,34 @@
|
||||||
|
|
||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaultPageSize = 10
|
||||||
|
const maxPageSize = 50
|
||||||
|
|
||||||
6543
commented
useles function you always can use useles function you always can use `getURLQuery().Encode()` instead
|
|||||||
// ListOptions options for using Gitea's API pagination
|
// ListOptions options for using Gitea's API pagination
|
||||||
type ListOptions struct {
|
type ListOptions struct {
|
||||||
Page int
|
Page int
|
||||||
6543 marked this conversation as resolved
6543
commented
why differ from why differ from `models/list_options.go` struct ?
spawn2kill
commented
fixed fixed
|
|||||||
PageSize int
|
PageSize int
|
||||||
}
|
}
|
||||||
6543 marked this conversation as resolved
6543
commented
i would not implicit setDefaults as you have it explicit on each function anyway (give more indifidual control to each api call function) i would not implicit setDefaults as you have it explicit on each function anyway (give more indifidual control to each api call function)
spawn2kill
commented
fixed fixed
|
|||||||
|
|
||||||
|
func (o ListOptions) getURLQuery() url.Values {
|
||||||
|
query := make(url.Values)
|
||||||
|
query.Add("page", fmt.Sprintf("%d", o.Page))
|
||||||
|
query.Add("limit", fmt.Sprintf("%d", o.PageSize))
|
||||||
|
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o ListOptions) setDefaults() {
|
||||||
|
if o.Page < 1 {
|
||||||
|
o.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
6543 marked this conversation as resolved
6543
commented
can you add a varialbe on the beginging of can you add a varialbe on the beginging of `gitea/list_options.go` witch contain this vaule (50)?
spawn2kill
commented
fixed fixed
|
|||||||
|
if o.PageSize < 0 || o.PageSize > maxPageSize {
|
||||||
|
o.PageSize = defaultPageSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
19
gitea/org.go
|
@ -23,16 +23,23 @@ type Organization struct {
|
||||||
Visibility string `json:"visibility"`
|
Visibility string `json:"visibility"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListOrgsOptions options for listing organizations
|
||||||
|
type ListOrgsOptions struct {
|
||||||
6543 marked this conversation as resolved
6543
commented
can you let can you let `ListMyOrgs()` and `ListUserOrgs()` use `ListOrgsOptions` ?
spawn2kill
commented
fixed fixed
|
|||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListMyOrgs list all of current user's organizations
|
// ListMyOrgs list all of current user's organizations
|
||||||
func (c *Client) ListMyOrgs() ([]*Organization, error) {
|
func (c *Client) ListMyOrgs(opt ListOrgsOptions) ([]*Organization, error) {
|
||||||
orgs := make([]*Organization, 0, 5)
|
opt.setDefaults()
|
||||||
return orgs, c.getParsedResponse("GET", "/user/orgs", nil, nil, &orgs)
|
orgs := make([]*Organization, 0, opt.PageSize)
|
||||||
|
return orgs, c.getParsedResponse("GET", fmt.Sprintf("/user/orgs?%s", opt.getURLQuery().Encode()), nil, nil, &orgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListUserOrgs list all of some user's organizations
|
// ListUserOrgs list all of some user's organizations
|
||||||
func (c *Client) ListUserOrgs(user string) ([]*Organization, error) {
|
func (c *Client) ListUserOrgs(user string, opt ListOrgsOptions) ([]*Organization, error) {
|
||||||
orgs := make([]*Organization, 0, 5)
|
opt.setDefaults()
|
||||||
return orgs, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/orgs", user), nil, nil, &orgs)
|
orgs := make([]*Organization, 0, opt.PageSize)
|
||||||
|
return orgs, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/orgs?%s", user, opt.getURLQuery().Encode()), nil, nil, &orgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrg get one organization by name
|
// GetOrg get one organization by name
|
||||||
|
|
|
@ -22,16 +22,23 @@ type Team struct {
|
||||||
Units []string `json:"units"`
|
Units []string `json:"units"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListTeamsOptions options for listing teams
|
||||||
|
type ListTeamsOptions struct {
|
||||||
6543 marked this conversation as resolved
6543
commented
same here -> ListTeamsOptions for ListOrgTeams() & ListMyTeams() same here -> ListTeamsOptions for ListOrgTeams() & ListMyTeams()
spawn2kill
commented
fixed fixed
|
|||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListOrgTeams lists all teams of an organization
|
// ListOrgTeams lists all teams of an organization
|
||||||
func (c *Client) ListOrgTeams(org string) ([]*Team, error) {
|
func (c *Client) ListOrgTeams(org string, opt ListTeamsOptions) ([]*Team, error) {
|
||||||
teams := make([]*Team, 0, 10)
|
opt.setDefaults()
|
||||||
return teams, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/teams", org), nil, nil, &teams)
|
teams := make([]*Team, 0, opt.PageSize)
|
||||||
|
return teams, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/teams?%s", org, opt.getURLQuery().Encode()), nil, nil, &teams)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyTeams lists all the teams of the current user
|
// ListMyTeams lists all the teams of the current user
|
||||||
func (c *Client) ListMyTeams() ([]*Team, error) {
|
func (c *Client) ListMyTeams(opt *ListTeamsOptions) ([]*Team, error) {
|
||||||
teams := make([]*Team, 0, 10)
|
opt.setDefaults()
|
||||||
return teams, c.getParsedResponse("GET", "/user/teams", nil, nil, &teams)
|
teams := make([]*Team, 0, opt.PageSize)
|
||||||
|
return teams, c.getParsedResponse("GET", fmt.Sprintf("/user/teams?%s", opt.getURLQuery().Encode()), nil, nil, &teams)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTeam gets a team by ID
|
// GetTeam gets a team by ID
|
||||||
|
@ -86,10 +93,16 @@ func (c *Client) DeleteTeam(id int64) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListTeamMembersOptions options for listing team's members
|
||||||
|
type ListTeamMembersOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListTeamMembers lists all members of a team
|
// ListTeamMembers lists all members of a team
|
||||||
func (c *Client) ListTeamMembers(id int64) ([]*User, error) {
|
func (c *Client) ListTeamMembers(id int64, opt ListTeamMembersOptions) ([]*User, error) {
|
||||||
members := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return members, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/members", id), nil, nil, &members)
|
members := make([]*User, 0, opt.PageSize)
|
||||||
|
return members, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/members?%s", id, opt.getURLQuery().Encode()), nil, nil, &members)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTeamMember gets a member of a team
|
// GetTeamMember gets a member of a team
|
||||||
|
@ -110,10 +123,16 @@ func (c *Client) RemoveTeamMember(id int64, user string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListTeamRepositoriesOptions options for listing team's repositories
|
||||||
|
type ListTeamRepositoriesOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListTeamRepositories lists all repositories of a team
|
// ListTeamRepositories lists all repositories of a team
|
||||||
func (c *Client) ListTeamRepositories(id int64) ([]*Repository, error) {
|
func (c *Client) ListTeamRepositories(id int64, opt ListTeamRepositoriesOptions) ([]*Repository, error) {
|
||||||
repos := make([]*Repository, 0, 10)
|
opt.setDefaults()
|
||||||
return repos, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/repos", id), nil, nil, &repos)
|
repos := make([]*Repository, 0, opt.PageSize)
|
||||||
|
return repos, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/repos?%s", id, opt.getURLQuery().Encode()), nil, nil, &repos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddTeamRepository adds a repository to a team
|
// AddTeamRepository adds a repository to a team
|
||||||
|
|
|
@ -59,23 +59,16 @@ type PullRequest struct {
|
||||||
|
|
||||||
// ListPullRequestsOptions options for listing pull requests
|
// ListPullRequestsOptions options for listing pull requests
|
||||||
type ListPullRequestsOptions struct {
|
type ListPullRequestsOptions struct {
|
||||||
Page int `json:"page"`
|
ListOptions
|
||||||
6543 marked this conversation as resolved
6543
commented
just use just use `ListOptions`
spawn2kill
commented
fixed fixed
|
|||||||
State StateType `json:"state"`
|
State StateType `json:"state"`
|
||||||
// oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority
|
// oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority
|
||||||
Sort string `json:"sort"`
|
Sort string
|
||||||
Milestone int64 `json:"milestone"`
|
Milestone int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoPullRequests list PRs of one repository
|
// QueryEncode turns options into querystring argument
|
||||||
func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) {
|
func (opt *ListPullRequestsOptions) QueryEncode() string {
|
||||||
// declare variables
|
query := opt.getURLQuery()
|
||||||
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/pulls", owner, repo))
|
|
||||||
prs := make([]*PullRequest, 0, 10)
|
|
||||||
query := make(url.Values)
|
|
||||||
// add options to query
|
|
||||||
if opt.Page > 0 {
|
|
||||||
query.Add("page", fmt.Sprintf("%d", opt.Page))
|
|
||||||
}
|
|
||||||
if len(opt.State) > 0 {
|
if len(opt.State) > 0 {
|
||||||
query.Add("state", string(opt.State))
|
query.Add("state", string(opt.State))
|
||||||
}
|
}
|
||||||
|
@ -85,8 +78,16 @@ func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOp
|
||||||
if opt.Milestone > 0 {
|
if opt.Milestone > 0 {
|
||||||
query.Add("milestone", fmt.Sprintf("%d", opt.Milestone))
|
query.Add("milestone", fmt.Sprintf("%d", opt.Milestone))
|
||||||
}
|
}
|
||||||
link.RawQuery = query.Encode()
|
return query.Encode()
|
||||||
// request
|
}
|
||||||
|
|
||||||
|
// ListRepoPullRequests list PRs of one repository
|
||||||
|
func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) {
|
||||||
|
opt.setDefaults()
|
||||||
|
prs := make([]*PullRequest, 0, opt.PageSize)
|
||||||
|
|
||||||
|
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/pulls", owner, repo))
|
||||||
|
link.RawQuery = opt.QueryEncode()
|
||||||
return prs, c.getParsedResponse("GET", link.String(), jsonHeader, nil, &prs)
|
return prs, c.getParsedResponse("GET", link.String(), jsonHeader, nil, &prs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ func TestPull(t *testing.T) {
|
||||||
|
|
||||||
// ListRepoPullRequests list PRs of one repository
|
// ListRepoPullRequests list PRs of one repository
|
||||||
pulls, err := c.ListRepoPullRequests(user.UserName, repoName, ListPullRequestsOptions{
|
pulls, err := c.ListRepoPullRequests(user.UserName, repoName, ListPullRequestsOptions{
|
||||||
Page: 1,
|
ListOptions: ListOptions{Page: 1},
|
||||||
State: StateAll,
|
State: StateAll,
|
||||||
Sort: "leastupdate",
|
Sort: "leastupdate",
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, pulls, 0)
|
assert.Len(t, pulls, 0)
|
||||||
|
|
|
@ -29,11 +29,17 @@ type Release struct {
|
||||||
Attachments []*Attachment `json:"assets"`
|
Attachments []*Attachment `json:"assets"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListReleasesOptions options for listing repository's releases
|
||||||
|
type ListReleasesOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListReleases list releases of a repository
|
// ListReleases list releases of a repository
|
||||||
func (c *Client) ListReleases(user, repo string) ([]*Release, error) {
|
func (c *Client) ListReleases(user, repo string, opt ListReleasesOptions) ([]*Release, error) {
|
||||||
releases := make([]*Release, 0, 10)
|
opt.setDefaults()
|
||||||
|
releases := make([]*Release, 0, opt.PageSize)
|
||||||
err := c.getParsedResponse("GET",
|
err := c.getParsedResponse("GET",
|
||||||
fmt.Sprintf("/repos/%s/%s/releases", user, repo),
|
fmt.Sprintf("/repos/%s/%s/releases?%s", user, repo, opt.getURLQuery().Encode()),
|
||||||
nil, nil, &releases)
|
nil, nil, &releases)
|
||||||
return releases, err
|
return releases, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,26 +57,40 @@ type Repository struct {
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListReposOptions options for listing repositories
|
||||||
6543 marked this conversation as resolved
6543
commented
ListReposOptions ... for ListMyRepos() ListUserRepos() ListOrgReposOptions() ListReposOptions ... for ListMyRepos() ListUserRepos() ListOrgReposOptions()
spawn2kill
commented
fixed fixed
|
|||||||
|
type ListReposOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
||||||
func (c *Client) ListMyRepos() ([]*Repository, error) {
|
func (c *Client) ListMyRepos(opt ListReposOptions) ([]*Repository, error) {
|
||||||
6543 marked this conversation as resolved
6543
commented
`opt *ListReposOptions` -> `opt ListReposOptions`
|
|||||||
repos := make([]*Repository, 0, 10)
|
opt.setDefaults()
|
||||||
return repos, c.getParsedResponse("GET", "/user/repos", nil, nil, &repos)
|
repos := make([]*Repository, 0, opt.PageSize)
|
||||||
|
return repos, c.getParsedResponse("GET", fmt.Sprintf("/user/repos?%s", opt.getURLQuery().Encode()), nil, nil, &repos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListUserRepos list all repositories of one user by user's name
|
// ListUserRepos list all repositories of one user by user's name
|
||||||
func (c *Client) ListUserRepos(user string) ([]*Repository, error) {
|
func (c *Client) ListUserRepos(user string, opt ListReposOptions) ([]*Repository, error) {
|
||||||
repos := make([]*Repository, 0, 10)
|
opt.setDefaults()
|
||||||
return repos, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/repos", user), nil, nil, &repos)
|
repos := make([]*Repository, 0, opt.PageSize)
|
||||||
|
return repos, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/repos?%s", user, opt.getURLQuery().Encode()), nil, nil, &repos)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrgReposOptions options for a organization's repositories
|
||||||
|
type ListOrgReposOptions struct {
|
||||||
|
ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListOrgRepos list all repositories of one organization by organization's name
|
// ListOrgRepos list all repositories of one organization by organization's name
|
||||||
func (c *Client) ListOrgRepos(org string) ([]*Repository, error) {
|
func (c *Client) ListOrgRepos(org string, opt ListOrgReposOptions) ([]*Repository, error) {
|
||||||
repos := make([]*Repository, 0, 10)
|
opt.setDefaults()
|
||||||
return repos, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/repos", org), nil, nil, &repos)
|
repos := make([]*Repository, 0, opt.PageSize)
|
||||||
|
return repos, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/repos?%s", org, opt.getURLQuery().Encode()), nil, nil, &repos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchRepoOptions options for searching repositories
|
// SearchRepoOptions options for searching repositories
|
||||||
type SearchRepoOptions struct {
|
type SearchRepoOptions struct {
|
||||||
|
ListOptions
|
||||||
Keyword string
|
Keyword string
|
||||||
Topic bool
|
Topic bool
|
||||||
IncludeDesc bool
|
IncludeDesc bool
|
||||||
|
@ -92,7 +106,7 @@ type SearchRepoOptions struct {
|
||||||
|
|
||||||
// QueryEncode turns options into querystring argument
|
// QueryEncode turns options into querystring argument
|
||||||
func (opt *SearchRepoOptions) QueryEncode() string {
|
func (opt *SearchRepoOptions) QueryEncode() string {
|
||||||
query := make(url.Values)
|
query := opt.getURLQuery()
|
||||||
if opt.Keyword != "" {
|
if opt.Keyword != "" {
|
||||||
query.Add("q", opt.Keyword)
|
query.Add("q", opt.Keyword)
|
||||||
}
|
}
|
||||||
|
@ -134,6 +148,7 @@ type searchRepoResponse struct {
|
||||||
|
|
||||||
// SearchRepos searches for repositories matching the given filters
|
// SearchRepos searches for repositories matching the given filters
|
||||||
func (c *Client) SearchRepos(opt SearchRepoOptions) ([]*Repository, error) {
|
func (c *Client) SearchRepos(opt SearchRepoOptions) ([]*Repository, error) {
|
||||||
|
opt.setDefaults()
|
||||||
resp := new(searchRepoResponse)
|
resp := new(searchRepoResponse)
|
||||||
|
|
||||||
link, _ := url.Parse("/repos/search")
|
link, _ := url.Parse("/repos/search")
|
||||||
|
|
|
@ -49,10 +49,16 @@ type Branch struct {
|
||||||
Commit *PayloadCommit `json:"commit"`
|
Commit *PayloadCommit `json:"commit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRepoBranchesOptions options for listing a repository's branches
|
||||||
|
type ListRepoBranchesOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListRepoBranches list all the branches of one repository
|
// ListRepoBranches list all the branches of one repository
|
||||||
func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) {
|
func (c *Client) ListRepoBranches(user, repo string, opt ListRepoBranchesOptions) ([]*Branch, error) {
|
||||||
branches := make([]*Branch, 0, 10)
|
opt.setDefaults()
|
||||||
return branches, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches", user, repo), nil, nil, &branches)
|
branches := make([]*Branch, 0, opt.PageSize)
|
||||||
|
return branches, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &branches)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoBranch get one branch's information of one repository
|
// GetRepoBranch get one branch's information of one repository
|
||||||
|
|
|
@ -10,10 +10,18 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ListCollaboratorsOptions options for listing a repository's collaborators
|
||||||
|
type ListCollaboratorsOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListCollaborators list a repository's collaborators
|
// ListCollaborators list a repository's collaborators
|
||||||
func (c *Client) ListCollaborators(user, repo string) ([]*User, error) {
|
func (c *Client) ListCollaborators(user, repo string, opt ListCollaboratorsOptions) ([]*User, error) {
|
||||||
collaborators := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return collaborators, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), nil, nil, &collaborators)
|
collaborators := make([]*User, 0, opt.PageSize)
|
||||||
|
return collaborators, c.getParsedResponse("GET",
|
||||||
|
fmt.Sprintf("/repos/%s/%s/collaborators?%s", user, repo, opt.getURLQuery().Encode()),
|
||||||
|
nil, nil, &collaborators)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCollaborator check if a user is a collaborator of a repository
|
// IsCollaborator check if a user is a collaborator of a repository
|
||||||
|
|
|
@ -24,10 +24,16 @@ type DeployKey struct {
|
||||||
Repository *Repository `json:"repository,omitempty"`
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListDeployKeysOptions options for listing a repository's deploy keys
|
||||||
|
type ListDeployKeysOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListDeployKeys list all the deploy keys of one repository
|
// ListDeployKeys list all the deploy keys of one repository
|
||||||
func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error) {
|
func (c *Client) ListDeployKeys(user, repo string, opt ListDeployKeysOptions) ([]*DeployKey, error) {
|
||||||
keys := make([]*DeployKey, 0, 10)
|
opt.setDefaults()
|
||||||
return keys, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys", user, repo), nil, nil, &keys)
|
keys := make([]*DeployKey, 0, opt.PageSize)
|
||||||
|
return keys, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeployKey get one deploy key with key id
|
// GetDeployKey get one deploy key with key id
|
||||||
|
|
|
@ -17,8 +17,14 @@ type Tag struct {
|
||||||
TarballURL string `json:"tarball_url"`
|
TarballURL string `json:"tarball_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoTags list all the branches of one repository
|
// ListRepoTagsOptions options for listing a repository's tags
|
||||||
func (c *Client) ListRepoTags(user, repo string) ([]*Tag, error) {
|
type ListRepoTagsOptions struct {
|
||||||
tags := make([]*Tag, 0, 10)
|
ListOptions
|
||||||
return tags, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tags", user, repo), nil, nil, &tags)
|
}
|
||||||
|
|
||||||
|
// ListRepoTags list all the branches of one repository
|
||||||
|
func (c *Client) ListRepoTags(user, repo string, opt ListRepoTagsOptions) ([]*Tag, error) {
|
||||||
|
opt.setDefaults()
|
||||||
|
tags := make([]*Tag, 0, opt.PageSize)
|
||||||
|
return tags, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tags?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &tags)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,22 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ListRepoTopicsOptions options for listing repo's topics
|
||||||
|
type ListRepoTopicsOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// TopicsList represents a list of repo's topics
|
// TopicsList represents a list of repo's topics
|
||||||
type TopicsList struct {
|
type TopicsList struct {
|
||||||
Topics []string `json:"topics"`
|
Topics []string `json:"topics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRepoTopics list all repository's topics
|
// ListRepoTopics list all repository's topics
|
||||||
func (c *Client) ListRepoTopics(user, repo string) (*TopicsList, error) {
|
func (c *Client) ListRepoTopics(user, repo string, opt ListRepoTopicsOptions) (*TopicsList, error) {
|
||||||
|
opt.setDefaults()
|
||||||
6543 marked this conversation as resolved
6543
commented
opt.setDefaults() opt.setDefaults()
|
|||||||
|
|
||||||
var list TopicsList
|
var list TopicsList
|
||||||
return &list, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/topics", user, repo), nil, nil, &list)
|
return &list, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/topics?%s", user, repo, opt.getURLQuery().Encode()), nil, nil, &list)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRepoTopics replaces the list of repo's topics
|
// SetRepoTopics replaces the list of repo's topics
|
||||||
|
|
|
@ -59,15 +59,16 @@ func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption)
|
||||||
return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status)
|
return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListStatusesOption holds pagination information
|
// ListStatusesOption options for listing a repository's commit's statuses
|
||||||
type ListStatusesOption struct {
|
type ListStatusesOption struct {
|
||||||
6543 marked this conversation as resolved
6543
commented
dont breake things if necesar!! rename dont breake things if necesar!!
rename `ListStatusesOptions` back to `ListStatusesOption`
|
|||||||
Page int
|
ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListStatuses returns all statuses for a given Commit
|
// ListStatuses returns all statuses for a given Commit
|
||||||
func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) ([]*Status, error) {
|
func (c *Client) ListStatuses(owner, repo, sha string, opt ListStatusesOption) ([]*Status, error) {
|
||||||
statuses := make([]*Status, 0, 10)
|
opt.setDefaults()
|
||||||
return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?page=%d", owner, repo, sha, opts.Page), nil, nil, &statuses)
|
statuses := make([]*Status, 0, opt.PageSize)
|
||||||
|
return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?%s", owner, repo, sha, opt.getURLQuery().Encode()), nil, nil, &statuses)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CombinedStatus holds the combined state of several statuses for a single commit
|
// CombinedStatus holds the combined state of several statuses for a single commit
|
||||||
|
|
|
@ -26,10 +26,16 @@ type AccessToken struct {
|
||||||
TokenLastEight string `json:"token_last_eight"`
|
TokenLastEight string `json:"token_last_eight"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListAccessTokens lista all the access tokens of user
|
// ListAccessTokensOptions options for listing a users's access tokens
|
||||||
func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
|
type ListAccessTokensOptions struct {
|
||||||
6543 marked this conversation as resolved
6543
commented
rename to ListAccessTokensOptions rename to ListAccessTokensOptions
|
|||||||
tokens := make([]*AccessToken, 0, 10)
|
ListOptions
|
||||||
return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens", user),
|
}
|
||||||
|
|
||||||
|
// ListAccessTokens lists all the access tokens of user
|
||||||
|
func (c *Client) ListAccessTokens(user, pass string, opts ListAccessTokensOptions) ([]*AccessToken, error) {
|
||||||
|
opts.setDefaults()
|
||||||
|
tokens := make([]*AccessToken, 0, opts.PageSize)
|
||||||
|
return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens?%s", user, opts.getURLQuery().Encode()),
|
||||||
http.Header{"Authorization": []string{"Basic " + basicAuthEncode(user, pass)}}, nil, &tokens)
|
http.Header{"Authorization": []string{"Basic " + basicAuthEncode(user, pass)}}, nil, &tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ package gitea
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Email an email address belonging to a user
|
// Email an email address belonging to a user
|
||||||
|
@ -16,10 +17,16 @@ type Email struct {
|
||||||
Primary bool `json:"primary"`
|
Primary bool `json:"primary"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListEmailsOptions options for listing current's user emails
|
||||||
|
type ListEmailsOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListEmails all the email addresses of user
|
// ListEmails all the email addresses of user
|
||||||
func (c *Client) ListEmails() ([]*Email, error) {
|
func (c *Client) ListEmails(opt ListEmailsOptions) ([]*Email, error) {
|
||||||
emails := make([]*Email, 0, 3)
|
opt.setDefaults()
|
||||||
return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails)
|
emails := make([]*Email, 0, opt.PageSize)
|
||||||
|
return emails, c.getParsedResponse("GET", fmt.Sprintf("/user/emails?%s", opt.getURLQuery().Encode()), nil, nil, &emails)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateEmailOption options when creating email addresses
|
// CreateEmailOption options when creating email addresses
|
||||||
|
|
|
@ -6,28 +6,42 @@ package gitea
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
// ListFollowersOptions options for listing followers
|
||||||
|
type ListFollowersOptions struct {
|
||||||
6543 marked this conversation as resolved
6543
commented
use ListFollowersOptions for ListMyFollowers() too use ListFollowersOptions for ListMyFollowers() too
spawn2kill
commented
fixed fixed
|
|||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListMyFollowers list all the followers of current user
|
// ListMyFollowers list all the followers of current user
|
||||||
func (c *Client) ListMyFollowers(page int) ([]*User, error) {
|
func (c *Client) ListMyFollowers(opt ListFollowersOptions) ([]*User, error) {
|
||||||
users := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return users, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?page=%d", page), nil, nil, &users)
|
users := make([]*User, 0, opt.PageSize)
|
||||||
|
return users, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?%s", opt.getURLQuery().Encode()), nil, nil, &users)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListFollowers list all the followers of one user
|
// ListFollowers list all the followers of one user
|
||||||
func (c *Client) ListFollowers(user string, page int) ([]*User, error) {
|
func (c *Client) ListFollowers(user string, opt ListFollowersOptions) ([]*User, error) {
|
||||||
users := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?page=%d", user, page), nil, nil, &users)
|
users := make([]*User, 0, opt.PageSize)
|
||||||
|
return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?%s", user, opt.getURLQuery().Encode()), nil, nil, &users)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListFollowingOptions options for listing a user's users being followed
|
||||||
|
type ListFollowingOptions struct {
|
||||||
|
ListOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyFollowing list all the users current user followed
|
// ListMyFollowing list all the users current user followed
|
||||||
func (c *Client) ListMyFollowing(page int) ([]*User, error) {
|
func (c *Client) ListMyFollowing(opt ListFollowingOptions) ([]*User, error) {
|
||||||
users := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users)
|
users := make([]*User, 0, opt.PageSize)
|
||||||
|
return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?%s", opt.getURLQuery().Encode()), nil, nil, &users)
|
||||||
}
|
}
|
||||||
|
|
||||||
6543 marked this conversation as resolved
6543
commented
use ListFollowingOptions for ListMyFollowing() too use ListFollowingOptions for ListMyFollowing() too
spawn2kill
commented
fixed fixed
|
|||||||
// ListFollowing list all the users the user followed
|
// ListFollowing list all the users the user followed
|
||||||
func (c *Client) ListFollowing(user string, page int) ([]*User, error) {
|
func (c *Client) ListFollowing(user string, opt ListFollowingOptions) ([]*User, error) {
|
||||||
users := make([]*User, 0, 10)
|
opt.setDefaults()
|
||||||
return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?page=%d", user, page), nil, nil, &users)
|
users := make([]*User, 0, opt.PageSize)
|
||||||
|
return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?%s", user, opt.getURLQuery().Encode()), nil, nil, &users)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsFollowing if current user followed the target
|
// IsFollowing if current user followed the target
|
||||||
|
|
|
@ -33,16 +33,23 @@ type GPGKeyEmail struct {
|
||||||
Verified bool `json:"verified"`
|
Verified bool `json:"verified"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListGPGKeysOptions options for listing a user's GPGKeys
|
||||||
|
type ListGPGKeysOptions struct {
|
||||||
6543 marked this conversation as resolved
spawn2kill
commented
fixed fixed
|
|||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListGPGKeys list all the GPG keys of the user
|
// ListGPGKeys list all the GPG keys of the user
|
||||||
func (c *Client) ListGPGKeys(user string) ([]*GPGKey, error) {
|
func (c *Client) ListGPGKeys(user string, opt ListGPGKeysOptions) ([]*GPGKey, error) {
|
||||||
keys := make([]*GPGKey, 0, 10)
|
opt.setDefaults()
|
||||||
return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/gpg_keys", user), nil, nil, &keys)
|
keys := make([]*GPGKey, 0, opt.PageSize)
|
||||||
|
return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/gpg_keys?%s", user, opt.getURLQuery().Encode()), nil, nil, &keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyGPGKeys list all the GPG keys of current user
|
// ListMyGPGKeys list all the GPG keys of current user
|
||||||
func (c *Client) ListMyGPGKeys() ([]*GPGKey, error) {
|
func (c *Client) ListMyGPGKeys(opt *ListGPGKeysOptions) ([]*GPGKey, error) {
|
||||||
6543 marked this conversation as resolved
6543
commented
use ListMyGPGKeysOption for ListMyGPGKeys() too use ListMyGPGKeysOption for ListMyGPGKeys() too
spawn2kill
commented
fixed fixed
|
|||||||
keys := make([]*GPGKey, 0, 10)
|
opt.setDefaults()
|
||||||
return keys, c.getParsedResponse("GET", "/user/gpg_keys", nil, nil, &keys)
|
keys := make([]*GPGKey, 0, opt.PageSize)
|
||||||
|
return keys, c.getParsedResponse("GET", fmt.Sprintf("/user/gpg_keys?%s", opt.getURLQuery().Encode()), nil, nil, &keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGPGKey get current user's GPG key by key id
|
// GetGPGKey get current user's GPG key by key id
|
||||||
|
|
|
@ -24,16 +24,23 @@ type PublicKey struct {
|
||||||
KeyType string `json:"key_type,omitempty"`
|
KeyType string `json:"key_type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListPublicKeysOptions options for listing a user's PublicKeys
|
||||||
|
type ListPublicKeysOptions struct {
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
// ListPublicKeys list all the public keys of the user
|
// ListPublicKeys list all the public keys of the user
|
||||||
func (c *Client) ListPublicKeys(user string) ([]*PublicKey, error) {
|
func (c *Client) ListPublicKeys(user string, opt ListPublicKeysOptions) ([]*PublicKey, error) {
|
||||||
keys := make([]*PublicKey, 0, 10)
|
opt.setDefaults()
|
||||||
return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/keys", user), nil, nil, &keys)
|
keys := make([]*PublicKey, 0, opt.PageSize)
|
||||||
|
return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/keys?%s", user, opt.getURLQuery().Encode()), nil, nil, &keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMyPublicKeys list all the public keys of current user
|
// ListMyPublicKeys list all the public keys of current user
|
||||||
func (c *Client) ListMyPublicKeys() ([]*PublicKey, error) {
|
func (c *Client) ListMyPublicKeys(opt ListPublicKeysOptions) ([]*PublicKey, error) {
|
||||||
keys := make([]*PublicKey, 0, 10)
|
opt.setDefaults()
|
||||||
return keys, c.getParsedResponse("GET", "/user/keys", nil, nil, &keys)
|
keys := make([]*PublicKey, 0, opt.PageSize)
|
||||||
|
return keys, c.getParsedResponse("GET", fmt.Sprintf("/user/keys?%s", opt.getURLQuery().Encode()), nil, nil, &keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
6543 marked this conversation as resolved
6543
commented
use ListPublicKeysOptions for ListMyPublicKeys() too use ListPublicKeysOptions for ListMyPublicKeys() too
spawn2kill
commented
fixed fixed
|
|||||||
// GetPublicKey get current user's public key by key id
|
// GetPublicKey get current user's public key by key id
|
||||||
|
|
|
@ -29,7 +29,7 @@ func TestUserApp(t *testing.T) {
|
||||||
log.Println("== TestUserApp ==")
|
log.Println("== TestUserApp ==")
|
||||||
c := newTestClient()
|
c := newTestClient()
|
||||||
|
|
||||||
result, err := c.ListAccessTokens(c.username, c.password)
|
result, err := c.ListAccessTokens(c.username, c.password, ListAccessTokensOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, result, 1)
|
assert.Len(t, result, 1)
|
||||||
assert.EqualValues(t, "gitea-admin", result[0].Name)
|
assert.EqualValues(t, "gitea-admin", result[0].Name)
|
||||||
|
@ -37,12 +37,12 @@ func TestUserApp(t *testing.T) {
|
||||||
t1, err := c.CreateAccessToken(c.username, c.password, CreateAccessTokenOption{Name: "TestCreateAccessToken"})
|
t1, err := c.CreateAccessToken(c.username, c.password, CreateAccessTokenOption{Name: "TestCreateAccessToken"})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "TestCreateAccessToken", t1.Name)
|
assert.EqualValues(t, "TestCreateAccessToken", t1.Name)
|
||||||
result, _ = c.ListAccessTokens(c.username, c.password)
|
result, _ = c.ListAccessTokens(c.username, c.password, ListAccessTokensOptions{})
|
||||||
assert.Len(t, result, 2)
|
assert.Len(t, result, 2)
|
||||||
|
|
||||||
err = c.DeleteAccessToken(c.username, c.password, t1.ID)
|
err = c.DeleteAccessToken(c.username, c.password, t1.ID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
result, _ = c.ListAccessTokens(c.username, c.password)
|
result, _ = c.ListAccessTokens(c.username, c.password, ListAccessTokensOptions{})
|
||||||
assert.Len(t, result, 1)
|
assert.Len(t, result, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,22 +107,22 @@ func TestUserFollow(t *testing.T) {
|
||||||
|
|
||||||
// ListMyFollowers of me
|
// ListMyFollowers of me
|
||||||
c.sudo = ""
|
c.sudo = ""
|
||||||
f, err := c.ListMyFollowers(1)
|
f, err := c.ListMyFollowers(ListFollowersOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, f, 2)
|
assert.Len(t, f, 2)
|
||||||
|
|
||||||
// ListFollowers of A
|
// ListFollowers of A
|
||||||
f, err = c.ListFollowers(uA, 1)
|
f, err = c.ListFollowers(uA, ListFollowersOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, f, 1)
|
assert.Len(t, f, 1)
|
||||||
|
|
||||||
// ListMyFollowing of me
|
// ListMyFollowing of me
|
||||||
f, err = c.ListMyFollowing(1)
|
f, err = c.ListMyFollowing(ListFollowingOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, f, 0)
|
assert.Len(t, f, 0)
|
||||||
|
|
||||||
// ListFollowing of A
|
// ListFollowing of A
|
||||||
f, err = c.ListFollowing(uA, 1)
|
f, err = c.ListFollowing(uA, ListFollowingOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, f, 1)
|
assert.Len(t, f, 1)
|
||||||
assert.EqualValues(t, me.ID, f[0].ID)
|
assert.EqualValues(t, me.ID, f[0].ID)
|
||||||
|
@ -139,7 +139,7 @@ func TestUserEmail(t *testing.T) {
|
||||||
c.sudo = userN
|
c.sudo = userN
|
||||||
|
|
||||||
// ListEmails
|
// ListEmails
|
||||||
el, err := c.ListEmails()
|
el, err := c.ListEmails(ListEmailsOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, el, 1)
|
assert.Len(t, el, 1)
|
||||||
assert.EqualValues(t, "testuseremail@gitea.io", el[0].Email)
|
assert.EqualValues(t, "testuseremail@gitea.io", el[0].Email)
|
||||||
|
@ -152,7 +152,7 @@ func TestUserEmail(t *testing.T) {
|
||||||
assert.Len(t, el, 2)
|
assert.Len(t, el, 2)
|
||||||
_, err = c.AddEmail(CreateEmailOption{Emails: []string{mails[1]}})
|
_, err = c.AddEmail(CreateEmailOption{Emails: []string{mails[1]}})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
el, err = c.ListEmails()
|
el, err = c.ListEmails(ListEmailsOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, el, 3)
|
assert.Len(t, el, 3)
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ func TestUserEmail(t *testing.T) {
|
||||||
err = c.DeleteEmail(DeleteEmailOption{Emails: []string{"imaginary@e.de"}})
|
err = c.DeleteEmail(DeleteEmailOption{Emails: []string{"imaginary@e.de"}})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
el, err = c.ListEmails()
|
el, err = c.ListEmails(ListEmailsOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, el, 2)
|
assert.Len(t, el, 2)
|
||||||
err = c.DeleteEmail(DeleteEmailOption{Emails: []string{mails[0]}})
|
err = c.DeleteEmail(DeleteEmailOption{Emails: []string{mails[0]}})
|
||||||
|
|
why not use ListHooksOptions for ListOrgHooks() and ListRepoHooks() ?
fixed