Skip to content

feat: Add pull request settings to github_repository - #3479

Open
nicolas-grekas wants to merge 2 commits into
integrations:mainfrom
nicolas-grekas:feat/repository-pull-request-settings
Open

nicolas-grekas wants to merge 2 commits into
integrations:mainfrom
nicolas-grekas:feat/repository-pull-request-settings

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Jun 6, 2026 •

Copy link
Copy Markdown

Resolves #3198


Before the change?

github_repository could not manage the repository pull request settings GitHub shipped in February 2026: disabling pull requests entirely, and restricting who can open them.

After the change?

Two new arguments on github_repository (and read-only attributes on the github_repository data source):

  • has_pull_requests (bool, defaults to true): set to false to disable pull requests on the repository.
  • pull_request_creation_policy (all / collaborators_only): restricts who can open pull requests.

has_pull_requests defaults to true so existing repositories keep pull requests enabled rather than being silently disabled on the next apply. pull_request_creation_policy is only sent when pull requests are enabled, mirroring how the existing merge_commit_* / squash_merge_commit_* arguments are gated on their parent toggle. Its diff is ignored while pull requests are disabled, so that a value that isn't sent doesn't show up in every plan.

The struct fields landed in google/go-github#4268, released in v89.0.0, which main already includes.

Pull request checklist

  • Schema migrations have been created if needed (none needed: additive optional fields)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

  • Yes
  • No

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@ap-1

ap-1 commented Jul 6, 2026

Copy link
Copy Markdown

@nicolas-grekas v89 just released!

@ap-1

ap-1 commented Aug 9, 2026

Copy link
Copy Markdown

hi @nicolas-grekas, is there any chance you can pick this back up?

@nicolas-grekas
nicolas-grekas force-pushed the feat/repository-pull-request-settings branch 2 times, most recently from d457d80 to 6896fe0 Compare August 10, 2026 07:48
@nicolas-grekas
nicolas-grekas marked this pull request as ready for review August 10, 2026 07:50
@nicolas-grekas

nicolas-grekas commented Aug 10, 2026 •

Copy link
Copy Markdown
Author

thanks for the reminder, this is now ready for review!

@ap-1

ap-1 commented Sep 22, 2026

Copy link
Copy Markdown

@deiga mentioning you since you reviewed the old PR #3349

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The data-source schema lacks required descriptions and acceptance coverage, and the new tests use legacy state checks.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

These provider review instructions are being used. This PR adds repository-level pull request controls to the resource and exposes them through the data source.

Changes:

  • Adds has_pull_requests and pull_request_creation_policy.
  • Maps the settings through GitHub API reads and writes.
  • Adds resource acceptance tests and user documentation.
File Description
github/​resource_github_repository.go Adds schema and API mapping.
github/​resource_github_repository_test.go Tests resource settings and defaults.
github/​data_source_github_repository.go Exposes computed PR settings.
templates/​resources/​repository.md.tmpl Documents resource arguments.
templates/​data-sources/​repository.md.tmpl Documents data-source attributes.
docs/​resources/​repository.md Updates generated resource docs.
docs/​data-sources/​repository.md Updates generated data-source docs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread github/data_source_github_repository.go Resolved
Comment thread github/data_source_github_repository.go Resolved
@giacchetta

giacchetta commented Oct 5, 2026 •

Copy link
Copy Markdown

Any chance to make this review done?

GitHub added two repository settings in February 2026: disabling pull
requests entirely (has_pull_requests) and restricting who can open them
(pull_request_creation_policy, "all" or "collaborators_only").

has_pull_requests defaults to true so existing repositories keep pull
requests enabled. The creation policy is only sent when pull requests are
enabled, matching how the merge-commit title/message fields are handled.
- describe the two data source attributes
- cover them with a data source acceptance test
- use ConfigStateChecks in the new resource tests
- suppress the pull_request_creation_policy diff while pull requests are
  disabled, since the policy is not sent in that case
- regenerate the resource docs, which now come from schema descriptions
@nicolas-grekas
nicolas-grekas force-pushed the feat/repository-pull-request-settings branch from 6896fe0 to e7e641a Compare October 5, 2026 19:45
@nicolas-grekas

Copy link
Copy Markdown
Author

PR rebased and updated for the Copilot review. On top of that, the pull_request_creation_policy diff is now ignored while has_pull_requests is false: the policy isn't sent in that case, so a non-default value would otherwise show up in every plan.

@ap-1

ap-1 commented Nov 14, 2026

Copy link
Copy Markdown

@deiga any chance this can get looked at?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: New Pull Request settings for Repositories

4 participants