Skip to content

Commit

Permalink
Reduce a few more uses
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Sep 20, 2024
1 parent 1d439f4 commit 113ade0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/github.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use_github <- function(organisation = NULL,
visibility <- match.arg(visibility)
check_protocol(protocol)
check_uses_git()
default_branch <- git_default_branch()
default_branch <- guess_local_default_branch()

Check warning on line 64 in R/github.R

View check run for this annotation

Codecov / codecov/patch

R/github.R#L64

Added line #L64 was not covered by tests
check_current_branch(
is = default_branch,
# glue-ing happens inside check_current_branch(), where `gb` gives the
Expand Down
8 changes: 2 additions & 6 deletions R/pr.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pr_resume <- function(branch = NULL) {
ui_bullets(c(
"i" = "No branch specified ... looking up local branches and associated PRs."
))
default_branch <- git_default_branch()
default_branch <- guess_local_default_branch()

Check warning on line 240 in R/pr.R

View check run for this annotation

Codecov / codecov/patch

R/pr.R#L240

Added line #L240 was not covered by tests
branch <- choose_branch(exclude = default_branch)
if (is.null(branch)) {
ui_bullets(c("x" = "Repo doesn't seem to have any non-default branches."))
Expand Down Expand Up @@ -632,14 +632,10 @@ pr_clean <- function(number = NULL,
# we're in DEFAULT branch of a fork. I wish everyone set up DEFAULT to track the
# DEFAULT branch in the source repo, but this protects us against sub-optimal
# setup.
pr_pull_source_override <- function(tr = NULL, default_branch = NULL) {
# naive selection of target repo; calling function should analyse the config
tr <- tr %||% target_repo(github_get = FALSE, ask = FALSE)

pr_pull_source_override <- function(tr, default_branch) {
# TODO: why does this not use a check_*() function, i.e. shared helper?
# I guess to issue a specific error message?
current_branch <- git_branch()
default_branch <- default_branch %||% git_default_branch()
if (current_branch != default_branch) {
ui_abort("
Internal error: {.fun pr_pull_source_override} should only be used when on
Expand Down

0 comments on commit 113ade0

Please sign in to comment.