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

bugfix: .R, .Rmd, .qmd are extensions, not substrings #1107

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# rsconnect (development version)

* Primary Quarto document detection only considers `.R`, `.Rmd`, and `.qmd` as
end-of-file extensions. Previously, a file with `.R` elsewhere in its name,
such as `.Rprofile`, was incorrectly considered. (#1106)

* Use the public Connect server API endpoint `/v1/tasks/{id}` to poll task
progress. (#1088)

Expand Down
4 changes: 2 additions & 2 deletions R/appMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ inferAppPrimaryDoc <- function(appPrimaryDoc, appFiles, appMode) {
# determine expected primary document extension
ext <- switch(appMode,
"static" = "\\.html?$",
"quarto-static" = "\\.(r|rmd|qmd)",
"quarto-shiny" = "\\.(rmd|qmd)",
"quarto-static" = "\\.(r|rmd|qmd)$",
"quarto-shiny" = "\\.(rmd|qmd)$",
"\\.rmd$")

# use index file if it exists
Expand Down
1 change: 1 addition & 0 deletions rsconnect.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 3d8f30a6-9562-4255-8985-ba9413556e97

RestoreWorkspace: No
SaveWorkspace: No
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/appMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
Condition
Error in `inferAppPrimaryDoc()`:
! Failed to determine `appPrimaryDoc` for "quarto-static" content.
x No files matching "\\.(r|rmd|qmd)".
x No files matching "\\.(r|rmd|qmd)$".
Code
inferAppPrimaryDoc(NULL, "a.html", "quarto-shiny")
Condition
Error in `inferAppPrimaryDoc()`:
! Failed to determine `appPrimaryDoc` for "quarto-shiny" content.
x No files matching "\\.(rmd|qmd)".
x No files matching "\\.(rmd|qmd)$".

13 changes: 12 additions & 1 deletion tests/testthat/test-appMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,20 @@ test_that("uses index file if present", {
})

test_that("otherwise fails back to first file with matching extensions", {
files <- c("a.html", "b.html", "a.Rmd", "b.Rmd")
files <- c(".Rprofile", "a.html", "b.html", "a.Rmd", "b.Rmd")
expect_equal(inferAppPrimaryDoc(NULL, files, "static"), "a.html")
expect_equal(inferAppPrimaryDoc(NULL, files, "rmd-static"), "a.Rmd")
expect_equal(inferAppPrimaryDoc(NULL, files, "rmd-shiny"), "a.Rmd")
expect_equal(inferAppPrimaryDoc(NULL, files, "quarto-static"), "a.Rmd")
expect_equal(inferAppPrimaryDoc(NULL, files, "quarto-shiny"), "a.Rmd")
})

test_that("can use R, Rmd, and qmd files for Quarto modes", {
expect_equal(inferAppPrimaryDoc(NULL, c(".Rprofile", "foo.R"), "quarto-static"), "foo.R")
expect_equal(inferAppPrimaryDoc(NULL, c(".Rprofile", "foo.Rmd"), "quarto-static"), "foo.Rmd")
expect_equal(inferAppPrimaryDoc(NULL, c(".Rprofile", "foo.qmd"), "quarto-static"), "foo.qmd")
expect_equal(inferAppPrimaryDoc(NULL, c(".Rprofile", "foo.Rmd"), "quarto-shiny"), "foo.Rmd")
expect_equal(inferAppPrimaryDoc(NULL, c(".Rprofile", "foo.qmd"), "quarto-shiny"), "foo.qmd")
})

test_that("errors if no files with needed extension", {
Expand Down
Loading