Skip to content
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

Add more PR links #1981

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions R/pr.R
Original file line number Diff line number Diff line change
Expand Up @@ -867,23 +867,25 @@ choose_branch <- function(exclude = character()) {
)
prompt <- glue("{prompt}\n{fine_print}")
}
dat$pretty_name <- format(dat$name, justify = "right")

# For alignment
dat$leading_spaces <- sub("\\S.*$", "", format(dat$name, justify = "right"))
dat_pretty <- purrr::pmap_chr(
dat[c("pretty_name", "pr_number", "pr_html_url", "pr_user", "pr_title")],
function(pretty_name, pr_number, pr_html_url, pr_user, pr_title) {
dat[c("leading_spaces", "pr_number", "pr_html_url", "pr_user", "pr_title", "name")],
function(leading_spaces, pr_number, pr_html_url, pr_user, pr_title, name) {
if (is.na(pr_number)) {
pretty_name
cli::format_inline("{leading_spaces}{.run [{name}](usethis::pr_resume('{name}'))}")
} else {
href_number <- ui_pre_glue("{.href [PR #<<pr_number>>](<<pr_html_url>>)}")
at_user <- glue("@{pr_user}")
template <- ui_pre_glue(
"{pretty_name} {cli::symbol$arrow_right} <<href_number>> ({.field <<at_user>>}): {.val <<pr_title>>}"
"{leading_spaces}{.run [{name}](usethis::pr_resume('{name}'))} {cli::symbol$arrow_right} <<href_number>> ({.field <<at_user>>}): {.val <<pr_title>>}"
)
cli::format_inline(template)
}
}
)
choice <- utils::menu(title = prompt, choices = cli::ansi_strtrim(dat_pretty))
choice <- utils::menu(title = prompt, choices = cli::ansi_strtrim(dat_pretty, width = cli::console_width() - 1L))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full width looks bad currently in RStudio (tends to switch line)

Saw the same thing in r-lib/styler#1189.

dat$name[choice]
}

Expand Down Expand Up @@ -936,7 +938,7 @@ choose_pr <- function(tr = NULL, pr_dat = NULL) {
)
choice <- utils::menu(
title = prompt,
choices = cli::ansi_strtrim(pr_pretty)
choices = cli::ansi_strtrim(pr_pretty, width = cli::console_width() - 1L)
)
as.list(pr_dat[choice, ])
}
Expand Down Expand Up @@ -967,22 +969,22 @@ pr_branch_delete <- function(pr) {

if (is.null(pr_ref)) {
ui_bullets(c(
"i" = "PR {.val {pr$pr_string}} originated from branch {.val {pr_remref}},
"i" = "{.href [PR {pr$pr_string}]({pr$pr_html_url})} originated from branch {.val {pr_remref}},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"i" = "{.href [PR {pr$pr_string}]({pr$pr_html_url})} originated from branch {.val {pr_remref}},
"i" = "{.href [PR {pr$pr_number}]({pr$pr_html_url})} originated from branch {.val {pr_remref}},

This looks a bit bad.
image

Any reason on why not just including the PR Number?

which no longer exists."
))
return(invisible(FALSE))
}

if (is.na(pr$pr_merged_at)) {
ui_bullets(c(
"i" = "PR {.val {pr$pr_string}} is unmerged, we will not delete the
"i" = "{.href [PR {pr$pr_string}]({pr$pr_html_url})} is unmerged, we will not delete the
remote branch {.val {pr_remref}}."
))
return(invisible(FALSE))
}

ui_bullets(c(
"v" = "PR {.val {pr$pr_string}} has been merged, deleting remote branch
"v" = "{.href [PR {pr$pr_string}]({pr$pr_html_url})} has been merged, deleting remote branch
{.val {pr_remref}}."
))
# TODO: tryCatch here?
Expand Down
Loading