Skip to content

Add HasPullRequests and PullRequestCreationPolicy to Repository #4267

@ap-1

Description

@ap-1

The Repository struct is missing two fields that GitHub's REST API returns and accepts:

  • has_pull_requests (bool, default true): whether the repository's "Pull requests" feature is enabled, alongside the existing has_issues / has_wiki / has_projects / has_discussions fields
  • pull_request_creation_policy (string, all | collaborators_only): who may open pull requests ("Creation allowed by")

Both appear in the repository object from GET /repos/{owner}/{repo}, and PATCH /repos/{owner}/{repo} accepts has_pull_requests and persists it:

$ curl -s -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json"
    https://api.github.com/repos/OWNER/REPO | jq '{has_pull_requests, pull_request_creation_policy}'
{
  "has_pull_requests": true,
  "pull_request_creation_policy": "all"
}

$ curl -s -o /dev/null -w '%{http_code}\n' -X PATCH
    -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json"
    https://api.github.com/repos/OWNER/REPO -d '{"has_pull_requests": false}'
200

$ curl -s -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json"
    https://api.github.com/repos/OWNER/REPO | jq '{has_pull_requests, pull_request_creation_policy}'
{
  "has_pull_requests": false,
  "pull_request_creation_policy": "all"
}

These currently can't be set or read through go-github because the fields aren't on the Repository struct.

I need this downstream in terraform-provider-github to manage the setting declaratively (integrations/terraform-provider-github#3472), so I'm willing to work on this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions