Skip to content

Commit 681c630

Browse files
committed
fix: Properly detect unstaged files in Git and respect user's choice in the interactive menu
1 parent 60e9ca0 commit 681c630

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# flir (0.4.1)
2+
3+
## Bug fixes
4+
5+
* Changes were still directly applied to files that are unstaged
6+
in Git while there should have been a warning. This is now fixed.
7+
8+
* Properly skip changes in the user picks "No" in the menu about
9+
modifying unstaged files in Git.
10+
111
# flir (0.4.0)
212

313
## Breaking changes

R/fix.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,17 @@ fix <- function(
6868

6969
if (uses_git()) {
7070
unstaged_files <- unlist(git2r::status()$unstaged)
71+
unstaged_files <- fs::path_abs(unstaged_files)
7172
if (any(r_files %in% unstaged_files)) {
7273
if (interactive()) {
73-
utils::menu(
74+
choice <- utils::menu(
7475
title = "It is recommended to commit or discard all modified files before running `fix()`. Do you want to apply fixes anyway?",
7576
choices = c("Yes", "No")
7677
)
78+
if (choice == 2) {
79+
cli::cli_inform(c(i = "No changes applied."))
80+
return(invisible())
81+
}
7782
} else if (isFALSE(force)) {
7883
stop(
7984
"It is recommended to commit or discard all modified files before running `fix()`. Therefore, this operation is not allowed by default in

inst/cache_file_state.rds

-12 KB
Binary file not shown.

tests/testthat/test-rep_len.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test_that("rep_len_linter blocks simple disallowed usages", {
3939

4040
test_that("vectorized lints work", {
4141
linter <- rep_len_linter()
42-
lint_msg <- rex::rex("Use rep_len(x, n) instead of rep(x, length.out = n).")
42+
lint_msg <- "Use rep_len(x, n) instead of rep(x, length.out = n)."
4343

4444
expect_equal(
4545
nrow(

0 commit comments

Comments
 (0)