-
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -280,10 +280,12 @@ scold_for_scopes <- function(scopes) { | |||||
|
||||||
suggestions <- c( | ||||||
"*" = if (!has_repo) "{.val repo}: needed to fully access user's repos", | ||||||
"*" = if (!has_workflow) | ||||||
"{.val workflow}: needed to manage GitHub Actions workflow files", | ||||||
"*" = if (!has_user_email) | ||||||
"*" = if (!has_workflow) { | ||||||
"{.val workflow}: needed to manage GitHub Actions workflow files" | ||||||
}, | ||||||
"*" = if (!has_user_email) { | ||||||
"{.val user:email}: needed to read user's email addresses" | ||||||
} | ||||||
) | ||||||
message <- c( | ||||||
"!" = "Token lacks recommended scopes:", | ||||||
|
@@ -294,3 +296,48 @@ scold_for_scopes <- function(scopes) { | |||||
) | ||||||
ui_bullets(message) | ||||||
} | ||||||
|
||||||
#' Lock and unlock a branch on GitHub | ||||||
#' | ||||||
#' 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. | ||||||
#' | ||||||
#' @export | ||||||
#' @param branch The branch to lock/unlock. If not supplied, uses the | ||||||
#' default branch with is usually "main" or "master". | ||||||
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.
Suggested change
|
||||||
gh_lock_branch <- function(branch = NULL) { | ||||||
cfg <- github_remote_config(github_get = TRUE) | ||||||
repo <- target_repo(cfg) | ||||||
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? |
||||||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection", | ||||||
owner = repo$repo_owner, | ||||||
repo = repo$repo_name, | ||||||
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 | ||||||
)) | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -81,7 +81,7 @@ release_checklist <- function(version, on_cran, target_repo = NULL) { | |||||
milestone_num <- gh_milestone_number(target_repo, version) | ||||||
|
||||||
c( | ||||||
if (!on_cran) | ||||||
if (!on_cran) { | ||||||
c( | ||||||
"First release:", | ||||||
"", | ||||||
|
@@ -100,7 +100,8 @@ release_checklist <- function(version, on_cran, target_repo = NULL) { | |||||
), | ||||||
todo("Review <https://github.com/DavisVaughan/extrachecks>"), | ||||||
"" | ||||||
), | ||||||
) | ||||||
}, | ||||||
"Prepare for release:", | ||||||
"", | ||||||
todo("`git pull`"), | ||||||
|
@@ -137,13 +138,15 @@ release_checklist <- function(version, on_cran, target_repo = NULL) { | |||||
"", | ||||||
"Submit to CRAN:", | ||||||
"", | ||||||
todo("`usethis::gh_lock_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.
Suggested change
|
||||||
todo("`usethis::use_version('{type}')`"), | ||||||
todo("`devtools::submit_cran()`"), | ||||||
todo("Approve email"), | ||||||
"", | ||||||
"Wait for CRAN...", | ||||||
"", | ||||||
todo("Accepted :tada:"), | ||||||
todo("`usethis::gh_unlock_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.
Suggested change
|
||||||
todo("Finish & publish blog post", type != "patch"), | ||||||
todo("Add link to blog post in pkgdown news menu", type != "patch"), | ||||||
todo("`usethis::use_github_release()`"), | ||||||
|
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.
Anything about permissions required to perform this action?