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 use_blank_slate() #139

Merged
merged 24 commits into from Dec 22, 2017

Conversation

Projects
None yet
2 participants
@jennybc
Copy link
Member

jennybc commented Dec 20, 2017

Closes #133.

Implements use_freshstarts() use_blank_slate(), to suppress save/reload of user's workspace upon R restarts.

Handles scope = "project" but not scope = "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.

@jennybc jennybc requested a review from hadley Dec 20, 2017

R/rstudio.R Outdated
scope <- match.arg(scope)

if (scope == "user") {
message(

This comment has been minimized.

@jennybc

jennybc Dec 20, 2017

Author Member

I suspect this appalls you. Happy to implement in a more usethis-style.

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

I think this is fine, just use todo() instead of message().

This comment has been minimized.

@jennybc

jennybc Dec 20, 2017

Author Member

done 0dbc25a

R/rstudio.R Outdated
rproj_path(),
list(RestoreWorkspace = "No", SaveWorkspace = "No")
)
write_utf8(file.path(proj_get(), rproj_path()), rproj_options)

This comment has been minimized.

@jennybc

jennybc Dec 20, 2017

Author Member

I would prefer write_over() but I don't want to ask user's permission.

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

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"
)

This comment has been minimized.

@jennybc

jennybc Dec 20, 2017

Author Member

I confirmed restart is necessary for this to take effect.

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

Maybe just "Restart RStudio for a fresh state?"

@jennybc jennybc force-pushed the use-freshstarts branch from a6e3d9d to 3ccf9b0 Dec 20, 2017

R/rstudio.R Outdated
#' @inheritParams edit
#'
#' @export
use_freshstarts <- function(scope = c("user", "project")) {

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

Should this be use_fresh_starts()?

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

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

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

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.

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

Link to blog post for more info?

R/rstudio.R Outdated
scope <- match.arg(scope)

if (scope == "user") {
message(

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

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)

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

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"
)

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

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) {

This comment has been minimized.

@hadley

hadley Dec 20, 2017

Member

I'd like to see a bunch of unit tests for this, since it's fairly high risk.

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

Tests added. This is ready for another look.

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

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.

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Dec 20, 2017

Let's call it use_blank_slate()

@jennybc jennybc force-pushed the use-freshstarts branch from e1d59d8 to 4879ae8 Dec 22, 2017

jennybc added some commits Dec 22, 2017

Merge branch 'scoped-temporary-things' into use-freshstarts
* scoped-temporary-things:
  Prefer capture_output() to capture.output()
  Make scoped_temporary_package callable from the console
  Move scoped_temporary_package() to test dir
Merge branch 'careful-rbuildignore' into use-freshstarts
* 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

@jennybc jennybc changed the title Add use_freshstarts() Add use_blank_slate() Dec 22, 2017

@@ -1,4 +1,4 @@
^.*\.Rproj$

This comment has been minimized.

@hadley

hadley Dec 22, 2017

Member

Doesn't RStudio modify this when you re-open?

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

It does not for me. Does it for you?

This comment has been minimized.

@hadley

hadley Dec 22, 2017

Member

Hmmm, I could've sworn it did in the past, but not this time!

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

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?

This comment has been minimized.

@hadley

hadley Dec 22, 2017

Member

Agreed x2

expect_identical(rproj, paste0(basename(dir), ".Rproj"))
})

test_that("a non-RStudio project is recognized", {

This comment has been minimized.

@hadley

hadley Dec 22, 2017

Member

is not recognised?

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

ok changed

list()
)
writeLines(serialize_rproj(rproj), tmp)
expect_equivalent(

This comment has been minimized.

@hadley

hadley Dec 22, 2017

Member

Why not expect_equal() on the lines themselves?

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

ok changed

@jennybc

This comment has been minimized.

Copy link
Member Author

jennybc commented Dec 22, 2017

@hadley look again?

@hadley

hadley approved these changes Dec 22, 2017

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(

This comment has been minimized.

@hadley

hadley Dec 22, 2017

Member

I think you could now make this:

use_build_ignore(c(paste0(project_name(), "\.Rproj"), ".Rproj.user"))

This comment has been minimized.

@jennybc

jennybc Dec 22, 2017

Author Member

yes, changed

@hadley

hadley approved these changes Dec 22, 2017

Add NEWS bullet
[skip ci]

@jennybc jennybc merged commit 7f5dee2 into master Dec 22, 2017

0 of 2 checks passed

continuous-integration/appveyor/branch AppVeyor build failed
Details
continuous-integration/appveyor/pr AppVeyor build failed
Details

@jennybc jennybc deleted the use-freshstarts branch Dec 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.