Skip to content

Commit d0c2d21

Browse files
refactor!: Pass TemplateRepoRequest by value in Repositories.CreateFromTemplate (#4378)
BREAKING CHANGE: `RepositoriesService.CreateFromTemplate` now passes `body` by value and `Name` is now required and passed by value.
1 parent 78629dd commit d0c2d21

5 files changed

Lines changed: 12 additions & 18 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ linters:
269269
- TeamAddTeamRepoOptions
270270
- TeamLDAPMapping
271271
- TeamProjectOptions
272-
- TemplateRepoRequest
273272
- UpdateCodespaceOptions
274273
- UpdateDefaultSetupConfigurationOptions
275274
- UpdateProjectItemOptions

github/github-accessors.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,21 +620,19 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo
620620

621621
// TemplateRepoRequest represents a request to create a repository from a template.
622622
type TemplateRepoRequest struct {
623-
// Name is required when creating a repo.
624-
Name *string `json:"name,omitempty"`
625-
Owner *string `json:"owner,omitempty"`
626-
Description *string `json:"description,omitempty"`
627-
628-
IncludeAllBranches *bool `json:"include_all_branches,omitempty"`
629-
Private *bool `json:"private,omitempty"`
623+
Name string `json:"name"`
624+
Owner *string `json:"owner,omitempty"`
625+
Description *string `json:"description,omitempty"`
626+
IncludeAllBranches *bool `json:"include_all_branches,omitempty"`
627+
Private *bool `json:"private,omitempty"`
630628
}
631629

632630
// CreateFromTemplate generates a repository from a template.
633631
//
634632
// GitHub API docs: https://docs.github.com/rest/repos/repos?apiVersion=2022-11-28#create-a-repository-using-a-template
635633
//
636634
//meta:operation POST /repos/{template_owner}/{template_repo}/generate
637-
func (s *RepositoriesService) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo string, body *TemplateRepoRequest) (*Repository, *Response, error) {
635+
func (s *RepositoriesService) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo string, body TemplateRepoRequest) (*Repository, *Response, error) {
638636
u := fmt.Sprintf("repos/%v/%v/generate", templateOwner, templateRepo)
639637

640638
req, err := s.client.NewRequest(ctx, "POST", u, body)

github/repos_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ func TestRepositoriesService_CreateFromTemplate(t *testing.T) {
341341
t.Parallel()
342342
client, mux, _ := setup(t)
343343

344-
templateRepoReq := &TemplateRepoRequest{
345-
Name: Ptr("n"),
344+
templateRepoReq := TemplateRepoRequest{
345+
Name: "n",
346346
}
347347

348348
mux.HandleFunc("/repos/to/tr/generate", func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)