mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-01 08:47:40 -04:00
08069dc465
* add migrations * fix package dependency * fix lints * implements migrations except pull requests * add releases * migrating releases * fix bug * fix lint * fix migrate releases * fix tests * add rollback * pull request migtations * fix import * fix go module vendor * add tests for upload to gitea * more migrate options * fix swagger-check * fix misspell * add options on migration UI * fix log error * improve UI options on migrating * add support for username password when migrating from github * fix tests * remove comments and fix migrate limitation * improve error handles * migrate API will also support migrate milestones/labels/issues/pulls/releases * fix tests and remove unused codes * add DownloaderFactory and docs about how to create a new Downloader * fix misspell * fix migration docs * Add hints about migrate options on migration page * fix tests
216 lines
5.8 KiB
Go
216 lines
5.8 KiB
Go
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||
//
|
||
// Use of this source code is governed by a BSD-style
|
||
// license that can be found in the LICENSE file.
|
||
|
||
package github
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
)
|
||
|
||
// ListEvents drinks from the firehose of all public events across GitHub.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events
|
||
func (s *ActivityService) ListEvents(ctx context.Context, opt *ListOptions) ([]*Event, *Response, error) {
|
||
u, err := addOptions("events", opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListRepositoryEvents lists events for a repository.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-repository-events
|
||
func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opt *ListOptions) ([]*Event, *Response, error) {
|
||
u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListIssueEventsForRepository lists issue events for a repository.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
|
||
func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opt *ListOptions) ([]*IssueEvent, *Response, error) {
|
||
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*IssueEvent
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListEventsForRepoNetwork lists public events for a network of repositories.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories
|
||
func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opt *ListOptions) ([]*Event, *Response, error) {
|
||
u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListEventsForOrganization lists public events for an organization.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
|
||
func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opt *ListOptions) ([]*Event, *Response, error) {
|
||
u := fmt.Sprintf("orgs/%v/events", org)
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
|
||
// true, only public events will be returned.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user
|
||
func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opt *ListOptions) ([]*Event, *Response, error) {
|
||
var u string
|
||
if publicOnly {
|
||
u = fmt.Sprintf("users/%v/events/public", user)
|
||
} else {
|
||
u = fmt.Sprintf("users/%v/events", user)
|
||
}
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListEventsReceivedByUser lists the events received by a user. If publicOnly is
|
||
// true, only public events will be returned.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received
|
||
func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opt *ListOptions) ([]*Event, *Response, error) {
|
||
var u string
|
||
if publicOnly {
|
||
u = fmt.Sprintf("users/%v/received_events/public", user)
|
||
} else {
|
||
u = fmt.Sprintf("users/%v/received_events", user)
|
||
}
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|
||
|
||
// ListUserEventsForOrganization provides the user’s organization dashboard. You
|
||
// must be authenticated as the user to view this.
|
||
//
|
||
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-events-for-an-organization
|
||
func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opt *ListOptions) ([]*Event, *Response, error) {
|
||
u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
|
||
u, err := addOptions(u, opt)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
req, err := s.client.NewRequest("GET", u, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
|
||
var events []*Event
|
||
resp, err := s.client.Do(ctx, req, &events)
|
||
if err != nil {
|
||
return nil, resp, err
|
||
}
|
||
|
||
return events, resp, nil
|
||
}
|