1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 13:49:42 +02:00
Migrated from plain /vendor to go dep
This commit is contained in:
Harvey Kandola 2018-02-14 15:23:46 +00:00
parent 0262763c95
commit fd693f4ff4
957 changed files with 36866 additions and 177595 deletions

View file

@ -6,6 +6,7 @@
package github
import (
"context"
"errors"
"fmt"
"net/http"
@ -16,13 +17,11 @@ import (
// in the GitHub API.
//
// GitHub API docs: https://developer.github.com/v3/migration/
type MigrationService struct {
client *Client
}
type MigrationService service
// Migration represents a GitHub migration (archival).
type Migration struct {
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
GUID *string `json:"guid,omitempty"`
// State is the current state of a migration.
// Possible values are:
@ -76,7 +75,7 @@ type startMigration struct {
// repos is a slice of repository names to migrate.
//
// GitHub API docs: https://developer.github.com/v3/migration/migrations/#start-a-migration
func (s *MigrationService) StartMigration(org string, repos []string, opt *MigrationOptions) (*Migration, *Response, error) {
func (s *MigrationService) StartMigration(ctx context.Context, org string, repos []string, opt *MigrationOptions) (*Migration, *Response, error) {
u := fmt.Sprintf("orgs/%v/migrations", org)
body := &startMigration{Repositories: repos}
@ -94,7 +93,7 @@ func (s *MigrationService) StartMigration(org string, repos []string, opt *Migra
req.Header.Set("Accept", mediaTypeMigrationsPreview)
m := &Migration{}
resp, err := s.client.Do(req, m)
resp, err := s.client.Do(ctx, req, m)
if err != nil {
return nil, resp, err
}
@ -105,7 +104,7 @@ func (s *MigrationService) StartMigration(org string, repos []string, opt *Migra
// ListMigrations lists the most recent migrations.
//
// GitHub API docs: https://developer.github.com/v3/migration/migrations/#get-a-list-of-migrations
func (s *MigrationService) ListMigrations(org string) ([]*Migration, *Response, error) {
func (s *MigrationService) ListMigrations(ctx context.Context, org string) ([]*Migration, *Response, error) {
u := fmt.Sprintf("orgs/%v/migrations", org)
req, err := s.client.NewRequest("GET", u, nil)
@ -117,7 +116,7 @@ func (s *MigrationService) ListMigrations(org string) ([]*Migration, *Response,
req.Header.Set("Accept", mediaTypeMigrationsPreview)
var m []*Migration
resp, err := s.client.Do(req, &m)
resp, err := s.client.Do(ctx, req, &m)
if err != nil {
return nil, resp, err
}
@ -129,7 +128,7 @@ func (s *MigrationService) ListMigrations(org string) ([]*Migration, *Response,
// id is the migration ID.
//
// GitHub API docs: https://developer.github.com/v3/migration/migrations/#get-the-status-of-a-migration
func (s *MigrationService) MigrationStatus(org string, id int) (*Migration, *Response, error) {
func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) {
u := fmt.Sprintf("orgs/%v/migrations/%v", org, id)
req, err := s.client.NewRequest("GET", u, nil)
@ -141,7 +140,7 @@ func (s *MigrationService) MigrationStatus(org string, id int) (*Migration, *Res
req.Header.Set("Accept", mediaTypeMigrationsPreview)
m := &Migration{}
resp, err := s.client.Do(req, m)
resp, err := s.client.Do(ctx, req, m)
if err != nil {
return nil, resp, err
}
@ -153,7 +152,7 @@ func (s *MigrationService) MigrationStatus(org string, id int) (*Migration, *Res
// id is the migration ID.
//
// GitHub API docs: https://developer.github.com/v3/migration/migrations/#download-a-migration-archive
func (s *MigrationService) MigrationArchiveURL(org string, id int) (url string, err error) {
func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, id int64) (url string, err error) {
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
req, err := s.client.NewRequest("GET", u, nil)
@ -176,7 +175,7 @@ func (s *MigrationService) MigrationArchiveURL(org string, id int) (url string,
}
defer func() { s.client.client.CheckRedirect = saveRedirect }()
_, err = s.client.Do(req, nil) // expect error from disable redirect
_, err = s.client.Do(ctx, req, nil) // expect error from disable redirect
if err == nil {
return "", errors.New("expected redirect, none provided")
}
@ -190,7 +189,7 @@ func (s *MigrationService) MigrationArchiveURL(org string, id int) (url string,
// id is the migration ID.
//
// GitHub API docs: https://developer.github.com/v3/migration/migrations/#delete-a-migration-archive
func (s *MigrationService) DeleteMigration(org string, id int) (*Response, error) {
func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) {
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
req, err := s.client.NewRequest("DELETE", u, nil)
@ -201,7 +200,7 @@ func (s *MigrationService) DeleteMigration(org string, id int) (*Response, error
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
return s.client.Do(req, nil)
return s.client.Do(ctx, req, nil)
}
// UnlockRepo unlocks a repository that was locked for migration.
@ -210,7 +209,7 @@ func (s *MigrationService) DeleteMigration(org string, id int) (*Response, error
// is complete and you no longer need the source data.
//
// GitHub API docs: https://developer.github.com/v3/migration/migrations/#unlock-a-repository
func (s *MigrationService) UnlockRepo(org string, id int, repo string) (*Response, error) {
func (s *MigrationService) UnlockRepo(ctx context.Context, org string, id int64, repo string) (*Response, error) {
u := fmt.Sprintf("orgs/%v/migrations/%v/repos/%v/lock", org, id, repo)
req, err := s.client.NewRequest("DELETE", u, nil)
@ -221,5 +220,5 @@ func (s *MigrationService) UnlockRepo(org string, id int, repo string) (*Respons
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
return s.client.Do(req, nil)
return s.client.Do(ctx, req, nil)
}