-
Notifications
You must be signed in to change notification settings - Fork 285
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 use_blank_slate() #139
Conversation
R/rstudio.R
Outdated
scope <- match.arg(scope) | ||
|
||
if (scope == "user") { | ||
message( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this appalls you. Happy to implement in a more usethis-style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, just use todo()
instead of message()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 0dbc25a
R/rstudio.R
Outdated
rproj_path(), | ||
list(RestoreWorkspace = "No", SaveWorkspace = "No") | ||
) | ||
write_utf8(file.path(proj_get(), rproj_path()), rproj_options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer write_over()
but I don't want to ask user's permission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's fine
R/rstudio.R
Outdated
write_utf8(file.path(proj_get(), rproj_path()), rproj_options) | ||
restart_rstudio( | ||
"A restart of RStudio is required to activate fresh starts" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed restart is necessary for this to take effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just "Restart RStudio for a fresh state?"
a6e3d9d
to
3ccf9b0
Compare
R/rstudio.R
Outdated
#' @inheritParams edit | ||
#' | ||
#' @export | ||
use_freshstarts <- function(scope = c("user", "project")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be use_fresh_starts()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use_blank_slate()
? use_tabula_rasa()
?
R/rstudio.R
Outdated
#' starts provide timely feedback that encourages the development of scripts | ||
#' that are complete and self-contained. | ||
#' | ||
#' Only `use_freshstarts("project")` is implemented so far, since RStudio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented -> automated
R/rstudio.R
Outdated
#' | ||
#' Only `use_freshstarts("project")` is implemented so far, since RStudio | ||
#' currently only supports modification of user-level or global options via the | ||
#' user interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to blog post for more info?
R/rstudio.R
Outdated
scope <- match.arg(scope) | ||
|
||
if (scope == "user") { | ||
message( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, just use todo()
instead of message()
.
R/rstudio.R
Outdated
rproj_path(), | ||
list(RestoreWorkspace = "No", SaveWorkspace = "No") | ||
) | ||
write_utf8(file.path(proj_get(), rproj_path()), rproj_options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's fine
R/rstudio.R
Outdated
write_utf8(file.path(proj_get(), rproj_path()), rproj_options) | ||
restart_rstudio( | ||
"A restart of RStudio is required to activate fresh starts" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just "Restart RStudio for a fresh state?"
R/rstudio.R
Outdated
@@ -32,3 +95,37 @@ in_rstudio <- function(base_path = proj_get()) { | |||
|
|||
normalizePath(proj) == normalizePath(base_path) | |||
} | |||
|
|||
build_rproj <- function(file, fields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a bunch of unit tests for this, since it's fairly high risk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests added. This is ready for another look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call it |
e1d59d8
to
4879ae8
Compare
* scoped-temporary-things: Prefer capture_output() to capture.output() Make scoped_temporary_package callable from the console Move scoped_temporary_package() to test dir
* careful-rbuildignore: More specific pattern re: Rbuildignoring .Rproj files Remove .Rbuildignore from .gitignore More specific Rbuildignore for usethis.Rproj Test we can find templates vulnerable to Rbuildignore
@@ -1,4 +1,4 @@ | |||
^.*\.Rproj$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't RStudio modify this when you re-open?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not for me. Does it for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I could've sworn it did in the past, but not this time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have even checked with a full "new Project (that is a package) from GitHub" workflow. And RStudio doesn't modify this in .Rbuildignore
I've come to the conclusion that the problem of the missing template was self-inflicted. Although maybe that .Rbuildignore
line was originally inspired by RStudio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed x2
tests/testthat/test-rstudio.R
Outdated
expect_identical(rproj, paste0(basename(dir), ".Rproj")) | ||
}) | ||
|
||
test_that("a non-RStudio project is recognized", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is not recognised?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok changed
tests/testthat/test-rstudio.R
Outdated
list() | ||
) | ||
writeLines(serialize_rproj(rproj), tmp) | ||
expect_equivalent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not expect_equal()
on the lines themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok changed
@hadley look again? |
R/rstudio.R
Outdated
@@ -13,12 +13,88 @@ use_rstudio <- function() { | |||
|
|||
use_git_ignore(".Rproj.user") | |||
if (is_package()) { | |||
use_build_ignore(c("^.*\\.Rproj$", "^\\.Rproj\\.user$"), escape = FALSE) | |||
use_build_ignore( | |||
c( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could now make this:
use_build_ignore(c(paste0(project_name(), "\.Rproj"), ".Rproj.user"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, changed
[skip ci]
Closes #133.
Implements
use_freshstarts()
use_blank_slate()
, to suppress save/reload of user's workspace upon R restarts.Handles
scope = "project"
but notscope = "user"
. Reasons given in #133 (comment).I needed to use work done in PRs #145 (Make scoped_temporary_package() easier to work with) and #146 (Less promiscuous Rbuildignoring) so those need approval first.