Skip to content

Commit 52593d8

Browse files
committed
Revert the addition of github_(un)lock_branch()
This reverts commits: * b4ffeeb * ca6cc25 * 66d0437 See notes in #1946 for why I reverted and what it will take to do this on our next attempt.
1 parent b4ffeeb commit 52593d8

File tree

8 files changed

+1
-142
lines changed

8 files changed

+1
-142
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ Config/usethis/last-upkeep: 2025-04-22
6363
Encoding: UTF-8
6464
Language: en-US
6565
Roxygen: list(markdown = TRUE)
66-
RoxygenNote: 7.3.3
66+
RoxygenNote: 7.3.2.9000

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ export(git_protocol)
4141
export(git_remotes)
4242
export(git_sitrep)
4343
export(git_vaccinate)
44-
export(github_lock_branch)
45-
export(github_unlock_branch)
4644
export(issue_close_community)
4745
export(issue_reprex_needed)
4846
export(local_project)

NEWS.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# usethis (development version)
22

3-
* `github_lock_branch()` and `github_unlock_branch()` are new functions to lock
4-
and unlock a GitHub branch, which is now part of the release checklist
5-
generated by `use_release_issue()` (#2145).
63
* `create_quarto_project()` exits early if the Quarto CLI does not appear to be
74
installed and related tests are skipped (#2162).
85

R/github.R

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -224,101 +224,6 @@ use_github_links <- function(overwrite = FALSE) {
224224
invisible()
225225
}
226226

227-
#' Lock and unlock a branch on GitHub
228-
#'
229-
#' @description
230-
#' These functions lock and unlock a branch on GitHub so that it's not possible
231-
#' for anyone to make any changes. They are used in the release checklist
232-
#' generated by [use_release_issue()]. The objective is to ensure that, once
233-
#' you've submitted your package to CRAN, you don't accidentally merge any pull
234-
#' requests or push any commits, while you are waiting for CRAN to get back to
235-
#' you. This, in turn, helps guarantee that your future Git release tag points
236-
#' to the correct commit.
237-
#'
238-
#' You must be an admin or an owner of the repo in order to lock/unlock
239-
#' a branch.
240-
#'
241-
#' @export
242-
#' @param branch The branch to lock/unlock. If not supplied, uses the
243-
#' default branch which is usually "main" or "master", as determined by
244-
#' [git_default_branch()].
245-
github_lock_branch <- function(branch = NULL) {
246-
cfg <- github_remote_config(github_get = TRUE)
247-
tr <- target_repo(cfg, role = "source", ask = FALSE)
248-
branch <- branch %||% git_default_branch_(cfg)
249-
250-
if (!isTRUE(tr$can_admin)) {
251-
ui_abort(
252-
"
253-
You don't seem to have {.field admin} permissions for the source repo
254-
{.val {tr$repo_spec}}, which is required to lock a branch."
255-
)
256-
}
257-
258-
gh <- gh_tr(tr)
259-
out <- gh(
260-
"PUT /repos/{owner}/{repo}/branches/{branch}/protection",
261-
branch = branch,
262-
# required parameters
263-
required_status_checks = NA,
264-
enforce_admins = TRUE,
265-
required_pull_request_reviews = NA,
266-
restrictions = NA,
267-
# paramater that actually does what we want
268-
lock_branch = TRUE
269-
)
270-
result <- pluck_lgl(out, "lock_branch")
271-
272-
if (isTRUE(result)) {
273-
ui_bullets(c(
274-
"v" = "Branch {.val {branch}} is locked."
275-
))
276-
}
277-
278-
invisible(out)
279-
}
280-
281-
#' @export
282-
#' @rdname github_lock_branch
283-
github_unlock_branch <- function(branch = NULL) {
284-
cfg <- github_remote_config(github_get = TRUE)
285-
tr <- target_repo(cfg, role = "source", ask = FALSE)
286-
branch <- branch %||% git_default_branch_(cfg)
287-
288-
if (!isTRUE(tr$can_admin)) {
289-
ui_abort(
290-
"
291-
You don't seem to have {.field admin} permissions for the source repo
292-
{.val {tr$repo_spec}}, which is required to unlock a branch."
293-
)
294-
}
295-
296-
gh <- gh_tr(tr)
297-
# using the endpoint to update branch protection instead of the one for
298-
# deletion, in order to get a response that helps us emit a good message
299-
# and invisibly return something useful
300-
out <- gh(
301-
"PUT /repos/{owner}/{repo}/branches/{branch}/protection",
302-
branch = branch,
303-
# required parameters
304-
required_status_checks = NA,
305-
enforce_admins = FALSE,
306-
required_pull_request_reviews = NA,
307-
restrictions = NA,
308-
# paramater that actually does what we want
309-
lock_branch = FALSE
310-
)
311-
result <- pluck_lgl(out, "lock_branch")
312-
313-
if (isFALSE(result)) {
314-
ui_bullets(c(
315-
"v" = "Branch {.val {branch}} is unlocked."
316-
))
317-
}
318-
319-
invisible(out)
320-
}
321-
322227
has_github_links <- function(target_repo = NULL) {
323228
url <- if (is.null(target_repo)) NULL else target_repo$url
324229
github_url <- github_url_from_git_remotes(url)

R/release.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,13 @@ release_checklist <- function(version, on_cran, target_repo = NULL) {
132132
"",
133133
"Submit to CRAN:",
134134
"",
135-
todo("`usethis::github_lock_branch()`"),
136135
todo("`usethis::use_version('{type}')`"),
137136
todo("`devtools::submit_cran()`"),
138137
todo("Approve email"),
139138
"",
140139
"Wait for CRAN...",
141140
"",
142141
todo("Accepted :tada:"),
143-
todo("`usethis::github_unlock_branch()`"),
144142
todo("Finish & publish blog post", type != "patch"),
145143
todo("Add link to blog post in pkgdown news menu", type != "patch"),
146144
todo("`usethis::use_github_release()`"),

_pkgdown.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ reference:
121121
- starts_with("use_github")
122122
- git_sitrep
123123
- create_github_token
124-
- github_lock_branch
125124
- gh_token_help
126125
- git_vaccinate
127126
- use_git_config

man/github_lock_branch.Rd

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/testthat/_snaps/release.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
2727
Submit to CRAN:
2828
29-
* [ ] `usethis::github_lock_branch()`
3029
* [ ] `usethis::use_version('minor')`
3130
* [ ] `devtools::submit_cran()`
3231
* [ ] Approve email
3332
3433
Wait for CRAN...
3534
3635
* [ ] Accepted :tada:
37-
* [ ] `usethis::github_unlock_branch()`
3836
* [ ] Finish & publish blog post
3937
* [ ] Add link to blog post in pkgdown news menu
4038
* [ ] `usethis::use_github_release()`
@@ -62,15 +60,13 @@
6260
6361
Submit to CRAN:
6462
65-
* [ ] `usethis::github_lock_branch()`
6663
* [ ] `usethis::use_version('patch')`
6764
* [ ] `devtools::submit_cran()`
6865
* [ ] Approve email
6966
7067
Wait for CRAN...
7168
7269
* [ ] Accepted :tada:
73-
* [ ] `usethis::github_unlock_branch()`
7470
* [ ] `usethis::use_github_release()`
7571
* [ ] `usethis::use_dev_version(push = TRUE)`
7672
* [ ] `usethis::use_news_md()`
@@ -97,15 +93,13 @@
9793
9894
Submit to CRAN:
9995
100-
* [ ] `usethis::github_lock_branch()`
10196
* [ ] `usethis::use_version('major')`
10297
* [ ] `devtools::submit_cran()`
10398
* [ ] Approve email
10499
105100
Wait for CRAN...
106101
107102
* [ ] Accepted :tada:
108-
* [ ] `usethis::github_unlock_branch()`
109103
* [ ] Finish & publish blog post
110104
* [ ] Add link to blog post in pkgdown news menu
111105
* [ ] `usethis::use_github_release()`
@@ -154,15 +148,13 @@
154148
155149
Submit to CRAN:
156150
157-
* [ ] `usethis::github_lock_branch()`
158151
* [ ] `usethis::use_version('major')`
159152
* [ ] `devtools::submit_cran()`
160153
* [ ] Approve email
161154
162155
Wait for CRAN...
163156
164157
* [ ] Accepted :tada:
165-
* [ ] `usethis::github_unlock_branch()`
166158
* [ ] Finish & publish blog post
167159
* [ ] Add link to blog post in pkgdown news menu
168160
* [ ] `usethis::use_github_release()`
@@ -192,15 +184,13 @@
192184
193185
Submit to CRAN:
194186
195-
* [ ] `usethis::github_lock_branch()`
196187
* [ ] `usethis::use_version('major')`
197188
* [ ] `devtools::submit_cran()`
198189
* [ ] Approve email
199190
200191
Wait for CRAN...
201192
202193
* [ ] Accepted :tada:
203-
* [ ] `usethis::github_unlock_branch()`
204194
* [ ] Finish & publish blog post
205195
* [ ] Add link to blog post in pkgdown news menu
206196
* [ ] `usethis::use_github_release()`

0 commit comments

Comments
 (0)