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.
The
Repositorystruct is missing two fields that GitHub's REST API returns and accepts:has_pull_requests(bool, defaulttrue): whether the repository's "Pull requests" feature is enabled, alongside the existinghas_issues/has_wiki/has_projects/has_discussionsfieldspull_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}, andPATCH /repos/{owner}/{repo}acceptshas_pull_requestsand persists it:These currently can't be set or read through go-github because the fields aren't on the
Repositorystruct.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.