From f72fa879143c6ecc7349102905964f1b6dfaa726 Mon Sep 17 00:00:00 2001 From: zhouhaibing089 Date: Mon, 7 Jun 2021 10:56:05 -0700 Subject: [PATCH 1/2] repos: add option include_all_branches to template repo request This option, when set to true, the created repository will get files from all the branches, not just the default branch. See [create-a-repository-using-a-template][1] for more information. [1]: https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template --- github/repos.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github/repos.go b/github/repos.go index 73e05f23fe1..8f34cf8b6d3 100644 --- a/github/repos.go +++ b/github/repos.go @@ -385,7 +385,8 @@ type TemplateRepoRequest struct { Owner *string `json:"owner,omitempty"` Description *string `json:"description,omitempty"` - Private *bool `json:"private,omitempty"` + IncludeAllBranches *bool `json:"include_all_branches,omitempty"` + Private *bool `json:"private,omitempty"` } // CreateFromTemplate generates a repository from a template. From d1f957d778d15bc3996b59d00c3c30b38c18e23d Mon Sep 17 00:00:00 2001 From: Haibing Zhou Date: Mon, 7 Jun 2021 11:09:22 -0700 Subject: [PATCH 2/2] run go generate ./... Run `go generate ./...`. --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index cb068a69c0a..1c17384eac0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -14764,6 +14764,14 @@ func (t *TemplateRepoRequest) GetDescription() string { return *t.Description } +// GetIncludeAllBranches returns the IncludeAllBranches field if it's non-nil, zero value otherwise. +func (t *TemplateRepoRequest) GetIncludeAllBranches() bool { + if t == nil || t.IncludeAllBranches == nil { + return false + } + return *t.IncludeAllBranches +} + // GetName returns the Name field if it's non-nil, zero value otherwise. func (t *TemplateRepoRequest) GetName() string { if t == nil || t.Name == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 5695e3fb3d2..750c6a40f8f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -17292,6 +17292,16 @@ func TestTemplateRepoRequest_GetDescription(tt *testing.T) { t.GetDescription() } +func TestTemplateRepoRequest_GetIncludeAllBranches(tt *testing.T) { + var zeroValue bool + t := &TemplateRepoRequest{IncludeAllBranches: &zeroValue} + t.GetIncludeAllBranches() + t = &TemplateRepoRequest{} + t.GetIncludeAllBranches() + t = nil + t.GetIncludeAllBranches() +} + func TestTemplateRepoRequest_GetName(tt *testing.T) { var zeroValue string t := &TemplateRepoRequest{Name: &zeroValue}