-
Notifications
You must be signed in to change notification settings - Fork 289
Lock and unlock branch as part of the release process #2145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0178d05
865e9bf
1f66e24
0fa7197
33d8ad5
982686c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -296,3 +296,52 @@ scold_for_scopes <- function(scopes) { | |||||||||||||||||||||
) | ||||||||||||||||||||||
ui_bullets(message) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
#' Lock and unlock a branch on GitHub | ||||||||||||||||||||||
#' | ||||||||||||||||||||||
#' @description | ||||||||||||||||||||||
#' These functions lock and unlock a branch on GitHub so that it's not possible | ||||||||||||||||||||||
#' for anyone to make any changes. This is used as part of the release process | ||||||||||||||||||||||
#' to ensure that you don't accidentally merge any pull requests or push any | ||||||||||||||||||||||
#' commits while you are waiting for CRAN to get back to you. | ||||||||||||||||||||||
Comment on lines
+303
to
+306
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anything about permissions required to perform this action? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to be an admin or owner, which I've documented. It looks like this is already in line with our governance tidyup where the maintainer has admin access: https://github.com/tidyverse/tidyups/blob/main/004-governance.md#maintainer. |
||||||||||||||||||||||
#' | ||||||||||||||||||||||
#' You must be an admin or an owner of the repo in order to lock/unlock | ||||||||||||||||||||||
#' a branch. | ||||||||||||||||||||||
#' | ||||||||||||||||||||||
#' @export | ||||||||||||||||||||||
#' @param branch The branch to lock/unlock. If not supplied, uses the | ||||||||||||||||||||||
#' 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right around here we could adapt this code we use in Lines 38 to 47 in 0592077
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||||||||||||||||||||||
branch <- branch %||% git_default_branch_(cfg) | ||||||||||||||||||||||
|
||||||||||||||||||||||
invisible(gh::gh( | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if you lock an already locked branch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it's idempotent |
||||||||||||||||||||||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection", | ||||||||||||||||||||||
owner = repo$repo_owner, | ||||||||||||||||||||||
repo = repo$repo_name, | ||||||||||||||||||||||
Comment on lines
+321
to
+322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually do a different move to create these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||||||||||||||||||||||
branch = branch, | ||||||||||||||||||||||
# required parameters | ||||||||||||||||||||||
required_status_checks = NA, | ||||||||||||||||||||||
enforce_admins = TRUE, | ||||||||||||||||||||||
required_pull_request_reviews = NA, | ||||||||||||||||||||||
restrictions = NA, | ||||||||||||||||||||||
# paramter that actually does what we want | ||||||||||||||||||||||
lock_branch = TRUE | ||||||||||||||||||||||
)) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
#' @export | ||||||||||||||||||||||
#' @rdname gh_lock_branch | ||||||||||||||||||||||
gh_unlock_branch <- function(branch = NULL) { | ||||||||||||||||||||||
cfg <- github_remote_config(github_get = TRUE) | ||||||||||||||||||||||
repo <- target_repo(cfg) | ||||||||||||||||||||||
branch <- branch %||% git_default_branch_(cfg) | ||||||||||||||||||||||
|
||||||||||||||||||||||
invisible(gh::gh( | ||||||||||||||||||||||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection", | ||||||||||||||||||||||
owner = repo$repo_owner, | ||||||||||||||||||||||
repo = repo$repo_name, | ||||||||||||||||||||||
branch = branch | ||||||||||||||||||||||
)) | ||||||||||||||||||||||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we think of
github_lock_branch()
? Just want us to at least consider. I don't have a strong opinion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion either. If you want user-facing functions to use a
github_
prefix I'm happy to change it.