1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Update dependencies

This commit is contained in:
Chris Cummer
2018-07-31 10:20:12 -07:00
parent 015d7736db
commit 869cb0b9da
23 changed files with 1605 additions and 76 deletions

View File

@@ -146,6 +146,7 @@ Sahil Dua <sahildua2305@gmail.com>
saisi <saisi@users.noreply.github.com>
Sam Minnée <sam@silverstripe.com>
Sander van Harmelen <svanharmelen@schubergphilis.com>
Sanket Payghan <sanket.payghan8@gmail.com>
Sarasa Kisaragi <lingsamuelgrace@gmail.com>
Sean Wang <sean@decrypted.org>
Sebastian Mandrean <sebastian.mandrean@gmail.com>

View File

@@ -32,6 +32,10 @@ func (e Event) String() string {
// a value of the corresponding struct type will be returned.
func (e *Event) ParsePayload() (payload interface{}, err error) {
switch *e.Type {
case "CheckRunEvent":
payload = &CheckRunEvent{}
case "CheckSuiteEvent":
payload = &CheckSuiteEvent{}
case "CommitCommentEvent":
payload = &CommitCommentEvent{}
case "CreateEvent":

View File

@@ -74,9 +74,6 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opt *ListOptions) ([
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMarketplacePreview)
var plans []*MarketplacePlan
resp, err := s.client.Do(ctx, req, &plans)
if err != nil {
@@ -101,9 +98,6 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMarketplacePreview)
var accounts []*MarketplacePlanAccount
resp, err := s.client.Do(ctx, req, &accounts)
if err != nil {
@@ -128,9 +122,6 @@ func (s *MarketplaceService) ListPlanAccountsForAccount(ctx context.Context, acc
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMarketplacePreview)
var accounts []*MarketplacePlanAccount
resp, err := s.client.Do(ctx, req, &accounts)
if err != nil {
@@ -159,9 +150,6 @@ func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMarketplacePreview)
var purchases []*MarketplacePurchase
resp, err := s.client.Do(ctx, req, &purchases)
if err != nil {

428
vendor/github.com/google/go-github/github/checks.go generated vendored Normal file
View File

@@ -0,0 +1,428 @@
// Copyright 2018 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"
)
// ChecksService provides access to the Checks API in the
// GitHub API.
//
// GitHub API docs: https://developer.github.com/v3/checks/
type ChecksService service
// CheckRun represents a GitHub check run on a repository associated with a GitHub app.
type CheckRun struct {
ID *int64 `json:"id,omitempty"`
HeadSHA *string `json:"head_sha,omitempty"`
ExternalID *string `json:"external_id,omitempty"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
Status *string `json:"status,omitempty"`
Conclusion *string `json:"conclusion,omitempty"`
StartedAt *Timestamp `json:"started_at,omitempty"`
CompletedAt *Timestamp `json:"completed_at,omitempty"`
Output *CheckRunOutput `json:"output,omitempty"`
Name *string `json:"name,omitempty"`
CheckSuite *CheckSuite `json:"check_suite,omitempty"`
App *App `json:"app,omitempty"`
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
}
// CheckRunOutput represents the output of a CheckRun.
type CheckRunOutput struct {
Title *string `json:"title,omitempty"`
Summary *string `json:"summary,omitempty"`
Text *string `json:"text,omitempty"`
AnnotationsCount *int `json:"annotations_count,omitempty"`
AnnotationsURL *string `json:"annotations_url,omitempty"`
Annotations []*CheckRunAnnotation `json:"annotations,omitempty"`
Images []*CheckRunImage `json:"images,omitempty"`
}
// CheckRunAnnotation represents an annotation object for a CheckRun output.
type CheckRunAnnotation struct {
FileName *string `json:"filename,omitempty"`
BlobHRef *string `json:"blob_href,omitempty"`
StartLine *int `json:"start_line,omitempty"`
EndLine *int `json:"end_line,omitempty"`
WarningLevel *string `json:"warning_level,omitempty"`
Message *string `json:"message,omitempty"`
Title *string `json:"title,omitempty"`
RawDetails *string `json:"raw_details,omitempty"`
}
// CheckRunImage represents an image object for a CheckRun output.
type CheckRunImage struct {
Alt *string `json:"alt,omitempty"`
ImageURL *string `json:"image_url,omitempty"`
Caption *string `json:"caption,omitempty"`
}
// CheckSuite represents a suite of check runs.
type CheckSuite struct {
ID *int64 `json:"id,omitempty"`
HeadBranch *string `json:"head_branch,omitempty"`
HeadSHA *string `json:"head_sha,omitempty"`
URL *string `json:"url,omitempty"`
BeforeSHA *string `json:"before,omitempty"`
AfterSHA *string `json:"after,omitempty"`
Status *string `json:"status,omitempty"`
Conclusion *string `json:"conclusion,omitempty"`
App *App `json:"app,omitempty"`
Repository *Repository `json:"repository,omitempty"`
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
}
func (c CheckRun) String() string {
return Stringify(c)
}
func (c CheckSuite) String() string {
return Stringify(c)
}
// GetCheckRun gets a check-run for a repository.
//
// GitHub API docs: https://developer.github.com/v3/checks/runs/#get-a-single-check-run
func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
checkRun := new(CheckRun)
resp, err := s.client.Do(ctx, req, checkRun)
if err != nil {
return nil, resp, err
}
return checkRun, resp, nil
}
// GetCheckSuite gets a single check suite.
//
// GitHub API docs: https://developer.github.com/v3/checks/suites/#get-a-single-check-suite
func (s *ChecksService) GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-suites/%v", owner, repo, checkSuiteID)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
checkSuite := new(CheckSuite)
resp, err := s.client.Do(ctx, req, checkSuite)
if err != nil {
return nil, resp, err
}
return checkSuite, resp, nil
}
// CreateCheckRunOptions sets up parameters needed to create a CheckRun.
type CreateCheckRunOptions struct {
Name string `json:"name"` // The name of the check (e.g., "code-coverage"). (Required.)
HeadBranch string `json:"head_branch"` // The name of the branch to perform a check against. (Required.)
HeadSHA string `json:"head_sha"` // The SHA of the commit. (Required.)
DetailsURL *string `json:"details_url,omitempty"` // The URL of the integrator's site that has the full details of the check. (Optional.)
ExternalID *string `json:"external_id,omitempty"` // A reference for the run on the integrator's system. (Optional.)
Status *string `json:"status,omitempty"` // The current status. Can be one of "queued", "in_progress", or "completed". Default: "queued". (Optional.)
Conclusion *string `json:"conclusion,omitempty"` // Can be one of "success", "failure", "neutral", "cancelled", "timed_out", or "action_required". (Optional. Required if you provide a status of "completed".)
StartedAt *Timestamp `json:"started_at,omitempty"` // The time that the check run began. (Optional.)
CompletedAt *Timestamp `json:"completed_at,omitempty"` // The time the check completed. (Optional. Required if you provide conclusion.)
Output *CheckRunOutput `json:"output,omitempty"` // Provide descriptive details about the run. (Optional)
}
// CreateCheckRun creates a check run for repository.
//
// GitHub API docs: https://developer.github.com/v3/checks/runs/#create-a-check-run
func (s *ChecksService) CreateCheckRun(ctx context.Context, owner, repo string, opt CreateCheckRunOptions) (*CheckRun, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-runs", owner, repo)
req, err := s.client.NewRequest("POST", u, opt)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
checkRun := new(CheckRun)
resp, err := s.client.Do(ctx, req, checkRun)
if err != nil {
return nil, resp, err
}
return checkRun, resp, nil
}
// UpdateCheckRunOptions sets up parameters needed to update a CheckRun.
type UpdateCheckRunOptions struct {
Name string `json:"name"` // The name of the check (e.g., "code-coverage"). (Required.)
HeadBranch *string `json:"head_branch,omitempty"` // The name of the branch to perform a check against. (Optional.)
HeadSHA *string `json:"head_sha,omitempty"` // The SHA of the commit. (Optional.)
DetailsURL *string `json:"details_url,omitempty"` // The URL of the integrator's site that has the full details of the check. (Optional.)
ExternalID *string `json:"external_id,omitempty"` // A reference for the run on the integrator's system. (Optional.)
Status *string `json:"status,omitempty"` // The current status. Can be one of "queued", "in_progress", or "completed". Default: "queued". (Optional.)
Conclusion *string `json:"conclusion,omitempty"` // Can be one of "success", "failure", "neutral", "cancelled", "timed_out", or "action_required". (Optional. Required if you provide a status of "completed".)
CompletedAt *Timestamp `json:"completed_at,omitempty"` // The time the check completed. (Optional. Required if you provide conclusion.)
Output *CheckRunOutput `json:"output,omitempty"` // Provide descriptive details about the run. (Optional)
}
// UpdateCheckRun updates a check run for a specific commit in a repository.
//
// GitHub API docs: https://developer.github.com/v3/checks/runs/#update-a-check-run
func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opt UpdateCheckRunOptions) (*CheckRun, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
req, err := s.client.NewRequest("PATCH", u, opt)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
checkRun := new(CheckRun)
resp, err := s.client.Do(ctx, req, checkRun)
if err != nil {
return nil, resp, err
}
return checkRun, resp, nil
}
// ListCheckRunAnnotations lists the annotations for a check run.
//
// GitHub API docs: https://developer.github.com/v3/checks/runs/#list-annotations-for-a-check-run
func (s *ChecksService) ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opt *ListOptions) ([]*CheckRunAnnotation, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-runs/%v/annotations", owner, repo, checkRunID)
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
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
var checkRunAnnotations []*CheckRunAnnotation
resp, err := s.client.Do(ctx, req, &checkRunAnnotations)
if err != nil {
return nil, resp, err
}
return checkRunAnnotations, resp, nil
}
// ListCheckRunsOptions represents parameters to list check runs.
type ListCheckRunsOptions struct {
CheckName *string `url:"check_name,omitempty"` // Returns check runs with the specified name.
Status *string `url:"status,omitempty"` // Returns check runs with the specified status. Can be one of "queued", "in_progress", or "completed".
Filter *string `url:"filter,omitempty"` // Filters check runs by their completed_at timestamp. Can be one of "latest" (returning the most recent check runs) or "all". Default: "latest"
ListOptions
}
// ListCheckRunsResults represents the result of a check run list.
type ListCheckRunsResults struct {
Total *int `json:"total_count,omitempty"`
CheckRuns []*CheckRun `json:"check_runs,omitempty"`
}
// ListCheckRunsForRef lists check runs for a specific ref.
//
// GitHub API docs: https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref
func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opt *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/commits/%v/check-runs", owner, repo, ref)
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
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
var checkRunResults *ListCheckRunsResults
resp, err := s.client.Do(ctx, req, &checkRunResults)
if err != nil {
return nil, resp, err
}
return checkRunResults, resp, nil
}
// ListCheckRunsCheckSuite lists check runs for a check suite.
//
// GitHub API docs: https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite
func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64, opt *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-suites/%v/check-runs", owner, repo, checkSuiteID)
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
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
var checkRunResults *ListCheckRunsResults
resp, err := s.client.Do(ctx, req, &checkRunResults)
if err != nil {
return nil, resp, err
}
return checkRunResults, resp, nil
}
// ListCheckSuiteOptions represents parameters to list check suites.
type ListCheckSuiteOptions struct {
CheckName *string `url:"check_name,omitempty"` // Filters checks suites by the name of the check run.
AppID *int `url:"app_id,omitempty"` // Filters check suites by GitHub App id.
ListOptions
}
// ListCheckSuiteResults represents the result of a check run list.
type ListCheckSuiteResults struct {
Total *int `json:"total_count,omitempty"`
CheckSuites []*CheckSuite `json:"check_suites,omitempty"`
}
// ListCheckSuitesForRef lists check suite for a specific ref.
//
// GitHub API docs: https://developer.github.com/v3/checks/suites/#list-check-suites-for-a-specific-ref
func (s *ChecksService) ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opt *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/commits/%v/check-suites", owner, repo, ref)
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
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
var checkSuiteResults *ListCheckSuiteResults
resp, err := s.client.Do(ctx, req, &checkSuiteResults)
if err != nil {
return nil, resp, err
}
return checkSuiteResults, resp, nil
}
// AutoTriggerCheck enables or disables automatic creation of CheckSuite events upon pushes to the repository.
type AutoTriggerCheck struct {
AppID *int64 `json:"app_id,omitempty"` // The id of the GitHub App. (Required.)
Setting *bool `json:"setting,omitempty"` // Set to "true" to enable automatic creation of CheckSuite events upon pushes to the repository, or "false" to disable them. Default: "true" (Required.)
}
// CheckSuitePreferenceOptions set options for check suite preferences for a repository.
type CheckSuitePreferenceOptions struct {
PreferenceList *PreferenceList `json:"auto_trigger_checks,omitempty"` // A list of auto trigger checks that can be set for a check suite in a repository.
}
// CheckSuitePreferenceResults represents the results of the preference set operation.
type CheckSuitePreferenceResults struct {
Preferences *PreferenceList `json:"preferences,omitempty"`
Repository *Repository `json:"repository,omitempty"`
}
// PreferenceList represents a list of auto trigger checks for repository
type PreferenceList struct {
AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
}
// SetCheckSuitePreferences changes the default automatic flow when creating check suites.
//
// GitHub API docs: https://developer.github.com/v3/checks/suites/#set-preferences-for-check-suites-on-a-repository
func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, repo string, opt CheckSuitePreferenceOptions) (*CheckSuitePreferenceResults, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-suites/preferences", owner, repo)
req, err := s.client.NewRequest("PATCH", u, opt)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
var checkSuitePrefResults *CheckSuitePreferenceResults
resp, err := s.client.Do(ctx, req, &checkSuitePrefResults)
if err != nil {
return nil, resp, err
}
return checkSuitePrefResults, resp, nil
}
// CreateCheckSuiteOptions sets up parameters to manually create a check suites
type CreateCheckSuiteOptions struct {
HeadSHA string `json:"head_sha"` // The sha of the head commit. (Required.)
HeadBranch *string `json:"head_branch,omitempty"` // The name of the head branch where the code changes are implemented.
}
// CreateCheckSuite manually creates a check suite for a repository.
//
// GitHub API docs: https://developer.github.com/v3/checks/suites/#create-a-check-suite
func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string, opt CreateCheckSuiteOptions) (*CheckSuite, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-suites", owner, repo)
req, err := s.client.NewRequest("POST", u, opt)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
checkSuite := new(CheckSuite)
resp, err := s.client.Do(ctx, req, checkSuite)
if err != nil {
return nil, resp, err
}
return checkSuite, resp, nil
}
// RequestCheckSuiteOptions sets up the parameters for a request check suite endpoint.
type RequestCheckSuiteOptions struct {
HeadSHA string `json:"head_sha"` // The sha of the head commit. (Required.)
}
// RequestCheckSuite triggers GitHub to create a new check suite, without pushing new code to a repository.
//
// GitHub API docs: https://developer.github.com/v3/checks/suites/#request-check-suites
func (s *ChecksService) RequestCheckSuite(ctx context.Context, owner, repo string, opt RequestCheckSuiteOptions) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/check-suite-requests", owner, repo)
u, err := addOptions(u, opt)
if err != nil {
return nil, err
}
req, err := s.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
}
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
resp, err := s.client.Do(ctx, req, nil)
return resp, err
}

View File

@@ -7,6 +7,38 @@
package github
// CheckRunEvent is triggered when a check run is "created", "updated", or "re-requested".
// The Webhook event name is "check_run".
//
// GitHub API docs: https://developer.github.com/v3/activity/events/types/#checkrunevent
type CheckRunEvent struct {
CheckRun *CheckRun `json:"check_run,omitempty"`
// The action performed. Can be "created", "updated" or "re-requested".
Action *string `json:"action,omitempty"`
// The following fields are only populated by Webhook events.
Repo *Repository `json:"repository,omitempty"`
Org *Organization `json:"organization,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}
// CheckSuiteEvent is triggered when a check suite is "completed", "requested", or "re-requested".
// The Webhook event name is "check_suite".
//
// GitHub API docs: https://developer.github.com/v3/activity/events/types/#checksuiteevent
type CheckSuiteEvent struct {
CheckSuite *CheckSuite `json:"check_suite,omitempty"`
// The action performed. Can be "completed", "requested" or "re-requested".
Action *string `json:"action,omitempty"`
// The following fields are only populated by Webhook events.
Repo *Repository `json:"repository,omitempty"`
Org *Organization `json:"organization,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
}
// CommitCommentEvent is triggered when a commit comment is created.
// The Webhook event name is "commit_comment".
//

View File

@@ -364,6 +364,22 @@ func (a *AuthorizationUpdateRequest) GetNoteURL() string {
return *a.NoteURL
}
// GetAppID returns the AppID field if it's non-nil, zero value otherwise.
func (a *AutoTriggerCheck) GetAppID() int64 {
if a == nil || a.AppID == nil {
return 0
}
return *a.AppID
}
// GetSetting returns the Setting field if it's non-nil, zero value otherwise.
func (a *AutoTriggerCheck) GetSetting() bool {
if a == nil || a.Setting == nil {
return false
}
return *a.Setting
}
// GetContent returns the Content field if it's non-nil, zero value otherwise.
func (b *Blob) GetContent() string {
if b == nil || b.Content == nil {
@@ -436,6 +452,438 @@ func (b *Branch) GetProtected() bool {
return *b.Protected
}
// GetApp returns the App field.
func (c *CheckRun) GetApp() *App {
if c == nil {
return nil
}
return c.App
}
// GetCheckSuite returns the CheckSuite field.
func (c *CheckRun) GetCheckSuite() *CheckSuite {
if c == nil {
return nil
}
return c.CheckSuite
}
// GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetCompletedAt() Timestamp {
if c == nil || c.CompletedAt == nil {
return Timestamp{}
}
return *c.CompletedAt
}
// GetConclusion returns the Conclusion field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetConclusion() string {
if c == nil || c.Conclusion == nil {
return ""
}
return *c.Conclusion
}
// GetExternalID returns the ExternalID field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetExternalID() string {
if c == nil || c.ExternalID == nil {
return ""
}
return *c.ExternalID
}
// GetHeadSHA returns the HeadSHA field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetHeadSHA() string {
if c == nil || c.HeadSHA == nil {
return ""
}
return *c.HeadSHA
}
// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetHTMLURL() string {
if c == nil || c.HTMLURL == nil {
return ""
}
return *c.HTMLURL
}
// GetID returns the ID field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetID() int64 {
if c == nil || c.ID == nil {
return 0
}
return *c.ID
}
// GetName returns the Name field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetName() string {
if c == nil || c.Name == nil {
return ""
}
return *c.Name
}
// GetOutput returns the Output field.
func (c *CheckRun) GetOutput() *CheckRunOutput {
if c == nil {
return nil
}
return c.Output
}
// GetStartedAt returns the StartedAt field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetStartedAt() Timestamp {
if c == nil || c.StartedAt == nil {
return Timestamp{}
}
return *c.StartedAt
}
// GetStatus returns the Status field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetStatus() string {
if c == nil || c.Status == nil {
return ""
}
return *c.Status
}
// GetURL returns the URL field if it's non-nil, zero value otherwise.
func (c *CheckRun) GetURL() string {
if c == nil || c.URL == nil {
return ""
}
return *c.URL
}
// GetBlobHRef returns the BlobHRef field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetBlobHRef() string {
if c == nil || c.BlobHRef == nil {
return ""
}
return *c.BlobHRef
}
// GetEndLine returns the EndLine field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetEndLine() int {
if c == nil || c.EndLine == nil {
return 0
}
return *c.EndLine
}
// GetFileName returns the FileName field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetFileName() string {
if c == nil || c.FileName == nil {
return ""
}
return *c.FileName
}
// GetMessage returns the Message field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetMessage() string {
if c == nil || c.Message == nil {
return ""
}
return *c.Message
}
// GetRawDetails returns the RawDetails field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetRawDetails() string {
if c == nil || c.RawDetails == nil {
return ""
}
return *c.RawDetails
}
// GetStartLine returns the StartLine field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetStartLine() int {
if c == nil || c.StartLine == nil {
return 0
}
return *c.StartLine
}
// GetTitle returns the Title field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetTitle() string {
if c == nil || c.Title == nil {
return ""
}
return *c.Title
}
// GetWarningLevel returns the WarningLevel field if it's non-nil, zero value otherwise.
func (c *CheckRunAnnotation) GetWarningLevel() string {
if c == nil || c.WarningLevel == nil {
return ""
}
return *c.WarningLevel
}
// GetAction returns the Action field if it's non-nil, zero value otherwise.
func (c *CheckRunEvent) GetAction() string {
if c == nil || c.Action == nil {
return ""
}
return *c.Action
}
// GetCheckRun returns the CheckRun field.
func (c *CheckRunEvent) GetCheckRun() *CheckRun {
if c == nil {
return nil
}
return c.CheckRun
}
// GetInstallation returns the Installation field.
func (c *CheckRunEvent) GetInstallation() *Installation {
if c == nil {
return nil
}
return c.Installation
}
// GetOrg returns the Org field.
func (c *CheckRunEvent) GetOrg() *Organization {
if c == nil {
return nil
}
return c.Org
}
// GetRepo returns the Repo field.
func (c *CheckRunEvent) GetRepo() *Repository {
if c == nil {
return nil
}
return c.Repo
}
// GetSender returns the Sender field.
func (c *CheckRunEvent) GetSender() *User {
if c == nil {
return nil
}
return c.Sender
}
// GetAlt returns the Alt field if it's non-nil, zero value otherwise.
func (c *CheckRunImage) GetAlt() string {
if c == nil || c.Alt == nil {
return ""
}
return *c.Alt
}
// GetCaption returns the Caption field if it's non-nil, zero value otherwise.
func (c *CheckRunImage) GetCaption() string {
if c == nil || c.Caption == nil {
return ""
}
return *c.Caption
}
// GetImageURL returns the ImageURL field if it's non-nil, zero value otherwise.
func (c *CheckRunImage) GetImageURL() string {
if c == nil || c.ImageURL == nil {
return ""
}
return *c.ImageURL
}
// GetAnnotationsCount returns the AnnotationsCount field if it's non-nil, zero value otherwise.
func (c *CheckRunOutput) GetAnnotationsCount() int {
if c == nil || c.AnnotationsCount == nil {
return 0
}
return *c.AnnotationsCount
}
// GetAnnotationsURL returns the AnnotationsURL field if it's non-nil, zero value otherwise.
func (c *CheckRunOutput) GetAnnotationsURL() string {
if c == nil || c.AnnotationsURL == nil {
return ""
}
return *c.AnnotationsURL
}
// GetSummary returns the Summary field if it's non-nil, zero value otherwise.
func (c *CheckRunOutput) GetSummary() string {
if c == nil || c.Summary == nil {
return ""
}
return *c.Summary
}
// GetText returns the Text field if it's non-nil, zero value otherwise.
func (c *CheckRunOutput) GetText() string {
if c == nil || c.Text == nil {
return ""
}
return *c.Text
}
// GetTitle returns the Title field if it's non-nil, zero value otherwise.
func (c *CheckRunOutput) GetTitle() string {
if c == nil || c.Title == nil {
return ""
}
return *c.Title
}
// GetAfterSHA returns the AfterSHA field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetAfterSHA() string {
if c == nil || c.AfterSHA == nil {
return ""
}
return *c.AfterSHA
}
// GetApp returns the App field.
func (c *CheckSuite) GetApp() *App {
if c == nil {
return nil
}
return c.App
}
// GetBeforeSHA returns the BeforeSHA field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetBeforeSHA() string {
if c == nil || c.BeforeSHA == nil {
return ""
}
return *c.BeforeSHA
}
// GetConclusion returns the Conclusion field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetConclusion() string {
if c == nil || c.Conclusion == nil {
return ""
}
return *c.Conclusion
}
// GetHeadBranch returns the HeadBranch field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetHeadBranch() string {
if c == nil || c.HeadBranch == nil {
return ""
}
return *c.HeadBranch
}
// GetHeadSHA returns the HeadSHA field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetHeadSHA() string {
if c == nil || c.HeadSHA == nil {
return ""
}
return *c.HeadSHA
}
// GetID returns the ID field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetID() int64 {
if c == nil || c.ID == nil {
return 0
}
return *c.ID
}
// GetRepository returns the Repository field.
func (c *CheckSuite) GetRepository() *Repository {
if c == nil {
return nil
}
return c.Repository
}
// GetStatus returns the Status field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetStatus() string {
if c == nil || c.Status == nil {
return ""
}
return *c.Status
}
// GetURL returns the URL field if it's non-nil, zero value otherwise.
func (c *CheckSuite) GetURL() string {
if c == nil || c.URL == nil {
return ""
}
return *c.URL
}
// GetAction returns the Action field if it's non-nil, zero value otherwise.
func (c *CheckSuiteEvent) GetAction() string {
if c == nil || c.Action == nil {
return ""
}
return *c.Action
}
// GetCheckSuite returns the CheckSuite field.
func (c *CheckSuiteEvent) GetCheckSuite() *CheckSuite {
if c == nil {
return nil
}
return c.CheckSuite
}
// GetInstallation returns the Installation field.
func (c *CheckSuiteEvent) GetInstallation() *Installation {
if c == nil {
return nil
}
return c.Installation
}
// GetOrg returns the Org field.
func (c *CheckSuiteEvent) GetOrg() *Organization {
if c == nil {
return nil
}
return c.Org
}
// GetRepo returns the Repo field.
func (c *CheckSuiteEvent) GetRepo() *Repository {
if c == nil {
return nil
}
return c.Repo
}
// GetSender returns the Sender field.
func (c *CheckSuiteEvent) GetSender() *User {
if c == nil {
return nil
}
return c.Sender
}
// GetPreferenceList returns the PreferenceList field.
func (c *CheckSuitePreferenceOptions) GetPreferenceList() *PreferenceList {
if c == nil {
return nil
}
return c.PreferenceList
}
// GetPreferences returns the Preferences field.
func (c *CheckSuitePreferenceResults) GetPreferences() *PreferenceList {
if c == nil {
return nil
}
return c.Preferences
}
// GetRepository returns the Repository field.
func (c *CheckSuitePreferenceResults) GetRepository() *Repository {
if c == nil {
return nil
}
return c.Repository
}
// GetBody returns the Body field if it's non-nil, zero value otherwise.
func (c *CodeOfConduct) GetBody() string {
if c == nil || c.Body == nil {
@@ -1060,6 +1508,14 @@ func (c *CommunityHealthFiles) GetContributing() *Metric {
return c.Contributing
}
// GetIssueTemplate returns the IssueTemplate field.
func (c *CommunityHealthFiles) GetIssueTemplate() *Metric {
if c == nil {
return nil
}
return c.IssueTemplate
}
// GetLicense returns the License field.
func (c *CommunityHealthFiles) GetLicense() *Metric {
if c == nil {
@@ -1068,6 +1524,14 @@ func (c *CommunityHealthFiles) GetLicense() *Metric {
return c.License
}
// GetPullRequestTemplate returns the PullRequestTemplate field.
func (c *CommunityHealthFiles) GetPullRequestTemplate() *Metric {
if c == nil {
return nil
}
return c.PullRequestTemplate
}
// GetReadme returns the Readme field.
func (c *CommunityHealthFiles) GetReadme() *Metric {
if c == nil {
@@ -1260,6 +1724,70 @@ func (c *ContributorStats) GetTotal() int {
return *c.Total
}
// GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise.
func (c *CreateCheckRunOptions) GetCompletedAt() Timestamp {
if c == nil || c.CompletedAt == nil {
return Timestamp{}
}
return *c.CompletedAt
}
// GetConclusion returns the Conclusion field if it's non-nil, zero value otherwise.
func (c *CreateCheckRunOptions) GetConclusion() string {
if c == nil || c.Conclusion == nil {
return ""
}
return *c.Conclusion
}
// GetDetailsURL returns the DetailsURL field if it's non-nil, zero value otherwise.
func (c *CreateCheckRunOptions) GetDetailsURL() string {
if c == nil || c.DetailsURL == nil {
return ""
}
return *c.DetailsURL
}
// GetExternalID returns the ExternalID field if it's non-nil, zero value otherwise.
func (c *CreateCheckRunOptions) GetExternalID() string {
if c == nil || c.ExternalID == nil {
return ""
}
return *c.ExternalID
}
// GetOutput returns the Output field.
func (c *CreateCheckRunOptions) GetOutput() *CheckRunOutput {
if c == nil {
return nil
}
return c.Output
}
// GetStartedAt returns the StartedAt field if it's non-nil, zero value otherwise.
func (c *CreateCheckRunOptions) GetStartedAt() Timestamp {
if c == nil || c.StartedAt == nil {
return Timestamp{}
}
return *c.StartedAt
}
// GetStatus returns the Status field if it's non-nil, zero value otherwise.
func (c *CreateCheckRunOptions) GetStatus() string {
if c == nil || c.Status == nil {
return ""
}
return *c.Status
}
// GetHeadBranch returns the HeadBranch field if it's non-nil, zero value otherwise.
func (c *CreateCheckSuiteOptions) GetHeadBranch() string {
if c == nil || c.HeadBranch == nil {
return ""
}
return *c.HeadBranch
}
// GetDescription returns the Description field if it's non-nil, zero value otherwise.
func (c *CreateEvent) GetDescription() string {
if c == nil || c.Description == nil {
@@ -4004,6 +4532,62 @@ func (l *License) GetURL() string {
return *l.URL
}
// GetCheckName returns the CheckName field if it's non-nil, zero value otherwise.
func (l *ListCheckRunsOptions) GetCheckName() string {
if l == nil || l.CheckName == nil {
return ""
}
return *l.CheckName
}
// GetFilter returns the Filter field if it's non-nil, zero value otherwise.
func (l *ListCheckRunsOptions) GetFilter() string {
if l == nil || l.Filter == nil {
return ""
}
return *l.Filter
}
// GetStatus returns the Status field if it's non-nil, zero value otherwise.
func (l *ListCheckRunsOptions) GetStatus() string {
if l == nil || l.Status == nil {
return ""
}
return *l.Status
}
// GetTotal returns the Total field if it's non-nil, zero value otherwise.
func (l *ListCheckRunsResults) GetTotal() int {
if l == nil || l.Total == nil {
return 0
}
return *l.Total
}
// GetAppID returns the AppID field if it's non-nil, zero value otherwise.
func (l *ListCheckSuiteOptions) GetAppID() int {
if l == nil || l.AppID == nil {
return 0
}
return *l.AppID
}
// GetCheckName returns the CheckName field if it's non-nil, zero value otherwise.
func (l *ListCheckSuiteOptions) GetCheckName() string {
if l == nil || l.CheckName == nil {
return ""
}
return *l.CheckName
}
// GetTotal returns the Total field if it's non-nil, zero value otherwise.
func (l *ListCheckSuiteResults) GetTotal() int {
if l == nil || l.Total == nil {
return 0
}
return *l.Total
}
// GetAccountsURL returns the AccountsURL field if it's non-nil, zero value otherwise.
func (m *MarketplacePlan) GetAccountsURL() string {
if m == nil || m.AccountsURL == nil {
@@ -5596,6 +6180,14 @@ func (p *Project) GetURL() string {
return *p.URL
}
// GetArchived returns the Archived field if it's non-nil, zero value otherwise.
func (p *ProjectCard) GetArchived() bool {
if p == nil || p.Archived == nil {
return false
}
return *p.Archived
}
// GetColumnID returns the ColumnID field if it's non-nil, zero value otherwise.
func (p *ProjectCard) GetColumnID() int64 {
if p == nil || p.ColumnID == nil {
@@ -5740,6 +6332,22 @@ func (p *ProjectCardEvent) GetSender() *User {
return p.Sender
}
// GetArchivedState returns the ArchivedState field if it's non-nil, zero value otherwise.
func (p *ProjectCardListOptions) GetArchivedState() string {
if p == nil || p.ArchivedState == nil {
return ""
}
return *p.ArchivedState
}
// GetArchived returns the Archived field if it's non-nil, zero value otherwise.
func (p *ProjectCardOptions) GetArchived() bool {
if p == nil || p.Archived == nil {
return false
}
return *p.Archived
}
// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
func (p *ProjectColumn) GetCreatedAt() Timestamp {
if p == nil || p.CreatedAt == nil {
@@ -10260,6 +10868,70 @@ func (t *TreeEntry) GetURL() string {
return *t.URL
}
// GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetCompletedAt() Timestamp {
if u == nil || u.CompletedAt == nil {
return Timestamp{}
}
return *u.CompletedAt
}
// GetConclusion returns the Conclusion field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetConclusion() string {
if u == nil || u.Conclusion == nil {
return ""
}
return *u.Conclusion
}
// GetDetailsURL returns the DetailsURL field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetDetailsURL() string {
if u == nil || u.DetailsURL == nil {
return ""
}
return *u.DetailsURL
}
// GetExternalID returns the ExternalID field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetExternalID() string {
if u == nil || u.ExternalID == nil {
return ""
}
return *u.ExternalID
}
// GetHeadBranch returns the HeadBranch field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetHeadBranch() string {
if u == nil || u.HeadBranch == nil {
return ""
}
return *u.HeadBranch
}
// GetHeadSHA returns the HeadSHA field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetHeadSHA() string {
if u == nil || u.HeadSHA == nil {
return ""
}
return *u.HeadSHA
}
// GetOutput returns the Output field.
func (u *UpdateCheckRunOptions) GetOutput() *CheckRunOutput {
if u == nil {
return nil
}
return u.Output
}
// GetStatus returns the Status field if it's non-nil, zero value otherwise.
func (u *UpdateCheckRunOptions) GetStatus() string {
if u == nil || u.Status == nil {
return ""
}
return *u.Status
}
// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise.
func (u *User) GetAvatarURL() string {
if u == nil || u.AvatarURL == nil {
@@ -10724,6 +11396,70 @@ func (u *UserLDAPMapping) GetURL() string {
return *u.URL
}
// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetCreatedAt() string {
if u == nil || u.CreatedAt == nil {
return ""
}
return *u.CreatedAt
}
// GetExcludeAttachments returns the ExcludeAttachments field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetExcludeAttachments() bool {
if u == nil || u.ExcludeAttachments == nil {
return false
}
return *u.ExcludeAttachments
}
// GetGUID returns the GUID field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetGUID() string {
if u == nil || u.GUID == nil {
return ""
}
return *u.GUID
}
// GetID returns the ID field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetID() int64 {
if u == nil || u.ID == nil {
return 0
}
return *u.ID
}
// GetLockRepositories returns the LockRepositories field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetLockRepositories() bool {
if u == nil || u.LockRepositories == nil {
return false
}
return *u.LockRepositories
}
// GetState returns the State field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetState() string {
if u == nil || u.State == nil {
return ""
}
return *u.State
}
// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetUpdatedAt() string {
if u == nil || u.UpdatedAt == nil {
return ""
}
return *u.UpdatedAt
}
// GetURL returns the URL field if it's non-nil, zero value otherwise.
func (u *UserMigration) GetURL() string {
if u == nil || u.URL == nil {
return ""
}
return *u.URL
}
// GetIncompleteResults returns the IncompleteResults field if it's non-nil, zero value otherwise.
func (u *UsersSearchResult) GetIncompleteResults() bool {
if u == nil || u.IncompleteResults == nil {

View File

@@ -96,9 +96,6 @@ const (
// https://developer.github.com/changes/2017-07-17-update-topics-on-repositories/
mediaTypeTopicsPreview = "application/vnd.github.mercy-preview+json"
// https://developer.github.com/v3/apps/marketplace/
mediaTypeMarketplacePreview = "application/vnd.github.valkyrie-preview+json"
// https://developer.github.com/changes/2017-08-30-preview-nested-teams/
mediaTypeNestedTeamsPreview = "application/vnd.github.hellcat-preview+json"
@@ -116,6 +113,9 @@ const (
// https://developer.github.com/changes/2018-02-07-team-discussions-api/
mediaTypeTeamDiscussionsPreview = "application/vnd.github.echo-preview+json"
// https://developer.github.com/changes/2018-05-07-new-checks-api-public-beta/
mediaTypeCheckRunsPreview = "application/vnd.github.antiope-preview+json"
)
// A Client manages communication with the GitHub API.
@@ -144,6 +144,7 @@ type Client struct {
Admin *AdminService
Apps *AppsService
Authorizations *AuthorizationsService
Checks *ChecksService
Gists *GistsService
Git *GitService
Gitignores *GitignoresService
@@ -235,6 +236,7 @@ func NewClient(httpClient *http.Client) *Client {
c.Admin = (*AdminService)(&c.common)
c.Apps = (*AppsService)(&c.common)
c.Authorizations = (*AuthorizationsService)(&c.common)
c.Checks = (*ChecksService)(&c.common)
c.Gists = (*GistsService)(&c.common)
c.Git = (*GitService)(&c.common)
c.Gitignores = (*GitignoresService)(&c.common)

View File

@@ -41,6 +41,8 @@ const (
var (
// eventTypeMapping maps webhooks types to their corresponding go-github struct types.
eventTypeMapping = map[string]string{
"check_run": "CheckRunEvent",
"check_suite": "CheckSuiteEvent",
"commit_comment": "CommitCommentEvent",
"create": "CreateEvent",
"delete": "DeleteEvent",

View File

@@ -0,0 +1,214 @@
// Copyright 2018 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"
"errors"
"fmt"
"net/http"
)
// UserMigration represents a GitHub migration (archival).
type UserMigration struct {
ID *int64 `json:"id,omitempty"`
GUID *string `json:"guid,omitempty"`
// State is the current state of a migration.
// Possible values are:
// "pending" which means the migration hasn't started yet,
// "exporting" which means the migration is in progress,
// "exported" which means the migration finished successfully, or
// "failed" which means the migration failed.
State *string `json:"state,omitempty"`
// LockRepositories indicates whether repositories are locked (to prevent
// manipulation) while migrating data.
LockRepositories *bool `json:"lock_repositories,omitempty"`
// ExcludeAttachments indicates whether attachments should be excluded from
// the migration (to reduce migration archive file size).
ExcludeAttachments *bool `json:"exclude_attachments,omitempty"`
URL *string `json:"url,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
UpdatedAt *string `json:"updated_at,omitempty"`
Repositories []*Repository `json:"repositories,omitempty"`
}
func (m UserMigration) String() string {
return Stringify(m)
}
// UserMigrationOptions specifies the optional parameters to Migration methods.
type UserMigrationOptions struct {
// LockRepositories indicates whether repositories should be locked (to prevent
// manipulation) while migrating data.
LockRepositories bool
// ExcludeAttachments indicates whether attachments should be excluded from
// the migration (to reduce migration archive file size).
ExcludeAttachments bool
}
// startUserMigration represents the body of a StartMigration request.
type startUserMigration struct {
// Repositories is a slice of repository names to migrate.
Repositories []string `json:"repositories,omitempty"`
// LockRepositories indicates whether repositories should be locked (to prevent
// manipulation) while migrating data.
LockRepositories *bool `json:"lock_repositories,omitempty"`
// ExcludeAttachments indicates whether attachments should be excluded from
// the migration (to reduce migration archive file size).
ExcludeAttachments *bool `json:"exclude_attachments,omitempty"`
}
// StartUserMigration starts the generation of a migration archive.
// repos is a slice of repository names to migrate.
//
// GitHub API docs: https://developer.github.com/v3/migrations/users/#start-a-user-migration
func (s *MigrationService) StartUserMigration(ctx context.Context, repos []string, opt *UserMigrationOptions) (*UserMigration, *Response, error) {
u := "user/migrations"
body := &startUserMigration{Repositories: repos}
if opt != nil {
body.LockRepositories = Bool(opt.LockRepositories)
body.ExcludeAttachments = Bool(opt.ExcludeAttachments)
}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
m := &UserMigration{}
resp, err := s.client.Do(ctx, req, m)
if err != nil {
return nil, resp, err
}
return m, resp, nil
}
// ListUserMigrations lists the most recent migrations.
//
// GitHub API docs: https://developer.github.com/v3/migrations/users/#get-a-list-of-user-migrations
func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigration, *Response, error) {
u := "user/migrations"
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
var m []*UserMigration
resp, err := s.client.Do(ctx, req, &m)
if err != nil {
return nil, resp, err
}
return m, resp, nil
}
// UserMigrationStatus gets the status of a specific migration archive.
// id is the migration ID.
//
// GitHub API docs: https://developer.github.com/v3/migrations/users/#get-the-status-of-a-user-migration
func (s *MigrationService) UserMigrationStatus(ctx context.Context, id int64) (*UserMigration, *Response, error) {
u := fmt.Sprintf("user/migrations/%v", id)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
m := &UserMigration{}
resp, err := s.client.Do(ctx, req, m)
if err != nil {
return nil, resp, err
}
return m, resp, nil
}
// UserMigrationArchiveURL gets the URL for a specific migration archive.
// id is the migration ID.
//
// GitHub API docs: https://developer.github.com/v3/migrations/users/#download-a-user-migration-archive
func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64) (string, error) {
url := fmt.Sprintf("user/migrations/%v/archive", id)
req, err := s.client.NewRequest("GET", url, nil)
if err != nil {
return "", err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
m := &UserMigration{}
var loc string
originalRedirect := s.client.client.CheckRedirect
s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
loc = req.URL.String()
return http.ErrUseLastResponse
}
defer func() {
s.client.client.CheckRedirect = originalRedirect
}()
resp, err := s.client.Do(ctx, req, m)
if err == nil {
return "", errors.New("expected redirect, none provided")
}
loc = resp.Header.Get("Location")
return loc, nil
}
// DeleteUserMigration will delete a previous migration archive.
// id is the migration ID.
//
// GitHub API docs: https://developer.github.com/v3/migrations/users/#delete-a-user-migration-archive
func (s *MigrationService) DeleteUserMigration(ctx context.Context, id int64) (*Response, error) {
url := fmt.Sprintf("user/migrations/%v/archive", id)
req, err := s.client.NewRequest("DELETE", url, nil)
if err != nil {
return nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
return s.client.Do(ctx, req, nil)
}
// UnlockUserRepository will unlock a repo that was locked for migration.
// id is migration ID.
// You should unlock each migrated repository and delete them when the migration
// is complete and you no longer need the source data.
//
// GitHub API docs: https://developer.github.com/v3/migrations/users/#unlock-a-user-repository
func (s *MigrationService) UnlockUserRepo(ctx context.Context, id int64, repo string) (*Response, error) {
url := fmt.Sprintf("user/migrations/%v/repos/%v/lock", id, repo)
req, err := s.client.NewRequest("DELETE", url, nil)
if err != nil {
return nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeMigrationsPreview)
return s.client.Do(ctx, req, nil)
}

View File

@@ -285,15 +285,26 @@ type ProjectCard struct {
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Archived *bool `json:"archived,omitempty"`
// The following fields are only populated by Webhook events.
ColumnID *int64 `json:"column_id,omitempty"`
}
// ProjectCardListOptions specifies the optional parameters to the
// ProjectsService.ListProjectCards method.
type ProjectCardListOptions struct {
// ArchivedState is used to list all, archived, or not_archived project cards.
// Defaults to not_archived when you omit this parameter.
ArchivedState *string `url:"archived_state,omitempty"`
ListOptions
}
// ListProjectCards lists the cards in a column of a GitHub Project.
//
// GitHub API docs: https://developer.github.com/v3/projects/cards/#list-project-cards
func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, opt *ListOptions) ([]*ProjectCard, *Response, error) {
func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, opt *ProjectCardListOptions) ([]*ProjectCard, *Response, error) {
u := fmt.Sprintf("projects/columns/%v/cards", columnID)
u, err := addOptions(u, opt)
if err != nil {
@@ -352,6 +363,9 @@ type ProjectCardOptions struct {
ContentID int64 `json:"content_id,omitempty"`
// The type of content to associate with this card. Possible values are: "Issue".
ContentType string `json:"content_type,omitempty"`
// Use true to archive a project card.
// Specify false if you need to restore a previously archived project card.
Archived *bool `json:"archived,omitempty"`
}
// CreateProjectCard creates a card in the specified column of a GitHub Project.

View File

@@ -218,7 +218,7 @@ func (s *RepositoriesService) GetCommitSHA1(ctx context.Context, owner, repo, re
// CompareCommits compares a range of commits with each other.
// todo: support media formats - https://github.com/google/go-github/issues/6
//
// GitHub API docs: https://developer.github.com/v3/repos/commits/index.html#compare-two-commits
// GitHub API docs: https://developer.github.com/v3/repos/commits/#compare-two-commits
func (s *RepositoriesService) CompareCommits(ctx context.Context, owner, repo string, base, head string) (*CommitsComparison, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/compare/%v...%v", owner, repo, base, head)

View File

@@ -21,10 +21,12 @@ type Metric struct {
// CommunityHealthFiles represents the different files in the community health metrics response.
type CommunityHealthFiles struct {
CodeOfConduct *Metric `json:"code_of_conduct"`
Contributing *Metric `json:"contributing"`
License *Metric `json:"license"`
Readme *Metric `json:"readme"`
CodeOfConduct *Metric `json:"code_of_conduct"`
Contributing *Metric `json:"contributing"`
IssueTemplate *Metric `json:"issue_template"`
PullRequestTemplate *Metric `json:"pull_request_template"`
License *Metric `json:"license"`
Readme *Metric `json:"readme"`
}
// CommunityHealthMetrics represents a response containing the community metrics of a repository.