mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-20 21:34:02 +02:00
fix highwayhash
This commit is contained in:
committed by
Cole Wippern
parent
5a2cfeabba
commit
6b020a1f97
-28
@@ -26,19 +26,15 @@ Andy Lindeman <andy@lindeman.io>
|
||||
Anshuman Bhartiya <anshuman.bhartiya@gmail.com>
|
||||
Antoine Pelisse <apelisse@gmail.com>
|
||||
Anubha Kushwaha <anubha_bt2k14@dtu.ac.in>
|
||||
appilon <apilon@hashicorp.com>
|
||||
Aravind <aravindkp@outlook.in>
|
||||
Arıl Bozoluk <arilbozoluk@hotmail.com>
|
||||
Austin Dizzy <dizzy@wow.com>
|
||||
Ben Batha <bhbatha@gmail.com>
|
||||
Beshr Kayali <beshrkayali@gmail.com>
|
||||
Beyang Liu <beyang.liu@gmail.com>
|
||||
Billy Lynch <wlynch92@gmail.com>
|
||||
Björn Häuser <b.haeuser@rebuy.de>
|
||||
Brad Harris <bmharris@gmail.com>
|
||||
Brad Moylan <moylan.brad@gmail.com>
|
||||
Bradley Falzon <brad@teambrad.net>
|
||||
Brandon Cook <phylake@gmail.com>
|
||||
Brian Egizi <brian@mojotech.com>
|
||||
Bryan Boreham <bryan@weave.works>
|
||||
Cami Diez <diezcami@gmail.com>
|
||||
@@ -58,10 +54,7 @@ Daniel Leavitt <daniel.leavitt@gmail.com>
|
||||
Dave Du Cros <davidducros@gmail.com>
|
||||
Dave Henderson <dhenderson@gmail.com>
|
||||
David Deng <daviddengcn@gmail.com>
|
||||
David Jannotta <djannotta@gmail.com>
|
||||
Davide Zipeto <dawez1@gmail.com>
|
||||
Dennis Webb <dennis@bluesentryit.com>
|
||||
Dhi Aurrahman <diorahman@rockybars.com>
|
||||
Diego Lapiduz <diego.lapiduz@cfpb.gov>
|
||||
Dmitri Shuralyov <shurcooL@gmail.com>
|
||||
dmnlk <seikima2demon@gmail.com>
|
||||
@@ -70,8 +63,6 @@ Doug Turner <doug.turner@gmail.com>
|
||||
Drew Fradette <drew.fradette@gmail.com>
|
||||
Eli Uriegas <seemethere101@gmail.com>
|
||||
Elliott Beach <elliott2.71828@gmail.com>
|
||||
Emerson Wood <emersonwood94@gmail.com>
|
||||
eperm <staffordworrell@gmail.com>
|
||||
erwinvaneyk <erwinvaneyk@gmail.com>
|
||||
Fabrice <fabrice.vaillant@student.ecp.fr>
|
||||
Filippo Valsorda <hi@filippo.io>
|
||||
@@ -80,14 +71,11 @@ Francesc Gil <xescugil@gmail.com>
|
||||
Francis <hello@francismakes.com>
|
||||
Fredrik Jönsson <fredrik.jonsson@izettle.com>
|
||||
Garrett Squire <garrettsquire@gmail.com>
|
||||
George Kontridze <george.kontridze@gmail.com>
|
||||
Georgy Buranov <gburanov@gmail.com>
|
||||
Gnahz <p@oath.pl>
|
||||
Google Inc.
|
||||
griffin_stewie <panterathefamilyguy@gmail.com>
|
||||
Guillaume Jacquet <guillaume.jacquet@gmail.com>
|
||||
Guz Alexander <kalimatas@gmail.com>
|
||||
Guðmundur Bjarni Ólafsson <gudmundur@github.com>
|
||||
Hanno Hecker <hanno.hecker@zalando.de>
|
||||
Hari haran <hariharan.uno@gmail.com>
|
||||
haya14busa <hayabusa1419@gmail.com>
|
||||
@@ -99,19 +87,15 @@ isqua <isqua@isqua.ru>
|
||||
Jameel Haffejee <RC1140@republiccommandos.co.za>
|
||||
Jan Kosecki <jan.kosecki91@gmail.com>
|
||||
Jeremy Morris <jeremylevanmorris@gmail.com>
|
||||
Jesse Newland <jesse@jnewland.com>
|
||||
Jihoon Chung <j.c@navercorp.com>
|
||||
Jimmi Dyson <jimmidyson@gmail.com>
|
||||
Joan Saum <joan.saum@epitech.eu>
|
||||
Joe Tsai <joetsai@digital-static.net>
|
||||
John Barton <jrbarton@gmail.com>
|
||||
John Engelman <john.r.engelman@gmail.com>
|
||||
jpbelanger-mtl <jp.belanger@gmail.com>
|
||||
Juan Basso <jrbasso@gmail.com>
|
||||
Julien Garcia Gonzalez <garciagonzalez.julien@gmail.com>
|
||||
Julien Rostand <jrostand@users.noreply.github.com>
|
||||
Justin Abrahms <justin@abrah.ms>
|
||||
Jusung Lee <e.jusunglee@gmail.com>
|
||||
jzhoucliqr <jzhou@cliqr.com>
|
||||
Katrina Owen <kytrinyx@github.com>
|
||||
Keita Urashima <ursm@ursm.jp>
|
||||
@@ -128,13 +112,10 @@ Luke Roberts <email@luke-roberts.co.uk>
|
||||
Luke Young <luke@hydrantlabs.org>
|
||||
Maksim Zhylinski <uzzable@gmail.com>
|
||||
Martin-Louis Bright <mlbright@gmail.com>
|
||||
Marwan Sulaiman <marwan.sameer@gmail.com>
|
||||
Mat Geist <matgeist@gmail.com>
|
||||
Matt <alpmatthew@gmail.com>
|
||||
Matt Brender <mjbrender@gmail.com>
|
||||
Matt Landis <landis.matt@gmail.com>
|
||||
Maxime Bury <maxime.bury@gmail.com>
|
||||
Michael Spiegel <michael.m.spiegel@gmail.com>
|
||||
Michael Tiller <michael.tiller@gmail.com>
|
||||
Michał Glapa <michal.glapa@gmail.com>
|
||||
Nathan VanBenschoten <nvanbenschoten@gmail.com>
|
||||
@@ -144,34 +125,26 @@ Nick Spragg <nick.spragg@bbc.co.uk>
|
||||
Nikhita Raghunath <nikitaraghunath@gmail.com>
|
||||
Noah Zoschke <noah+sso2@convox.com>
|
||||
ns-cweber <cweber@narrativescience.com>
|
||||
Oleg Kovalov <iamolegkovalov@gmail.com>
|
||||
Ondřej Kupka <ondra.cap@gmail.com>
|
||||
Panagiotis Moustafellos <pmoust@gmail.com>
|
||||
Parham Alvani <parham.alvani@gmail.com>
|
||||
Parker Moore <parkrmoore@gmail.com>
|
||||
parkhyukjun89 <park.hyukjun89@gmail.com>
|
||||
Pavel Shtanko <pavel.shtanko@gmail.com>
|
||||
Pete Wagner <thepwagner@github.com>
|
||||
Petr Shevtsov <petr.shevtsov@gmail.com>
|
||||
Pierre Carrier <pierre@meteor.com>
|
||||
Piotr Zurek <p.zurek@gmail.com>
|
||||
Quinn Slack <qslack@qslack.com>
|
||||
Rackspace US, Inc.
|
||||
Radek Simko <radek.simko@gmail.com>
|
||||
Radliński Ignacy <radlinsk@student.agh.edu.pl>
|
||||
Rajendra arora <rajendraarora16@yahoo.com>
|
||||
RaviTeja Pothana <ravi-teja@live.com>
|
||||
rc1140 <jameel@republiccommandos.co.za>
|
||||
Red Hat, Inc.
|
||||
Rob Figueiredo <robfig@yext.com>
|
||||
Rohit Upadhyay <urohit011@gmail.com>
|
||||
Ronak Jain <ronakjain@outlook.in>
|
||||
Ruben Vereecken <rubenvereecken@gmail.com>
|
||||
Ryan Lower <rpjlower@gmail.com>
|
||||
Sahil Dua <sahildua2305@gmail.com>
|
||||
saisi <saisi@users.noreply.github.com>
|
||||
Sam Minnée <sam@silverstripe.com>
|
||||
Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
|
||||
Sander van Harmelen <svanharmelen@schubergphilis.com>
|
||||
Sanket Payghan <sanket.payghan8@gmail.com>
|
||||
Sarasa Kisaragi <lingsamuelgrace@gmail.com>
|
||||
@@ -179,7 +152,6 @@ Sean Wang <sean@decrypted.org>
|
||||
Sebastian Mandrean <sebastian.mandrean@gmail.com>
|
||||
Sebastian Mæland Pedersen <sem.pedersen@stud.uis.no>
|
||||
Sevki <s@sevki.org>
|
||||
Shagun Khemka <shagun.khemka60@gmail.com>
|
||||
Shawn Catanzarite <me@shawncatz.com>
|
||||
Shawn Smith <shawnpsmith@gmail.com>
|
||||
sona-tar <sona.zip@gmail.com>
|
||||
|
||||
+2
-4
@@ -8,7 +8,6 @@ package github
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// StarredRepository is returned by ListStarred.
|
||||
@@ -85,9 +84,8 @@ func (s *ActivityService) ListStarred(ctx context.Context, user string, opt *Act
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when APIs fully launch
|
||||
acceptHeaders := []string{mediaTypeStarringPreview, mediaTypeTopicsPreview}
|
||||
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||
// TODO: remove custom Accept header when this API fully launches
|
||||
req.Header.Set("Accept", mediaTypeStarringPreview)
|
||||
|
||||
var repos []*StarredRepository
|
||||
resp, err := s.client.Do(ctx, req, &repos)
|
||||
|
||||
-7
@@ -197,13 +197,6 @@ func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, rep
|
||||
return s.getInstallation(ctx, fmt.Sprintf("repos/%v/%v/installation", owner, repo))
|
||||
}
|
||||
|
||||
// FindRepositoryInstallationByID finds the repository's installation information.
|
||||
//
|
||||
// Note: FindRepositoryInstallationByID uses the undocumented GitHub API endpoint /repositories/:id/installation.
|
||||
func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) {
|
||||
return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id))
|
||||
}
|
||||
|
||||
// FindUserInstallation finds the user's installation information.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/apps/#find-repository-installation
|
||||
|
||||
+21
-14
@@ -19,7 +19,6 @@ 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"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
HeadSHA *string `json:"head_sha,omitempty"`
|
||||
ExternalID *string `json:"external_id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
@@ -48,14 +47,14 @@ type CheckRunOutput struct {
|
||||
|
||||
// CheckRunAnnotation represents an annotation object for a CheckRun output.
|
||||
type CheckRunAnnotation struct {
|
||||
Path *string `json:"path,omitempty"`
|
||||
BlobHRef *string `json:"blob_href,omitempty"`
|
||||
StartLine *int `json:"start_line,omitempty"`
|
||||
EndLine *int `json:"end_line,omitempty"`
|
||||
AnnotationLevel *string `json:"annotation_level,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
RawDetails *string `json:"raw_details,omitempty"`
|
||||
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.
|
||||
@@ -68,7 +67,6 @@ type CheckRunImage struct {
|
||||
// CheckSuite represents a suite of check runs.
|
||||
type CheckSuite struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
HeadBranch *string `json:"head_branch,omitempty"`
|
||||
HeadSHA *string `json:"head_sha,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
@@ -403,11 +401,20 @@ func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string
|
||||
return checkSuite, resp, nil
|
||||
}
|
||||
|
||||
// ReRequestCheckSuite triggers GitHub to rerequest an existing check suite, without pushing new code to a repository.
|
||||
// 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/#rerequest-check-suite
|
||||
func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/check-suites/%v/rerequest", owner, repo, checkSuiteID)
|
||||
// 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 {
|
||||
|
||||
+33
-38
@@ -519,7 +519,6 @@ type PullRequestEvent struct {
|
||||
// the pull request was closed with unmerged commits. If the action is "closed"
|
||||
// and the merged key is true, the pull request was merged.
|
||||
Action *string `json:"action,omitempty"`
|
||||
Assignee *User `json:"assignee,omitempty"`
|
||||
Number *int `json:"number,omitempty"`
|
||||
PullRequest *PullRequest `json:"pull_request,omitempty"`
|
||||
|
||||
@@ -533,10 +532,6 @@ type PullRequestEvent struct {
|
||||
Sender *User `json:"sender,omitempty"`
|
||||
Installation *Installation `json:"installation,omitempty"`
|
||||
Label *Label `json:"label,omitempty"` // Populated in "labeled" event deliveries.
|
||||
|
||||
// The following field is only present when the webhook is triggered on
|
||||
// a repository belonging to an organization.
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
}
|
||||
|
||||
// PullRequestReviewEvent is triggered when a review is submitted on a pull
|
||||
@@ -635,39 +630,39 @@ func (p PushEventCommit) String() string {
|
||||
|
||||
// PushEventRepository represents the repo object in a PushEvent payload.
|
||||
type PushEventRepository struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
FullName *string `json:"full_name,omitempty"`
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
Private *bool `json:"private,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Fork *bool `json:"fork,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
PushedAt *Timestamp `json:"pushed_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
Homepage *string `json:"homepage,omitempty"`
|
||||
Size *int `json:"size,omitempty"`
|
||||
StargazersCount *int `json:"stargazers_count,omitempty"`
|
||||
WatchersCount *int `json:"watchers_count,omitempty"`
|
||||
Language *string `json:"language,omitempty"`
|
||||
HasIssues *bool `json:"has_issues,omitempty"`
|
||||
HasDownloads *bool `json:"has_downloads,omitempty"`
|
||||
HasWiki *bool `json:"has_wiki,omitempty"`
|
||||
HasPages *bool `json:"has_pages,omitempty"`
|
||||
ForksCount *int `json:"forks_count,omitempty"`
|
||||
OpenIssuesCount *int `json:"open_issues_count,omitempty"`
|
||||
DefaultBranch *string `json:"default_branch,omitempty"`
|
||||
MasterBranch *string `json:"master_branch,omitempty"`
|
||||
Organization *string `json:"organization,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
ArchiveURL *string `json:"archive_url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
StatusesURL *string `json:"statuses_url,omitempty"`
|
||||
GitURL *string `json:"git_url,omitempty"`
|
||||
SSHURL *string `json:"ssh_url,omitempty"`
|
||||
CloneURL *string `json:"clone_url,omitempty"`
|
||||
SVNURL *string `json:"svn_url,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
FullName *string `json:"full_name,omitempty"`
|
||||
Owner *PushEventRepoOwner `json:"owner,omitempty"`
|
||||
Private *bool `json:"private,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Fork *bool `json:"fork,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
PushedAt *Timestamp `json:"pushed_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
Homepage *string `json:"homepage,omitempty"`
|
||||
Size *int `json:"size,omitempty"`
|
||||
StargazersCount *int `json:"stargazers_count,omitempty"`
|
||||
WatchersCount *int `json:"watchers_count,omitempty"`
|
||||
Language *string `json:"language,omitempty"`
|
||||
HasIssues *bool `json:"has_issues,omitempty"`
|
||||
HasDownloads *bool `json:"has_downloads,omitempty"`
|
||||
HasWiki *bool `json:"has_wiki,omitempty"`
|
||||
HasPages *bool `json:"has_pages,omitempty"`
|
||||
ForksCount *int `json:"forks_count,omitempty"`
|
||||
OpenIssuesCount *int `json:"open_issues_count,omitempty"`
|
||||
DefaultBranch *string `json:"default_branch,omitempty"`
|
||||
MasterBranch *string `json:"master_branch,omitempty"`
|
||||
Organization *string `json:"organization,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
ArchiveURL *string `json:"archive_url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
StatusesURL *string `json:"statuses_url,omitempty"`
|
||||
GitURL *string `json:"git_url,omitempty"`
|
||||
SSHURL *string `json:"ssh_url,omitempty"`
|
||||
CloneURL *string `json:"clone_url,omitempty"`
|
||||
SVNURL *string `json:"svn_url,omitempty"`
|
||||
}
|
||||
|
||||
// PushEventRepoOwner is a basic representation of user/org in a PushEvent payload.
|
||||
|
||||
-332
@@ -1,332 +0,0 @@
|
||||
// Copyright 2017 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.
|
||||
|
||||
// +build ignore
|
||||
|
||||
// gen-accessors generates accessor methods for structs with pointer fields.
|
||||
//
|
||||
// It is meant to be used by the go-github authors in conjunction with the
|
||||
// go generate tool before sending a commit to GitHub.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const (
|
||||
fileSuffix = "-accessors.go"
|
||||
)
|
||||
|
||||
var (
|
||||
verbose = flag.Bool("v", false, "Print verbose log messages")
|
||||
|
||||
sourceTmpl = template.Must(template.New("source").Parse(source))
|
||||
|
||||
// blacklistStructMethod lists "struct.method" combos to skip.
|
||||
blacklistStructMethod = map[string]bool{
|
||||
"RepositoryContent.GetContent": true,
|
||||
"Client.GetBaseURL": true,
|
||||
"Client.GetUploadURL": true,
|
||||
"ErrorResponse.GetResponse": true,
|
||||
"RateLimitError.GetResponse": true,
|
||||
"AbuseRateLimitError.GetResponse": true,
|
||||
}
|
||||
// blacklistStruct lists structs to skip.
|
||||
blacklistStruct = map[string]bool{
|
||||
"Client": true,
|
||||
}
|
||||
)
|
||||
|
||||
func logf(fmt string, args ...interface{}) {
|
||||
if *verbose {
|
||||
log.Printf(fmt, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fset := token.NewFileSet()
|
||||
|
||||
pkgs, err := parser.ParseDir(fset, ".", sourceFilter, 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
for pkgName, pkg := range pkgs {
|
||||
t := &templateData{
|
||||
filename: pkgName + fileSuffix,
|
||||
Year: 2017,
|
||||
Package: pkgName,
|
||||
Imports: map[string]string{},
|
||||
}
|
||||
for filename, f := range pkg.Files {
|
||||
logf("Processing %v...", filename)
|
||||
if err := t.processAST(f); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := t.dump(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
logf("Done.")
|
||||
}
|
||||
|
||||
func (t *templateData) processAST(f *ast.File) error {
|
||||
for _, decl := range f.Decls {
|
||||
gd, ok := decl.(*ast.GenDecl)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, spec := range gd.Specs {
|
||||
ts, ok := spec.(*ast.TypeSpec)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
// Skip unexported identifiers.
|
||||
if !ts.Name.IsExported() {
|
||||
logf("Struct %v is unexported; skipping.", ts.Name)
|
||||
continue
|
||||
}
|
||||
// Check if the struct is blacklisted.
|
||||
if blacklistStruct[ts.Name.Name] {
|
||||
logf("Struct %v is blacklisted; skipping.", ts.Name)
|
||||
continue
|
||||
}
|
||||
st, ok := ts.Type.(*ast.StructType)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, field := range st.Fields.List {
|
||||
se, ok := field.Type.(*ast.StarExpr)
|
||||
if len(field.Names) == 0 || !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
fieldName := field.Names[0]
|
||||
// Skip unexported identifiers.
|
||||
if !fieldName.IsExported() {
|
||||
logf("Field %v is unexported; skipping.", fieldName)
|
||||
continue
|
||||
}
|
||||
// Check if "struct.method" is blacklisted.
|
||||
if key := fmt.Sprintf("%v.Get%v", ts.Name, fieldName); blacklistStructMethod[key] {
|
||||
logf("Method %v is blacklisted; skipping.", key)
|
||||
continue
|
||||
}
|
||||
|
||||
switch x := se.X.(type) {
|
||||
case *ast.ArrayType:
|
||||
t.addArrayType(x, ts.Name.String(), fieldName.String())
|
||||
case *ast.Ident:
|
||||
t.addIdent(x, ts.Name.String(), fieldName.String())
|
||||
case *ast.MapType:
|
||||
t.addMapType(x, ts.Name.String(), fieldName.String())
|
||||
case *ast.SelectorExpr:
|
||||
t.addSelectorExpr(x, ts.Name.String(), fieldName.String())
|
||||
default:
|
||||
logf("processAST: type %q, field %q, unknown %T: %+v", ts.Name, fieldName, x, x)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sourceFilter(fi os.FileInfo) bool {
|
||||
return !strings.HasSuffix(fi.Name(), "_test.go") && !strings.HasSuffix(fi.Name(), fileSuffix)
|
||||
}
|
||||
|
||||
func (t *templateData) dump() error {
|
||||
if len(t.Getters) == 0 {
|
||||
logf("No getters for %v; skipping.", t.filename)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sort getters by ReceiverType.FieldName.
|
||||
sort.Sort(byName(t.Getters))
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := sourceTmpl.Execute(&buf, t); err != nil {
|
||||
return err
|
||||
}
|
||||
clean, err := format.Source(buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logf("Writing %v...", t.filename)
|
||||
return ioutil.WriteFile(t.filename, clean, 0644)
|
||||
}
|
||||
|
||||
func newGetter(receiverType, fieldName, fieldType, zeroValue string, namedStruct bool) *getter {
|
||||
return &getter{
|
||||
sortVal: strings.ToLower(receiverType) + "." + strings.ToLower(fieldName),
|
||||
ReceiverVar: strings.ToLower(receiverType[:1]),
|
||||
ReceiverType: receiverType,
|
||||
FieldName: fieldName,
|
||||
FieldType: fieldType,
|
||||
ZeroValue: zeroValue,
|
||||
NamedStruct: namedStruct,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *templateData) addArrayType(x *ast.ArrayType, receiverType, fieldName string) {
|
||||
var eltType string
|
||||
switch elt := x.Elt.(type) {
|
||||
case *ast.Ident:
|
||||
eltType = elt.String()
|
||||
default:
|
||||
logf("addArrayType: type %q, field %q: unknown elt type: %T %+v; skipping.", receiverType, fieldName, elt, elt)
|
||||
return
|
||||
}
|
||||
|
||||
t.Getters = append(t.Getters, newGetter(receiverType, fieldName, "[]"+eltType, "nil", false))
|
||||
}
|
||||
|
||||
func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) {
|
||||
var zeroValue string
|
||||
var namedStruct = false
|
||||
switch x.String() {
|
||||
case "int", "int64":
|
||||
zeroValue = "0"
|
||||
case "string":
|
||||
zeroValue = `""`
|
||||
case "bool":
|
||||
zeroValue = "false"
|
||||
case "Timestamp":
|
||||
zeroValue = "Timestamp{}"
|
||||
default:
|
||||
zeroValue = "nil"
|
||||
namedStruct = true
|
||||
}
|
||||
|
||||
t.Getters = append(t.Getters, newGetter(receiverType, fieldName, x.String(), zeroValue, namedStruct))
|
||||
}
|
||||
|
||||
func (t *templateData) addMapType(x *ast.MapType, receiverType, fieldName string) {
|
||||
var keyType string
|
||||
switch key := x.Key.(type) {
|
||||
case *ast.Ident:
|
||||
keyType = key.String()
|
||||
default:
|
||||
logf("addMapType: type %q, field %q: unknown key type: %T %+v; skipping.", receiverType, fieldName, key, key)
|
||||
return
|
||||
}
|
||||
|
||||
var valueType string
|
||||
switch value := x.Value.(type) {
|
||||
case *ast.Ident:
|
||||
valueType = value.String()
|
||||
default:
|
||||
logf("addMapType: type %q, field %q: unknown value type: %T %+v; skipping.", receiverType, fieldName, value, value)
|
||||
return
|
||||
}
|
||||
|
||||
fieldType := fmt.Sprintf("map[%v]%v", keyType, valueType)
|
||||
zeroValue := fmt.Sprintf("map[%v]%v{}", keyType, valueType)
|
||||
t.Getters = append(t.Getters, newGetter(receiverType, fieldName, fieldType, zeroValue, false))
|
||||
}
|
||||
|
||||
func (t *templateData) addSelectorExpr(x *ast.SelectorExpr, receiverType, fieldName string) {
|
||||
if strings.ToLower(fieldName[:1]) == fieldName[:1] { // Non-exported field.
|
||||
return
|
||||
}
|
||||
|
||||
var xX string
|
||||
if xx, ok := x.X.(*ast.Ident); ok {
|
||||
xX = xx.String()
|
||||
}
|
||||
|
||||
switch xX {
|
||||
case "time", "json":
|
||||
if xX == "json" {
|
||||
t.Imports["encoding/json"] = "encoding/json"
|
||||
} else {
|
||||
t.Imports[xX] = xX
|
||||
}
|
||||
fieldType := fmt.Sprintf("%v.%v", xX, x.Sel.Name)
|
||||
zeroValue := fmt.Sprintf("%v.%v{}", xX, x.Sel.Name)
|
||||
if xX == "time" && x.Sel.Name == "Duration" {
|
||||
zeroValue = "0"
|
||||
}
|
||||
t.Getters = append(t.Getters, newGetter(receiverType, fieldName, fieldType, zeroValue, false))
|
||||
default:
|
||||
logf("addSelectorExpr: xX %q, type %q, field %q: unknown x=%+v; skipping.", xX, receiverType, fieldName, x)
|
||||
}
|
||||
}
|
||||
|
||||
type templateData struct {
|
||||
filename string
|
||||
Year int
|
||||
Package string
|
||||
Imports map[string]string
|
||||
Getters []*getter
|
||||
}
|
||||
|
||||
type getter struct {
|
||||
sortVal string // Lower-case version of "ReceiverType.FieldName".
|
||||
ReceiverVar string // The one-letter variable name to match the ReceiverType.
|
||||
ReceiverType string
|
||||
FieldName string
|
||||
FieldType string
|
||||
ZeroValue string
|
||||
NamedStruct bool // Getter for named struct.
|
||||
}
|
||||
|
||||
type byName []*getter
|
||||
|
||||
func (b byName) Len() int { return len(b) }
|
||||
func (b byName) Less(i, j int) bool { return b[i].sortVal < b[j].sortVal }
|
||||
func (b byName) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
|
||||
|
||||
const source = `// Copyright {{.Year}} 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.
|
||||
|
||||
// Code generated by gen-accessors; DO NOT EDIT.
|
||||
|
||||
package {{.Package}}
|
||||
{{with .Imports}}
|
||||
import (
|
||||
{{- range . -}}
|
||||
"{{.}}"
|
||||
{{end -}}
|
||||
)
|
||||
{{end}}
|
||||
{{range .Getters}}
|
||||
{{if .NamedStruct}}
|
||||
// Get{{.FieldName}} returns the {{.FieldName}} field.
|
||||
func ({{.ReceiverVar}} *{{.ReceiverType}}) Get{{.FieldName}}() *{{.FieldType}} {
|
||||
if {{.ReceiverVar}} == nil {
|
||||
return {{.ZeroValue}}
|
||||
}
|
||||
return {{.ReceiverVar}}.{{.FieldName}}
|
||||
}
|
||||
{{else}}
|
||||
// Get{{.FieldName}} returns the {{.FieldName}} field if it's non-nil, zero value otherwise.
|
||||
func ({{.ReceiverVar}} *{{.ReceiverType}}) Get{{.FieldName}}() {{.FieldType}} {
|
||||
if {{.ReceiverVar}} == nil || {{.ReceiverVar}}.{{.FieldName}} == nil {
|
||||
return {{.ZeroValue}}
|
||||
}
|
||||
return *{{.ReceiverVar}}.{{.FieldName}}
|
||||
}
|
||||
{{end}}
|
||||
{{end}}
|
||||
`
|
||||
+17
-241
@@ -532,14 +532,6 @@ func (c *CheckRun) GetName() string {
|
||||
return *c.Name
|
||||
}
|
||||
|
||||
// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise.
|
||||
func (c *CheckRun) GetNodeID() string {
|
||||
if c == nil || c.NodeID == nil {
|
||||
return ""
|
||||
}
|
||||
return *c.NodeID
|
||||
}
|
||||
|
||||
// GetOutput returns the Output field.
|
||||
func (c *CheckRun) GetOutput() *CheckRunOutput {
|
||||
if c == nil {
|
||||
@@ -572,14 +564,6 @@ func (c *CheckRun) GetURL() string {
|
||||
return *c.URL
|
||||
}
|
||||
|
||||
// GetAnnotationLevel returns the AnnotationLevel field if it's non-nil, zero value otherwise.
|
||||
func (c *CheckRunAnnotation) GetAnnotationLevel() string {
|
||||
if c == nil || c.AnnotationLevel == nil {
|
||||
return ""
|
||||
}
|
||||
return *c.AnnotationLevel
|
||||
}
|
||||
|
||||
// GetBlobHRef returns the BlobHRef field if it's non-nil, zero value otherwise.
|
||||
func (c *CheckRunAnnotation) GetBlobHRef() string {
|
||||
if c == nil || c.BlobHRef == nil {
|
||||
@@ -596,6 +580,14 @@ func (c *CheckRunAnnotation) GetEndLine() int {
|
||||
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 {
|
||||
@@ -604,14 +596,6 @@ func (c *CheckRunAnnotation) GetMessage() string {
|
||||
return *c.Message
|
||||
}
|
||||
|
||||
// GetPath returns the Path field if it's non-nil, zero value otherwise.
|
||||
func (c *CheckRunAnnotation) GetPath() string {
|
||||
if c == nil || c.Path == nil {
|
||||
return ""
|
||||
}
|
||||
return *c.Path
|
||||
}
|
||||
|
||||
// GetRawDetails returns the RawDetails field if it's non-nil, zero value otherwise.
|
||||
func (c *CheckRunAnnotation) GetRawDetails() string {
|
||||
if c == nil || c.RawDetails == nil {
|
||||
@@ -636,6 +620,14 @@ func (c *CheckRunAnnotation) GetTitle() string {
|
||||
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 {
|
||||
@@ -804,14 +796,6 @@ func (c *CheckSuite) GetID() int64 {
|
||||
return *c.ID
|
||||
}
|
||||
|
||||
// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise.
|
||||
func (c *CheckSuite) GetNodeID() string {
|
||||
if c == nil || c.NodeID == nil {
|
||||
return ""
|
||||
}
|
||||
return *c.NodeID
|
||||
}
|
||||
|
||||
// GetRepository returns the Repository field.
|
||||
func (c *CheckSuite) GetRepository() *Repository {
|
||||
if c == nil {
|
||||
@@ -2396,14 +2380,6 @@ func (d *DiscussionComment) GetNumber() int {
|
||||
return *d.Number
|
||||
}
|
||||
|
||||
// GetReactions returns the Reactions field.
|
||||
func (d *DiscussionComment) GetReactions() *Reactions {
|
||||
if d == nil {
|
||||
return nil
|
||||
}
|
||||
return d.Reactions
|
||||
}
|
||||
|
||||
// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise.
|
||||
func (d *DiscussionComment) GetUpdatedAt() Timestamp {
|
||||
if d == nil || d.UpdatedAt == nil {
|
||||
@@ -3884,14 +3860,6 @@ func (i *IssueComment) GetIssueURL() string {
|
||||
return *i.IssueURL
|
||||
}
|
||||
|
||||
// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise.
|
||||
func (i *IssueComment) GetNodeID() string {
|
||||
if i == nil || i.NodeID == nil {
|
||||
return ""
|
||||
}
|
||||
return *i.NodeID
|
||||
}
|
||||
|
||||
// GetReactions returns the Reactions field.
|
||||
func (i *IssueComment) GetReactions() *Reactions {
|
||||
if i == nil {
|
||||
@@ -5740,14 +5708,6 @@ func (o *Organization) GetTotalPrivateRepos() int {
|
||||
return *o.TotalPrivateRepos
|
||||
}
|
||||
|
||||
// GetTwoFactorRequirementEnabled returns the TwoFactorRequirementEnabled field if it's non-nil, zero value otherwise.
|
||||
func (o *Organization) GetTwoFactorRequirementEnabled() bool {
|
||||
if o == nil || o.TwoFactorRequirementEnabled == nil {
|
||||
return false
|
||||
}
|
||||
return *o.TwoFactorRequirementEnabled
|
||||
}
|
||||
|
||||
// GetType returns the Type field if it's non-nil, zero value otherwise.
|
||||
func (o *Organization) GetType() string {
|
||||
if o == nil || o.Type == nil {
|
||||
@@ -6196,78 +6156,6 @@ func (p *PreReceiveHook) GetName() string {
|
||||
return *p.Name
|
||||
}
|
||||
|
||||
// GetHRef returns the HRef field if it's non-nil, zero value otherwise.
|
||||
func (p *PRLink) GetHRef() string {
|
||||
if p == nil || p.HRef == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.HRef
|
||||
}
|
||||
|
||||
// GetComments returns the Comments field.
|
||||
func (p *PRLinks) GetComments() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Comments
|
||||
}
|
||||
|
||||
// GetCommits returns the Commits field.
|
||||
func (p *PRLinks) GetCommits() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Commits
|
||||
}
|
||||
|
||||
// GetHTML returns the HTML field.
|
||||
func (p *PRLinks) GetHTML() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.HTML
|
||||
}
|
||||
|
||||
// GetIssue returns the Issue field.
|
||||
func (p *PRLinks) GetIssue() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Issue
|
||||
}
|
||||
|
||||
// GetReviewComment returns the ReviewComment field.
|
||||
func (p *PRLinks) GetReviewComment() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.ReviewComment
|
||||
}
|
||||
|
||||
// GetReviewComments returns the ReviewComments field.
|
||||
func (p *PRLinks) GetReviewComments() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.ReviewComments
|
||||
}
|
||||
|
||||
// GetSelf returns the Self field.
|
||||
func (p *PRLinks) GetSelf() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Self
|
||||
}
|
||||
|
||||
// GetStatuses returns the Statuses field.
|
||||
func (p *PRLinks) GetStatuses() *PRLink {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Statuses
|
||||
}
|
||||
|
||||
// GetBody returns the Body field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetBody() string {
|
||||
if p == nil || p.Body == nil {
|
||||
@@ -6276,14 +6164,6 @@ func (p *Project) GetBody() string {
|
||||
return *p.Body
|
||||
}
|
||||
|
||||
// GetColumnsURL returns the ColumnsURL field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetColumnsURL() string {
|
||||
if p == nil || p.ColumnsURL == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.ColumnsURL
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetCreatedAt() Timestamp {
|
||||
if p == nil || p.CreatedAt == nil {
|
||||
@@ -6300,14 +6180,6 @@ func (p *Project) GetCreator() *User {
|
||||
return p.Creator
|
||||
}
|
||||
|
||||
// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetHTMLURL() string {
|
||||
if p == nil || p.HTMLURL == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.HTMLURL
|
||||
}
|
||||
|
||||
// GetID returns the ID field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetID() int64 {
|
||||
if p == nil || p.ID == nil {
|
||||
@@ -6348,14 +6220,6 @@ func (p *Project) GetOwnerURL() string {
|
||||
return *p.OwnerURL
|
||||
}
|
||||
|
||||
// GetState returns the State field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetState() string {
|
||||
if p == nil || p.State == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.State
|
||||
}
|
||||
|
||||
// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise.
|
||||
func (p *Project) GetUpdatedAt() Timestamp {
|
||||
if p == nil || p.UpdatedAt == nil {
|
||||
@@ -6540,14 +6404,6 @@ func (p *ProjectCardOptions) GetArchived() bool {
|
||||
return *p.Archived
|
||||
}
|
||||
|
||||
// GetCardsURL returns the CardsURL field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectColumn) GetCardsURL() string {
|
||||
if p == nil || p.CardsURL == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.CardsURL
|
||||
}
|
||||
|
||||
// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectColumn) GetCreatedAt() Timestamp {
|
||||
if p == nil || p.CreatedAt == nil {
|
||||
@@ -6596,14 +6452,6 @@ func (p *ProjectColumn) GetUpdatedAt() Timestamp {
|
||||
return *p.UpdatedAt
|
||||
}
|
||||
|
||||
// GetURL returns the URL field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectColumn) GetURL() string {
|
||||
if p == nil || p.URL == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.URL
|
||||
}
|
||||
|
||||
// GetAction returns the Action field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectColumnEvent) GetAction() string {
|
||||
if p == nil || p.Action == nil {
|
||||
@@ -6724,46 +6572,6 @@ func (p *ProjectEvent) GetSender() *User {
|
||||
return p.Sender
|
||||
}
|
||||
|
||||
// GetBody returns the Body field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectOptions) GetBody() string {
|
||||
if p == nil || p.Body == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.Body
|
||||
}
|
||||
|
||||
// GetName returns the Name field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectOptions) GetName() string {
|
||||
if p == nil || p.Name == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.Name
|
||||
}
|
||||
|
||||
// GetOrganizationPermission returns the OrganizationPermission field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectOptions) GetOrganizationPermission() string {
|
||||
if p == nil || p.OrganizationPermission == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.OrganizationPermission
|
||||
}
|
||||
|
||||
// GetPublic returns the Public field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectOptions) GetPublic() bool {
|
||||
if p == nil || p.Public == nil {
|
||||
return false
|
||||
}
|
||||
return *p.Public
|
||||
}
|
||||
|
||||
// GetState returns the State field if it's non-nil, zero value otherwise.
|
||||
func (p *ProjectOptions) GetState() string {
|
||||
if p == nil || p.State == nil {
|
||||
return ""
|
||||
}
|
||||
return *p.State
|
||||
}
|
||||
|
||||
// GetEnforceAdmins returns the EnforceAdmins field.
|
||||
func (p *Protection) GetEnforceAdmins() *AdminEnforcement {
|
||||
if p == nil {
|
||||
@@ -6996,14 +6804,6 @@ func (p *PullRequest) GetIssueURL() string {
|
||||
return *p.IssueURL
|
||||
}
|
||||
|
||||
// GetLinks returns the Links field.
|
||||
func (p *PullRequest) GetLinks() *PRLinks {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Links
|
||||
}
|
||||
|
||||
// GetMaintainerCanModify returns the MaintainerCanModify field if it's non-nil, zero value otherwise.
|
||||
func (p *PullRequest) GetMaintainerCanModify() bool {
|
||||
if p == nil || p.MaintainerCanModify == nil {
|
||||
@@ -7348,14 +7148,6 @@ func (p *PullRequestEvent) GetAction() string {
|
||||
return *p.Action
|
||||
}
|
||||
|
||||
// GetAssignee returns the Assignee field.
|
||||
func (p *PullRequestEvent) GetAssignee() *User {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Assignee
|
||||
}
|
||||
|
||||
// GetChanges returns the Changes field.
|
||||
func (p *PullRequestEvent) GetChanges() *EditChange {
|
||||
if p == nil {
|
||||
@@ -7388,14 +7180,6 @@ func (p *PullRequestEvent) GetNumber() int {
|
||||
return *p.Number
|
||||
}
|
||||
|
||||
// GetOrganization returns the Organization field.
|
||||
func (p *PullRequestEvent) GetOrganization() *Organization {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p.Organization
|
||||
}
|
||||
|
||||
// GetPullRequest returns the PullRequest field.
|
||||
func (p *PullRequestEvent) GetPullRequest() *PullRequest {
|
||||
if p == nil {
|
||||
@@ -8173,7 +7957,7 @@ func (p *PushEventRepository) GetOrganization() string {
|
||||
}
|
||||
|
||||
// GetOwner returns the Owner field.
|
||||
func (p *PushEventRepository) GetOwner() *User {
|
||||
func (p *PushEventRepository) GetOwner() *PushEventRepoOwner {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -10700,14 +10484,6 @@ func (t *TeamDiscussion) GetPrivate() bool {
|
||||
return *t.Private
|
||||
}
|
||||
|
||||
// GetReactions returns the Reactions field.
|
||||
func (t *TeamDiscussion) GetReactions() *Reactions {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
return t.Reactions
|
||||
}
|
||||
|
||||
// GetTeamURL returns the TeamURL field if it's non-nil, zero value otherwise.
|
||||
func (t *TeamDiscussion) GetTeamURL() string {
|
||||
if t == nil || t.TeamURL == nil {
|
||||
|
||||
+1
-3
@@ -375,9 +375,7 @@ type Response struct {
|
||||
FirstPage int
|
||||
LastPage int
|
||||
|
||||
// Explicitly specify the Rate type so Rate's String() receiver doesn't
|
||||
// propagate to Response.
|
||||
Rate Rate
|
||||
Rate
|
||||
}
|
||||
|
||||
// newResponse creates a new Response for the provided http.Response.
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo strin
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept headers when APIs fully launch.
|
||||
acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeLabelDescriptionSearchPreview, mediaTypeIntegrationPreview}
|
||||
acceptHeaders := []string{mediaTypeReactionsPreview, mediaTypeLabelDescriptionSearchPreview, mediaTypeLockReasonPreview}
|
||||
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||
|
||||
var issues []*Issue
|
||||
|
||||
-1
@@ -14,7 +14,6 @@ import (
|
||||
// IssueComment represents a comment left on an issue.
|
||||
type IssueComment struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
User *User `json:"user,omitempty"`
|
||||
Reactions *Reactions `json:"reactions,omitempty"`
|
||||
|
||||
+3
-3
@@ -175,19 +175,19 @@ func ValidatePayload(r *http.Request, secretKey []byte) (payload []byte, err err
|
||||
}
|
||||
|
||||
sig := r.Header.Get(signatureHeader)
|
||||
if err := ValidateSignature(sig, body, secretKey); err != nil {
|
||||
if err := validateSignature(sig, body, secretKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
// ValidateSignature validates the signature for the given payload.
|
||||
// validateSignature validates the signature for the given payload.
|
||||
// signature is the GitHub hash signature delivered in the X-Hub-Signature header.
|
||||
// payload is the JSON payload sent by GitHub Webhooks.
|
||||
// secretKey is the GitHub Webhook secret message.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/webhooks/securing/#validating-payloads-from-github
|
||||
func ValidateSignature(signature string, payload, secretKey []byte) error {
|
||||
func validateSignature(signature string, payload, secretKey []byte) error {
|
||||
messageMAC, hashFunc, err := messageMAC(signature)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+25
-26
@@ -19,32 +19,31 @@ type OrganizationsService service
|
||||
|
||||
// Organization represents a GitHub organization account.
|
||||
type Organization struct {
|
||||
Login *string `json:"login,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Company *string `json:"company,omitempty"`
|
||||
Blog *string `json:"blog,omitempty"`
|
||||
Location *string `json:"location,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
PublicRepos *int `json:"public_repos,omitempty"`
|
||||
PublicGists *int `json:"public_gists,omitempty"`
|
||||
Followers *int `json:"followers,omitempty"`
|
||||
Following *int `json:"following,omitempty"`
|
||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||
TotalPrivateRepos *int `json:"total_private_repos,omitempty"`
|
||||
OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"`
|
||||
PrivateGists *int `json:"private_gists,omitempty"`
|
||||
DiskUsage *int `json:"disk_usage,omitempty"`
|
||||
Collaborators *int `json:"collaborators,omitempty"`
|
||||
BillingEmail *string `json:"billing_email,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
Plan *Plan `json:"plan,omitempty"`
|
||||
TwoFactorRequirementEnabled *bool `json:"two_factor_requirement_enabled,omitempty"`
|
||||
Login *string `json:"login,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Company *string `json:"company,omitempty"`
|
||||
Blog *string `json:"blog,omitempty"`
|
||||
Location *string `json:"location,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
PublicRepos *int `json:"public_repos,omitempty"`
|
||||
PublicGists *int `json:"public_gists,omitempty"`
|
||||
Followers *int `json:"followers,omitempty"`
|
||||
Following *int `json:"following,omitempty"`
|
||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||
TotalPrivateRepos *int `json:"total_private_repos,omitempty"`
|
||||
OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"`
|
||||
PrivateGists *int `json:"private_gists,omitempty"`
|
||||
DiskUsage *int `json:"disk_usage,omitempty"`
|
||||
Collaborators *int `json:"collaborators,omitempty"`
|
||||
BillingEmail *string `json:"billing_email,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
Plan *Plan `json:"plan,omitempty"`
|
||||
|
||||
// API URLs
|
||||
URL *string `json:"url,omitempty"`
|
||||
|
||||
+1
-12
@@ -51,21 +51,10 @@ func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64
|
||||
// CreateHook creates a Hook for the specified org.
|
||||
// Name and Config are required fields.
|
||||
//
|
||||
// Note that only a subset of the hook fields are used and hook must
|
||||
// not be nil.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/orgs/hooks/#create-a-hook
|
||||
func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("orgs/%v/hooks", org)
|
||||
|
||||
hookReq := &createHookRequest{
|
||||
Name: hook.Name,
|
||||
Events: hook.Events,
|
||||
Active: hook.Active,
|
||||
Config: hook.Config,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, hookReq)
|
||||
req, err := s.client.NewRequest("POST", u, hook)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
+12
-26
@@ -18,18 +18,15 @@ type ProjectsService service
|
||||
|
||||
// Project represents a GitHub Project.
|
||||
type Project struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
ColumnsURL *string `json:"columns_url,omitempty"`
|
||||
OwnerURL *string `json:"owner_url,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Number *int `json:"number,omitempty"`
|
||||
State *string `json:"state,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
OwnerURL *string `json:"owner_url,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Number *int `json:"number,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
|
||||
// The User object that generated the project.
|
||||
Creator *User `json:"creator,omitempty"`
|
||||
@@ -66,24 +63,15 @@ func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *
|
||||
// ProjectsService.UpdateProject methods.
|
||||
type ProjectOptions struct {
|
||||
// The name of the project. (Required for creation; optional for update.)
|
||||
Name *string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// The body of the project. (Optional.)
|
||||
Body *string `json:"body,omitempty"`
|
||||
Body string `json:"body,omitempty"`
|
||||
|
||||
// The following field(s) are only applicable for update.
|
||||
// They should be left with zero values for creation.
|
||||
|
||||
// State of the project. Either "open" or "closed". (Optional.)
|
||||
State *string `json:"state,omitempty"`
|
||||
// The permission level that all members of the project's organization
|
||||
// will have on this project.
|
||||
// Setting the organization permission is only available
|
||||
// for organization projects. (Optional.)
|
||||
OrganizationPermission *string `json:"organization_permission,omitempty"`
|
||||
// Sets visibility of the project within the organization.
|
||||
// Setting visibility is only available
|
||||
// for organization projects.(Optional.)
|
||||
Public *bool `json:"public,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateProject updates a repository project.
|
||||
@@ -130,9 +118,7 @@ func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Respons
|
||||
type ProjectColumn struct {
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
ProjectURL *string `json:"project_url,omitempty"`
|
||||
CardsURL *string `json:"cards_url,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
|
||||
+2
-20
@@ -60,9 +60,8 @@ type PullRequest struct {
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
RequestedReviewers []*User `json:"requested_reviewers,omitempty"`
|
||||
|
||||
Links *PRLinks `json:"_links,omitempty"`
|
||||
Head *PullRequestBranch `json:"head,omitempty"`
|
||||
Base *PullRequestBranch `json:"base,omitempty"`
|
||||
Head *PullRequestBranch `json:"head,omitempty"`
|
||||
Base *PullRequestBranch `json:"base,omitempty"`
|
||||
|
||||
// ActiveLockReason is populated only when LockReason is provided while locking the pull request.
|
||||
// Possible values are: "off-topic", "too heated", "resolved", and "spam".
|
||||
@@ -73,23 +72,6 @@ func (p PullRequest) String() string {
|
||||
return Stringify(p)
|
||||
}
|
||||
|
||||
// PRLink represents a single link object from Github pull request _links.
|
||||
type PRLink struct {
|
||||
HRef *string `json:"href,omitempty"`
|
||||
}
|
||||
|
||||
// PRLinks represents the "_links" object in a Github pull request.
|
||||
type PRLinks struct {
|
||||
Self *PRLink `json:"self,omitempty"`
|
||||
HTML *PRLink `json:"html,omitempty"`
|
||||
Issue *PRLink `json:"issue,omitempty"`
|
||||
Comments *PRLink `json:"comments,omitempty"`
|
||||
ReviewComments *PRLink `json:"review_comments,omitempty"`
|
||||
ReviewComment *PRLink `json:"review_comment,omitempty"`
|
||||
Commits *PRLink `json:"commits,omitempty"`
|
||||
Statuses *PRLink `json:"statuses,omitempty"`
|
||||
}
|
||||
|
||||
// PullRequestBranch represents a base or head branch in a GitHub pull request.
|
||||
type PullRequestBranch struct {
|
||||
Label *string `json:"label,omitempty"`
|
||||
|
||||
-101
@@ -74,7 +74,6 @@ func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo
|
||||
// CreateCommentReaction creates a reaction for a commit comment.
|
||||
// Note that if you have already created a reaction of type content, the
|
||||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment
|
||||
func (s ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
|
||||
@@ -128,7 +127,6 @@ func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo s
|
||||
// CreateIssueReaction creates a reaction for an issue.
|
||||
// Note that if you have already created a reaction of type content, the
|
||||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-an-issue
|
||||
func (s ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) {
|
||||
@@ -182,7 +180,6 @@ func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner,
|
||||
// CreateIssueCommentReaction creates a reaction for an issue comment.
|
||||
// Note that if you have already created a reaction of type content, the
|
||||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
|
||||
func (s ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
|
||||
@@ -236,7 +233,6 @@ func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context,
|
||||
// CreatePullRequestCommentReaction creates a reaction for a pull request review comment.
|
||||
// Note that if you have already created a reaction of type content, the
|
||||
// previously created reaction will be returned with Status: 200 OK.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
|
||||
func (s ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
|
||||
@@ -260,103 +256,6 @@ func (s ReactionsService) CreatePullRequestCommentReaction(ctx context.Context,
|
||||
return m, resp, nil
|
||||
}
|
||||
|
||||
// ListTeamDiscussionReactions lists the reactions for a team discussion.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#list-reactions-for-a-team-discussion
|
||||
func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, teamID int64, discussionNumber int, opt *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber)
|
||||
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", mediaTypeReactionsPreview)
|
||||
|
||||
var m []*Reaction
|
||||
resp, err := s.client.Do(ctx, req, &m)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return m, resp, nil
|
||||
}
|
||||
|
||||
// CreateTeamDiscussionReaction creates a reaction for a team discussion.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-a-team-discussion
|
||||
func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber)
|
||||
|
||||
body := &Reaction{Content: String(content)}
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||
|
||||
m := &Reaction{}
|
||||
resp, err := s.client.Do(ctx, req, m)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return m, resp, nil
|
||||
}
|
||||
|
||||
// ListTeamDiscussionCommentReactions lists the reactions for a team discussion comment.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#list-reactions-for-a-team-discussion-comment
|
||||
func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Context, teamID int64, discussionNumber, commentNumber int, opt *ListOptions) ([]*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber)
|
||||
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", mediaTypeReactionsPreview)
|
||||
|
||||
var m []*Reaction
|
||||
resp, err := s.client.Do(ctx, req, &m)
|
||||
|
||||
return m, resp, nil
|
||||
}
|
||||
|
||||
// CreateTeamDiscussionCommentReaction creates a reaction for a team discussion comment.
|
||||
// The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reactions/#create-reaction-for-a-team-discussion-comment
|
||||
func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) {
|
||||
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber)
|
||||
|
||||
body := &Reaction{Content: String(content)}
|
||||
req, err := s.client.NewRequest("POST", u, body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||
|
||||
m := &Reaction{}
|
||||
resp, err := s.client.Do(ctx, req, m)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return m, resp, nil
|
||||
}
|
||||
|
||||
// DeleteReaction deletes a reaction.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/reaction/reactions/#delete-a-reaction-archive
|
||||
|
||||
+2
-49
@@ -56,7 +56,6 @@ type Repository struct {
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"`
|
||||
Topics []string `json:"topics,omitempty"`
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
|
||||
// Only provided when using RepositoriesService.Get while in preview
|
||||
License *License `json:"license,omitempty"`
|
||||
@@ -70,6 +69,7 @@ type Repository struct {
|
||||
HasDownloads *bool `json:"has_downloads,omitempty"`
|
||||
LicenseTemplate *string `json:"license_template,omitempty"`
|
||||
GitignoreTemplate *string `json:"gitignore_template,omitempty"`
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
|
||||
// Creating an organization repository. Required for non-owners.
|
||||
TeamID *int64 `json:"team_id,omitempty"`
|
||||
@@ -259,40 +259,10 @@ func (s *RepositoriesService) ListAll(ctx context.Context, opt *RepositoryListAl
|
||||
return repos, resp, nil
|
||||
}
|
||||
|
||||
// createRepoRequest is a subset of Repository and is used internally
|
||||
// by Create to pass only the known fields for the endpoint.
|
||||
//
|
||||
// See https://github.com/google/go-github/issues/1014 for more
|
||||
// information.
|
||||
type createRepoRequest struct {
|
||||
// Name is required when creating a repo.
|
||||
Name *string `json:"name,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Homepage *string `json:"homepage,omitempty"`
|
||||
|
||||
Private *bool `json:"private,omitempty"`
|
||||
HasIssues *bool `json:"has_issues,omitempty"`
|
||||
HasProjects *bool `json:"has_projects,omitempty"`
|
||||
HasWiki *bool `json:"has_wiki,omitempty"`
|
||||
|
||||
// Creating an organization repository. Required for non-owners.
|
||||
TeamID *int64 `json:"team_id,omitempty"`
|
||||
|
||||
AutoInit *bool `json:"auto_init,omitempty"`
|
||||
GitignoreTemplate *string `json:"gitignore_template,omitempty"`
|
||||
LicenseTemplate *string `json:"license_template,omitempty"`
|
||||
AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"`
|
||||
AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"`
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"`
|
||||
}
|
||||
|
||||
// Create a new repository. If an organization is specified, the new
|
||||
// repository will be created under that org. If the empty string is
|
||||
// specified, it will be created for the authenticated user.
|
||||
//
|
||||
// Note that only a subset of the repo fields are used and repo must
|
||||
// not be nil.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/#create
|
||||
func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error) {
|
||||
var u string
|
||||
@@ -302,24 +272,7 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo
|
||||
u = "user/repos"
|
||||
}
|
||||
|
||||
repoReq := &createRepoRequest{
|
||||
Name: repo.Name,
|
||||
Description: repo.Description,
|
||||
Homepage: repo.Homepage,
|
||||
Private: repo.Private,
|
||||
HasIssues: repo.HasIssues,
|
||||
HasProjects: repo.HasProjects,
|
||||
HasWiki: repo.HasWiki,
|
||||
TeamID: repo.TeamID,
|
||||
AutoInit: repo.AutoInit,
|
||||
GitignoreTemplate: repo.GitignoreTemplate,
|
||||
LicenseTemplate: repo.LicenseTemplate,
|
||||
AllowSquashMerge: repo.AllowSquashMerge,
|
||||
AllowMergeCommit: repo.AllowMergeCommit,
|
||||
AllowRebaseMerge: repo.AllowRebaseMerge,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, repoReq)
|
||||
req, err := s.client.NewRequest("POST", u, repo)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
+9
-37
@@ -69,55 +69,27 @@ func (w WebHookAuthor) String() string {
|
||||
|
||||
// Hook represents a GitHub (web and service) hook for a repository.
|
||||
type Hook struct {
|
||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
|
||||
// Only the following fields are used when creating a hook.
|
||||
// Name and Config are required.
|
||||
Name *string `json:"name,omitempty"`
|
||||
Config map[string]interface{} `json:"config,omitempty"`
|
||||
Events []string `json:"events,omitempty"`
|
||||
Active *bool `json:"active,omitempty"`
|
||||
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Events []string `json:"events,omitempty"`
|
||||
Active *bool `json:"active,omitempty"`
|
||||
Config map[string]interface{} `json:"config,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (h Hook) String() string {
|
||||
return Stringify(h)
|
||||
}
|
||||
|
||||
// createHookRequest is a subset of Hook and is used internally
|
||||
// by CreateHook to pass only the known fields for the endpoint.
|
||||
//
|
||||
// See https://github.com/google/go-github/issues/1015 for more
|
||||
// information.
|
||||
type createHookRequest struct {
|
||||
// Name and Config are required.
|
||||
// Name must be passed as "web".
|
||||
Name *string `json:"name,omitempty"`
|
||||
Config map[string]interface{} `json:"config,omitempty"`
|
||||
Events []string `json:"events,omitempty"`
|
||||
Active *bool `json:"active,omitempty"`
|
||||
}
|
||||
|
||||
// CreateHook creates a Hook for the specified repository.
|
||||
// Name and Config are required fields.
|
||||
//
|
||||
// Note that only a subset of the hook fields are used and hook must
|
||||
// not be nil.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/hooks/#create-a-hook
|
||||
func (s *RepositoriesService) CreateHook(ctx context.Context, owner, repo string, hook *Hook) (*Hook, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo)
|
||||
|
||||
hookReq := &createHookRequest{
|
||||
Name: hook.Name,
|
||||
Events: hook.Events,
|
||||
Active: hook.Active,
|
||||
Config: hook.Config,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, hookReq)
|
||||
req, err := s.client.NewRequest("POST", u, hook)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
+20
-61
@@ -19,26 +19,24 @@ import (
|
||||
|
||||
// RepositoryRelease represents a GitHub release in a repository.
|
||||
type RepositoryRelease struct {
|
||||
TagName *string `json:"tag_name,omitempty"`
|
||||
TargetCommitish *string `json:"target_commitish,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Draft *bool `json:"draft,omitempty"`
|
||||
Prerelease *bool `json:"prerelease,omitempty"`
|
||||
|
||||
// The following fields are not used in CreateRelease or EditRelease:
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
PublishedAt *Timestamp `json:"published_at,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
AssetsURL *string `json:"assets_url,omitempty"`
|
||||
Assets []ReleaseAsset `json:"assets,omitempty"`
|
||||
UploadURL *string `json:"upload_url,omitempty"`
|
||||
ZipballURL *string `json:"zipball_url,omitempty"`
|
||||
TarballURL *string `json:"tarball_url,omitempty"`
|
||||
Author *User `json:"author,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
TagName *string `json:"tag_name,omitempty"`
|
||||
TargetCommitish *string `json:"target_commitish,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Draft *bool `json:"draft,omitempty"`
|
||||
Prerelease *bool `json:"prerelease,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
PublishedAt *Timestamp `json:"published_at,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
HTMLURL *string `json:"html_url,omitempty"`
|
||||
AssetsURL *string `json:"assets_url,omitempty"`
|
||||
Assets []ReleaseAsset `json:"assets,omitempty"`
|
||||
UploadURL *string `json:"upload_url,omitempty"`
|
||||
ZipballURL *string `json:"zipball_url,omitempty"`
|
||||
TarballURL *string `json:"tarball_url,omitempty"`
|
||||
Author *User `json:"author,omitempty"`
|
||||
NodeID *string `json:"node_id,omitempty"`
|
||||
}
|
||||
|
||||
func (r RepositoryRelease) String() string {
|
||||
@@ -127,40 +125,13 @@ func (s *RepositoriesService) getSingleRelease(ctx context.Context, url string)
|
||||
return release, resp, nil
|
||||
}
|
||||
|
||||
// repositoryReleaseRequest is a subset of RepositoryRelease and
|
||||
// is used internally by CreateRelease and EditRelease to pass
|
||||
// only the known fields for these endpoints.
|
||||
//
|
||||
// See https://github.com/google/go-github/issues/992 for more
|
||||
// information.
|
||||
type repositoryReleaseRequest struct {
|
||||
TagName *string `json:"tag_name,omitempty"`
|
||||
TargetCommitish *string `json:"target_commitish,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Body *string `json:"body,omitempty"`
|
||||
Draft *bool `json:"draft,omitempty"`
|
||||
Prerelease *bool `json:"prerelease,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRelease adds a new release for a repository.
|
||||
//
|
||||
// Note that only a subset of the release fields are used.
|
||||
// See RepositoryRelease for more information.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/releases/#create-a-release
|
||||
func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, release *RepositoryRelease) (*RepositoryRelease, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/releases", owner, repo)
|
||||
|
||||
releaseReq := &repositoryReleaseRequest{
|
||||
TagName: release.TagName,
|
||||
TargetCommitish: release.TargetCommitish,
|
||||
Name: release.Name,
|
||||
Body: release.Body,
|
||||
Draft: release.Draft,
|
||||
Prerelease: release.Prerelease,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, releaseReq)
|
||||
req, err := s.client.NewRequest("POST", u, release)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -175,23 +146,11 @@ func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo str
|
||||
|
||||
// EditRelease edits a repository release.
|
||||
//
|
||||
// Note that only a subset of the release fields are used.
|
||||
// See RepositoryRelease for more information.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/releases/#edit-a-release
|
||||
func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo string, id int64, release *RepositoryRelease) (*RepositoryRelease, *Response, error) {
|
||||
u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id)
|
||||
|
||||
releaseReq := &repositoryReleaseRequest{
|
||||
TagName: release.TagName,
|
||||
TargetCommitish: release.TargetCommitish,
|
||||
Name: release.Name,
|
||||
Body: release.Body,
|
||||
Draft: release.Draft,
|
||||
Prerelease: release.Prerelease,
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest("PATCH", u, releaseReq)
|
||||
req, err := s.client.NewRequest("PATCH", u, release)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
-1
@@ -24,7 +24,6 @@ type DiscussionComment struct {
|
||||
Number *int `json:"number,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Reactions *Reactions `json:"reactions,omitempty"`
|
||||
}
|
||||
|
||||
func (c DiscussionComment) String() string {
|
||||
|
||||
-1
@@ -29,7 +29,6 @@ type TeamDiscussion struct {
|
||||
Title *string `json:"title,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Reactions *Reactions `json:"reactions,omitempty"`
|
||||
}
|
||||
|
||||
func (d TeamDiscussion) String() string {
|
||||
|
||||
Reference in New Issue
Block a user