diff --git a/github/github-accessors.go b/github/github-accessors.go index 8af31d64ae9..bc10272c032 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -46438,6 +46438,14 @@ func (t *TeamRepository) GetPermissions() *TeamPermissions { return t.Permissions } +// GetCustomProperties returns the CustomProperties map if it's non-nil, an empty map otherwise. +func (t *TemplateRepoRequest) GetCustomProperties() map[string]any { + if t == nil || t.CustomProperties == nil { + return map[string]any{} + } + return t.CustomProperties +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (t *TemplateRepoRequest) GetDescription() string { if t == nil || t.Description == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 134eedbc526..e978f5dfc0b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -57872,6 +57872,17 @@ func TestTeamRepository_GetPermissions(tt *testing.T) { t.GetPermissions() } +func TestTemplateRepoRequest_GetCustomProperties(tt *testing.T) { + tt.Parallel() + zeroValue := map[string]any{} + t := &TemplateRepoRequest{CustomProperties: zeroValue} + t.GetCustomProperties() + t = &TemplateRepoRequest{} + t.GetCustomProperties() + t = nil + t.GetCustomProperties() +} + func TestTemplateRepoRequest_GetDescription(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/repos.go b/github/repos.go index 9ffec574c91..f10f23db8d9 100644 --- a/github/repos.go +++ b/github/repos.go @@ -580,11 +580,12 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, body Creat // TemplateRepoRequest represents a request to create a repository from a template. type TemplateRepoRequest struct { - Name string `json:"name"` - Owner *string `json:"owner,omitempty"` - Description *string `json:"description,omitempty"` - IncludeAllBranches *bool `json:"include_all_branches,omitempty"` - Private *bool `json:"private,omitempty"` + Name string `json:"name"` + Owner *string `json:"owner,omitempty"` + Description *string `json:"description,omitempty"` + IncludeAllBranches *bool `json:"include_all_branches,omitempty"` + Private *bool `json:"private,omitempty"` + CustomProperties map[string]any `json:"custom_properties,omitempty"` } // CreateFromTemplate generates a repository from a template. diff --git a/github/repos_test.go b/github/repos_test.go index f363617ee16..9232c8bc16a 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -373,12 +373,17 @@ func TestRepositoriesService_CreateFromTemplate(t *testing.T) { templateRepoReq := TemplateRepoRequest{ Name: "n", + CustomProperties: map[string]any{ + "environment": "production", + "team": "backend", + "priority": 1, + }, } mux.HandleFunc("/repos/to/tr/generate", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Accept", mediaTypeRepositoryTemplatePreview) - testJSONBody(t, r, templateRepoReq) + testJSONBodyRaw(t, r, `{"name":"n","custom_properties":{"environment":"production","team":"backend","priority":1}}`) fmt.Fprint(w, `{"id":1,"name":"n"}`) })