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

CmdRunner now displays ANSI color codes

This commit is contained in:
Chris Cummer
2018-07-18 16:16:28 -07:00
parent 31e77a59ad
commit 6e6d918bfe
25 changed files with 813 additions and 100 deletions

View File

@@ -57,6 +57,8 @@ type Installation struct {
RepositorySelection *string `json:"repository_selection,omitempty"`
Events []string `json:"events,omitempty"`
Permissions *InstallationPermissions `json:"permissions,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
func (i Installation) String() string {

View File

@@ -2828,6 +2828,14 @@ func (i *Installation) GetAppID() int64 {
return *i.AppID
}
// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
func (i *Installation) GetCreatedAt() time.Time {
if i == nil || i.CreatedAt == nil {
return time.Time{}
}
return *i.CreatedAt
}
// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
func (i *Installation) GetHTMLURL() string {
if i == nil || i.HTMLURL == nil {
@@ -2892,6 +2900,14 @@ func (i *Installation) GetTargetType() string {
return *i.TargetType
}
// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise.
func (i *Installation) GetUpdatedAt() time.Time {
if i == nil || i.UpdatedAt == nil {
return time.Time{}
}
return *i.UpdatedAt
}
// GetAction returns the Action field if it's non-nil, zero value otherwise.
func (i *InstallationEvent) GetAction() string {
if i == nil || i.Action == nil {

View File

@@ -45,9 +45,6 @@ const (
// Media Type values to access preview APIs
// https://developer.github.com/changes/2015-03-09-licenses-api/
mediaTypeLicensesPreview = "application/vnd.github.drax-preview+json"
// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"

View File

@@ -67,9 +67,6 @@ func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, erro
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeLicensesPreview)
var licenses []*License
resp, err := s.client.Do(ctx, req, &licenses)
if err != nil {
@@ -90,9 +87,6 @@ func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypeLicensesPreview)
license := new(License)
resp, err := s.client.Do(ctx, req, license)
if err != nil {

View File

@@ -14,7 +14,7 @@ import (
// PullRequestComment represents a comment left on a pull request.
type PullRequestComment struct {
ID *int64 `json:"id,omitempty"`
InReplyTo *int64 `json:"in_reply_to,omitempty"`
InReplyTo *int64 `json:"in_reply_to_id,omitempty"`
Body *string `json:"body,omitempty"`
Path *string `json:"path,omitempty"`
DiffHunk *string `json:"diff_hunk,omitempty"`
@@ -129,6 +129,32 @@ func (s *PullRequestsService) CreateComment(ctx context.Context, owner string, r
return c, resp, nil
}
// CreateCommentInReplyTo creates a new comment as a reply to an existing pull request comment.
//
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#alternative-input
func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner string, repo string, number int, body string, commentID int64) (*PullRequestComment, *Response, error) {
comment := &struct {
Body string `json:"body,omitempty"`
InReplyTo int64 `json:"in_reply_to,omitempty"`
}{
Body: body,
InReplyTo: commentID,
}
u := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number)
req, err := s.client.NewRequest("POST", u, comment)
if err != nil {
return nil, nil, err
}
c := new(PullRequestComment)
resp, err := s.client.Do(ctx, req, c)
if err != nil {
return nil, resp, err
}
return c, resp, nil
}
// EditComment updates a pull request comment.
// A non-nil comment.Body must be provided. Other comment fields should be left nil.
//

View File

@@ -178,7 +178,7 @@ func (s *RepositoriesService) List(ctx context.Context, user string, opt *Reposi
}
// TODO: remove custom Accept headers when APIs fully launch.
acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
acceptHeaders := []string{mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
var repos []*Repository
@@ -216,7 +216,7 @@ func (s *RepositoriesService) ListByOrg(ctx context.Context, org string, opt *Re
}
// TODO: remove custom Accept headers when APIs fully launch.
acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
acceptHeaders := []string{mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
var repos []*Repository
@@ -297,7 +297,7 @@ func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Rep
// TODO: remove custom Accept header when the license support fully launches
// https://developer.github.com/v3/licenses/#get-a-repositorys-license
acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
acceptHeaders := []string{mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
repository := new(Repository)
@@ -341,10 +341,6 @@ func (s *RepositoriesService) GetByID(ctx context.Context, id int64) (*Repositor
return nil, nil, err
}
// TODO: remove custom Accept header when the license support fully launches
// https://developer.github.com/v3/licenses/#get-a-repositorys-license
req.Header.Set("Accept", mediaTypeLicensesPreview)
repository := new(Repository)
resp, err := s.client.Do(ctx, req, repository)
if err != nil {
@@ -1018,7 +1014,7 @@ func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo
// TransferRequest represents a request to transfer a repository.
type TransferRequest struct {
NewOwner string `json:"new_owner"`
TeamID []int64 `json:"team_id,omitempty"`
TeamID []int64 `json:"team_ids,omitempty"`
}
// Transfer transfers a repository from one account or organization to another.

View File

@@ -136,9 +136,13 @@ func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, i
if err != nil {
return nil, nil, err
}
hook := new(Hook)
resp, err := s.client.Do(ctx, req, hook)
return hook, resp, err
h := new(Hook)
resp, err := s.client.Do(ctx, req, h)
if err != nil {
return nil, resp, err
}
return h, resp, nil
}
// EditHook updates a specified Hook.
@@ -152,7 +156,11 @@ func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string,
}
h := new(Hook)
resp, err := s.client.Do(ctx, req, h)
return h, resp, err
if err != nil {
return nil, resp, err
}
return h, resp, nil
}
// DeleteHook deletes a specified Hook.