diff --git a/github/github-accessors.go b/github/github-accessors.go index be3920a5df3..bc3194bc1b6 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -32550,6 +32550,14 @@ func (r *Repository) GetHasProjects() bool { return *r.HasProjects } +// GetHasPullRequests returns the HasPullRequests field if it's non-nil, zero value otherwise. +func (r *Repository) GetHasPullRequests() bool { + if r == nil || r.HasPullRequests == nil { + return false + } + return *r.HasPullRequests +} + // GetHasWiki returns the HasWiki field if it's non-nil, zero value otherwise. func (r *Repository) GetHasWiki() bool { if r == nil || r.HasWiki == nil { @@ -32806,6 +32814,14 @@ func (r *Repository) GetPrivate() bool { return *r.Private } +// GetPullRequestCreationPolicy returns the PullRequestCreationPolicy field if it's non-nil, zero value otherwise. +func (r *Repository) GetPullRequestCreationPolicy() string { + if r == nil || r.PullRequestCreationPolicy == nil { + return "" + } + return *r.PullRequestCreationPolicy +} + // GetPullsURL returns the PullsURL field if it's non-nil, zero value otherwise. func (r *Repository) GetPullsURL() string { if r == nil || r.PullsURL == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 56417cc6282..c9ced173fe0 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -41047,6 +41047,17 @@ func TestRepository_GetHasProjects(tt *testing.T) { r.GetHasProjects() } +func TestRepository_GetHasPullRequests(tt *testing.T) { + tt.Parallel() + var zeroValue bool + r := &Repository{HasPullRequests: &zeroValue} + r.GetHasPullRequests() + r = &Repository{} + r.GetHasPullRequests() + r = nil + r.GetHasPullRequests() +} + func TestRepository_GetHasWiki(tt *testing.T) { tt.Parallel() var zeroValue bool @@ -41384,6 +41395,17 @@ func TestRepository_GetPrivate(tt *testing.T) { r.GetPrivate() } +func TestRepository_GetPullRequestCreationPolicy(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &Repository{PullRequestCreationPolicy: &zeroValue} + r.GetPullRequestCreationPolicy() + r = &Repository{} + r.GetPullRequestCreationPolicy() + r = nil + r.GetPullRequestCreationPolicy() +} + func TestRepository_GetPullsURL(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index aa1d905a2e4..267eab6471b 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1981,6 +1981,8 @@ func TestRepository_String(t *testing.T) { HasProjects: Ptr(false), HasDownloads: Ptr(false), HasDiscussions: Ptr(false), + HasPullRequests: Ptr(false), + PullRequestCreationPolicy: Ptr(""), IsTemplate: Ptr(false), LicenseTemplate: Ptr(""), GitignoreTemplate: Ptr(""), @@ -2026,7 +2028,7 @@ func TestRepository_String(t *testing.T) { Visibility: Ptr(""), RoleName: Ptr(""), } - want := `github.Repository{ID:0, NodeID:"", Owner:github.User{}, Name:"", FullName:"", Description:"", Homepage:"", CodeOfConduct:github.CodeOfConduct{}, DefaultBranch:"", MasterBranch:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PushedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HTMLURL:"", CloneURL:"", GitURL:"", MirrorURL:"", SSHURL:"", SVNURL:"", Language:"", Fork:false, ForksCount:0, NetworkCount:0, OpenIssuesCount:0, OpenIssues:0, StargazersCount:0, SubscribersCount:0, WatchersCount:0, Watchers:0, Size:0, AutoInit:false, Parent:github.Repository{}, Source:github.Repository{}, TemplateRepository:github.Repository{}, Organization:github.Organization{}, Permissions:github.RepositoryPermissions{}, AllowRebaseMerge:false, AllowUpdateBranch:false, AllowSquashMerge:false, AllowMergeCommit:false, AllowAutoMerge:false, AllowForking:false, WebCommitSignoffRequired:false, DeleteBranchOnMerge:false, UseSquashPRTitleAsDefault:false, SquashMergeCommitTitle:"", SquashMergeCommitMessage:"", MergeCommitTitle:"", MergeCommitMessage:"", Topics:[""], Archived:false, Disabled:false, License:github.License{}, Private:false, HasIssues:false, HasWiki:false, HasPages:false, HasProjects:false, HasDownloads:false, HasDiscussions:false, IsTemplate:false, LicenseTemplate:"", GitignoreTemplate:"", SecurityAndAnalysis:github.SecurityAndAnalysis{}, TeamID:0, URL:"", ArchiveURL:"", AssigneesURL:"", BlobsURL:"", BranchesURL:"", CollaboratorsURL:"", CommentsURL:"", CommitsURL:"", CompareURL:"", ContentsURL:"", ContributorsURL:"", DeploymentsURL:"", DownloadsURL:"", EventsURL:"", ForksURL:"", GitCommitsURL:"", GitRefsURL:"", GitTagsURL:"", HooksURL:"", IssueCommentURL:"", IssueEventsURL:"", IssuesURL:"", KeysURL:"", LabelsURL:"", LanguagesURL:"", MergesURL:"", MilestonesURL:"", NotificationsURL:"", PullsURL:"", ReleasesURL:"", StargazersURL:"", StatusesURL:"", SubscribersURL:"", SubscriptionURL:"", TagsURL:"", TreesURL:"", TeamsURL:"", Visibility:"", RoleName:""}` + want := `github.Repository{ID:0, NodeID:"", Owner:github.User{}, Name:"", FullName:"", Description:"", Homepage:"", CodeOfConduct:github.CodeOfConduct{}, DefaultBranch:"", MasterBranch:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PushedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HTMLURL:"", CloneURL:"", GitURL:"", MirrorURL:"", SSHURL:"", SVNURL:"", Language:"", Fork:false, ForksCount:0, NetworkCount:0, OpenIssuesCount:0, OpenIssues:0, StargazersCount:0, SubscribersCount:0, WatchersCount:0, Watchers:0, Size:0, AutoInit:false, Parent:github.Repository{}, Source:github.Repository{}, TemplateRepository:github.Repository{}, Organization:github.Organization{}, Permissions:github.RepositoryPermissions{}, AllowRebaseMerge:false, AllowUpdateBranch:false, AllowSquashMerge:false, AllowMergeCommit:false, AllowAutoMerge:false, AllowForking:false, WebCommitSignoffRequired:false, DeleteBranchOnMerge:false, UseSquashPRTitleAsDefault:false, SquashMergeCommitTitle:"", SquashMergeCommitMessage:"", MergeCommitTitle:"", MergeCommitMessage:"", Topics:[""], Archived:false, Disabled:false, License:github.License{}, Private:false, HasIssues:false, HasWiki:false, HasPages:false, HasProjects:false, HasDownloads:false, HasDiscussions:false, HasPullRequests:false, PullRequestCreationPolicy:"", IsTemplate:false, LicenseTemplate:"", GitignoreTemplate:"", SecurityAndAnalysis:github.SecurityAndAnalysis{}, TeamID:0, URL:"", ArchiveURL:"", AssigneesURL:"", BlobsURL:"", BranchesURL:"", CollaboratorsURL:"", CommentsURL:"", CommitsURL:"", CompareURL:"", ContentsURL:"", ContributorsURL:"", DeploymentsURL:"", DownloadsURL:"", EventsURL:"", ForksURL:"", GitCommitsURL:"", GitRefsURL:"", GitTagsURL:"", HooksURL:"", IssueCommentURL:"", IssueEventsURL:"", IssuesURL:"", KeysURL:"", LabelsURL:"", LanguagesURL:"", MergesURL:"", MilestonesURL:"", NotificationsURL:"", PullsURL:"", ReleasesURL:"", StargazersURL:"", StatusesURL:"", SubscribersURL:"", SubscriptionURL:"", TagsURL:"", TreesURL:"", TeamsURL:"", Visibility:"", RoleName:""}` if got := v.String(); got != want { t.Errorf("Repository.String = %v, want %v", got, want) } diff --git a/github/repos.go b/github/repos.go index b3e41a5f7a1..df4979979c8 100644 --- a/github/repos.go +++ b/github/repos.go @@ -85,16 +85,18 @@ type Repository struct { License *License `json:"license,omitempty"` // Additional mutable fields when creating and editing a repository - Private *bool `json:"private,omitempty"` - HasIssues *bool `json:"has_issues,omitempty"` - HasWiki *bool `json:"has_wiki,omitempty"` - HasPages *bool `json:"has_pages,omitempty"` - HasProjects *bool `json:"has_projects,omitempty"` - HasDownloads *bool `json:"has_downloads,omitempty"` - HasDiscussions *bool `json:"has_discussions,omitempty"` - IsTemplate *bool `json:"is_template,omitempty"` - LicenseTemplate *string `json:"license_template,omitempty"` - GitignoreTemplate *string `json:"gitignore_template,omitempty"` + Private *bool `json:"private,omitempty"` + HasIssues *bool `json:"has_issues,omitempty"` + HasWiki *bool `json:"has_wiki,omitempty"` + HasPages *bool `json:"has_pages,omitempty"` + HasProjects *bool `json:"has_projects,omitempty"` + HasDownloads *bool `json:"has_downloads,omitempty"` + HasDiscussions *bool `json:"has_discussions,omitempty"` + HasPullRequests *bool `json:"has_pull_requests,omitempty"` + PullRequestCreationPolicy *string `json:"pull_request_creation_policy,omitempty"` // Can be one of: "all", "collaborators_only" + IsTemplate *bool `json:"is_template,omitempty"` + LicenseTemplate *string `json:"license_template,omitempty"` + GitignoreTemplate *string `json:"gitignore_template,omitempty"` // Options for configuring Advanced Security and Secret Scanning SecurityAndAnalysis *SecurityAndAnalysis `json:"security_and_analysis,omitempty"`