You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on our discussion at work week, I'd propose that we too new arguments/questions to use_release_issue(): use_pre_release and use_branch.
If use_pre_release is true, then we create two issues a pre-release (the current "prepare for release bullets), and then a release issue, which would gain new bullets for locking the main branch at the start and unlocking at the end.
If use_branch is true, the bullets would replace git pull and git push with (e.g.) pr_init("v1.4.1-release") and merging the PR. (We'd recommend that the PR close the issue automatically with a comment).
(For use_branch = TRUE we still need to think through the post-release process to ensure that both dev and releases sites are updated, and we end up with a dev version on the main branch.)
We probably want to keep use_prerelease = FALSE the default, since it only really affects bigger releases.
We might want to make use_branch = TRUE the default, since it's probably good practice for us even we can push directly to main.
We might want to move the check runs to the release process, because particularly when using a branch, we can update the version earlier, meaning that we'd move to 0 notes when everything was good.
We took an initial step on this by adding github_(un)lock_branch() but then I had to revert those changes. Due to the API design, it's going to be pretty fiddly to lock/unlock a branch, without nuking all pre-existing branch protections or leaving it with new, undesired branch protections. I didn't want to put the half-baked version in a patch release and I don't want to do the job right at this time. I'll leave some notes below for our next attempt.
Thought dump:
You lock a branch with the Update branch protection endpoint. Unfortunately you can't only send lock_branch = TRUE. There are other required parameters: required_status_checks, enforce_admins, required_pull_request_reviews, and restrictions, most of which can be either null (disabled) or some more complicated object.
We actually do need to set enforce_admins = TRUE when we lock a branch, so that the lock actually has teeth, i.e. even folks with admin permissions can't ignore the lock.
However the other 3 seem unrelated to branch locking/unlocking and it would be nice to not change their configuration.
If you try to GET the current protections for a branch, when there are none, you get a 404, not an empty list or anything like that. So you need to tryCatch() it. The relevant endpoint is Get branch protection.
The response schema when you GET branch protections is not the same schema as what you need to send with the PUT to modify branch protections. So it's not easy to leave other protections alone, while we fiddle with lock_branch and enforce_admins.
Lived experience:
While fiddling with Lock and unlock branch as part of the release process #2145 I locked / unlocked the PR branch itself a few times. That seemed to be working. And yet pr_finish() failed because it could no longer delete the PR branch. Some of the branch protections we'd put in place during the process lingered on.
Then you are tempted to bring out the big hammer and use the Delete branch protection endpoint, to make the branch delete-able.
But what if someone had set branch protections intentionally? It feels uncool for us to delete them with a function that only advertises branch (un)locking.
I'm sure we can create the functionality we want, but it's going to require more research/time.
Activity
hadley commentedon Feb 14, 2024
A couple more thoughts:
use_prerelease = FALSEthe default, since it only really affects bigger releases.use_branch = TRUEthe default, since it's probably good practice for us even we can push directly to main.Lock and unlock branch as part of the release process
Lock and unlock branch as part of the release process (#2145)
Revert the addition of github_(un)lock_branch()
jennybc commentedon Sep 5, 2025
We took an initial step on this by adding
github_(un)lock_branch()but then I had to revert those changes. Due to the API design, it's going to be pretty fiddly to lock/unlock a branch, without nuking all pre-existing branch protections or leaving it with new, undesired branch protections. I didn't want to put the half-baked version in a patch release and I don't want to do the job right at this time. I'll leave some notes below for our next attempt.Thought dump:
lock_branch = TRUE. There are other required parameters:required_status_checks,enforce_admins,required_pull_request_reviews, andrestrictions, most of which can be eithernull(disabled) or some more complicated object.enforce_admins = TRUEwhen we lock a branch, so that the lock actually has teeth, i.e. even folks with admin permissions can't ignore the lock.tryCatch()it. The relevant endpoint is Get branch protection.lock_branchandenforce_admins.Lived experience:
pr_finish()failed because it could no longer delete the PR branch. Some of the branch protections we'd put in place during the process lingered on.I'm sure we can create the functionality we want, but it's going to require more research/time.
jennybc commentedon Sep 5, 2025
Parting thought: we might make locking/unlocking easier for ourselves by sending folks to a specific URL with certain boxes pre-checked: https://github.com/r-lib/usethis/settings/branch_protection_rules/new. Similar to how
create_github_token()works. Basically, just help folks use the web UI. Would require some research and experimentation to see if this is feasible.hadley commentedon May 18, 2026
Claude suggests we might be able to use (new-since-last-time-we-tried-this?) rulesets API