Repository navigation
Lock and unlock branch as part of the release process - #2145
Conversation
This ensures that there's no way to accidentally forget that you're in the middle of the release process and make a change to the repo. Part of #1946
DavisVaughan
left a comment
There was a problem hiding this comment.
I think the positioning makes sense based on what I remember about this
|
Don't have anything to add on top of Davis' comments |
| #' default branch which is usually "main" or "master". | ||
| gh_lock_branch <- function(branch = NULL) { | ||
| cfg <- github_remote_config(github_get = TRUE) | ||
| repo <- target_repo(cfg) |
There was a problem hiding this comment.
Right around here we could adapt this code we use in use_release_issue() and use_upkeep_issue() except I guess we just tell people that don't have enough permission to do this:
Lines 38 to 47 in 0592077
There was a problem hiding this comment.
I think it's probably fine to let the GitHub error bubble up, and then we can add more user-friendly errors if we discover it's causing substantial confusion.
There was a problem hiding this comment.
I went ahead and emitted our own error. It's a big improvement on what happens otherwise:
Letting the gh error bubble up, we get a mysterious 404:
> github_lock_branch()
✔ Setting active project to "/Users/jenny/tmp/nettskjemar".
Run `rlang::last_trace()` to see where the error occurred.
Error in `gh::gh()` at usethis/R/utils-gh.R:6:5:
! GitHub API error (404): Not Found
✖ URL not found:
<https://api.github.com/repos/cran/nettskjemar/branches/master/protection>
ℹ Read more at
<https://docs.github.com/rest/branches/branch-protection#update-branch-protection>
If we check for admin permissions and message:
> github_lock_branch()
✔ Setting active project to "/Users/jenny/tmp/nettskjemar".
Run `rlang::last_trace()` to see where the error occurred.
Error in `github_lock_branch()`:
✖ You don't seem to have admin permissions for the source repo
"cran/nettskjemar", which is required to lock a branch.
Looking at other function names we use "github" (vs. "gh") everywhere except `gh_token_help()`. And that is arguably correct, since you could view that function as helping the gh package get a suitable token.
Also, move to different file.
|
The CI failure is because the Air |
I have learned the hard way that we need to more fully reverse github_lock_branch() in order to be able to delete a branch later. Learned with a PR branch. Won't come up often IRL because we will mostly lock / unlock `main`. But still better to leave things as we found them.
This ensures that there's no way to accidentally forget that you're in the middle of the release process and make a change to the repo.
Part of #1946
@DavisVaughan it's been a long time since we discussed this, but does this make sense to you?
@jennybc mostly opening to start discussion; not planning to merge just yet.