@@ -200,7 +200,7 @@
Loading
200 200
    if (!is.na(remref)) {
201 201
      comparison <- git_branch_compare(current_branch, remref)
202 202
      if (comparison$remote_only > 0) {
203 -
        check_no_uncommitted_changes(untracked = TRUE)
203 +
        challenge_uncommitted_changes(untracked = TRUE)
204 204
      }
205 205
      ui_info("Pulling changes from {ui_value(remref)}")
206 206
      git_pull(remref = remref, verbose = FALSE)
@@ -245,7 +245,7 @@
Loading
245 245
      Call {ui_code(code)} to create a new PR branch")
246 246
  }
247 247
248 -
  check_no_uncommitted_changes(untracked = TRUE)
248 +
  challenge_uncommitted_changes(untracked = TRUE)
249 249
250 250
  ui_done("Switching to branch {ui_value(branch)}")
251 251
  gert::git_branch_checkout(branch, repo = repo)
@@ -265,7 +265,7 @@
Loading
265 265
#' }
266 266
pr_fetch <- function(number = NULL) {
267 267
  tr <- target_repo(github_get = TRUE)
268 -
  check_no_uncommitted_changes()
268 +
  challenge_uncommitted_changes()
269 269
270 270
  if (is.null(number)) {
271 271
    ui_info("No PR specified ... looking up open PRs")
@@ -354,7 +354,7 @@
Loading
354 354
  cfg <- github_remote_config(github_get = TRUE)
355 355
  check_ours_or_fork(cfg)
356 356
  check_pr_branch()
357 -
  check_no_uncommitted_changes()
357 +
  challenge_uncommitted_changes()
358 358
359 359
  repo <- git_repo()
360 360
  branch <- git_branch()
@@ -406,7 +406,7 @@
Loading
406 406
pr_pull <- function() {
407 407
  check_ours_or_fork()
408 408
  check_pr_branch()
409 -
  check_no_uncommitted_changes()
409 +
  challenge_uncommitted_changes()
410 410
411 411
  git_pull()
412 412
@@ -417,7 +417,7 @@
Loading
417 417
#' @rdname pull-requests
418 418
pr_merge_main <- function() {
419 419
  tr <- target_repo(github_get = TRUE, ask = FALSE)
420 -
  check_no_uncommitted_changes()
420 +
  challenge_uncommitted_changes()
421 421
  remref <- glue("{tr$remote}/{git_branch_default()}")
422 422
  ui_done("
423 423
    Pulling in changes from default branch of the source repo \\
@@ -496,7 +496,7 @@
Loading
496 496
      Nothing to do")
497 497
    return(invisible())
498 498
  }
499 -
  check_no_uncommitted_changes()
499 +
  challenge_uncommitted_changes()
500 500
  # TODO: what happens here if offline?
501 501
  check_branch_pulled(use = "pr_pull()")
502 502
@@ -516,7 +516,7 @@
Loading
516 516
  }
517 517
518 518
  check_pr_branch()
519 -
  check_no_uncommitted_changes()
519 +
  challenge_uncommitted_changes()
520 520
521 521
  branch <- git_branch()
522 522

@@ -58,11 +58,6 @@
Loading
58 58
                       host = NULL,
59 59
                       auth_token = deprecated(),
60 60
                       credentials = deprecated()) {
61 -
  check_uses_git()
62 -
  check_default_branch()
63 -
  check_no_uncommitted_changes()
64 -
  check_no_origin()
65 -
66 61
  if (lifecycle::is_present(auth_token)) {
67 62
    deprecate_warn_auth_token("use_github")
68 63
  }
@@ -70,6 +65,13 @@
Loading
70 65
    deprecate_warn_credentials("use_github")
71 66
  }
72 67
68 +
  check_uses_git()
69 +
  check_default_branch()
70 +
  challenge_uncommitted_changes(msg = "
71 +
    There are uncommitted changes and we're about to create and push to a new \\
72 +
    GitHub repo")
73 +
  check_no_origin()
74 +
73 75
  whoami <- suppressMessages(gh::gh_whoami(.api_url = host))
74 76
  if (is.null(whoami)) {
75 77
    ui_stop("

@@ -37,7 +37,9 @@
Loading
37 37
  }
38 38
39 39
  check_is_package("use_version()")
40 -
  check_no_uncommitted_changes()
40 +
  challenge_uncommitted_changes(
41 +
    msg = "There are uncommitted changes and you're about to bump version"
42 +
  )
41 43
42 44
  new_ver <- choose_version(which)
43 45
  if (is.null(new_ver)) {

@@ -174,7 +174,9 @@
Loading
174 174
#' @rdname tidyverse
175 175
use_tidy_style <- function(strict = TRUE) {
176 176
  check_installed("styler")
177 -
  check_no_uncommitted_changes()
177 +
  challenge_uncommitted_changes(msg = "
178 +
    There are uncommitted changes and it is highly recommended to get into a \\
179 +
    clean Git state before restyling your project's code")
178 180
  if (is_package()) {
179 181
    styled <- styler::style_pkg(
180 182
      proj_get(),

@@ -8,8 +8,6 @@
Loading
8 8
#'   Packages](https://r-pkgs.org).
9 9
#' @export
10 10
use_news_md <- function(open = rlang::is_interactive()) {
11 -
  check_no_uncommitted_changes()
12 -
13 11
  use_template(
14 12
    "NEWS.md",
15 13
    data = package_data(),

@@ -111,7 +111,7 @@
Loading
111 111
  nrow(git_status(untracked)) > 0
112 112
}
113 113
114 -
check_no_uncommitted_changes <- function(untracked = FALSE) {
114 +
challenge_uncommitted_changes <- function(untracked = FALSE, msg = NULL) {
115 115
  if (!uses_git()) {
116 116
    return(invisible())
117 117
  }
@@ -120,12 +120,12 @@
Loading
120 120
    rstudioapi::documentSaveAll()
121 121
  }
122 122
123 -
  # TODO: present a more useful overview of the situation?
123 +
  default_msg <- "
124 +
    There are uncommitted changes, which may cause problems when \\
125 +
    we push, pull, or switch branches"
126 +
  msg <- glue(msg %||% default_msg)
124 127
  if (git_uncommitted(untracked = untracked)) {
125 -
    if (ui_yeah("
126 -
          There are uncommitted changes, which may cause problems when \\
127 -
          we push, pull, or switch branches.
128 -
          Do you want to proceed anyway?")) {
128 +
    if (ui_yeah("{msg}\nDo you want to proceed anyway?")) {
129 129
      return(invisible())
130 130
    } else {
131 131
      ui_stop("Uncommitted changes. Please commit before continuing.")
Files Coverage
R 51.73%
Project Totals (64 files) 51.73%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading