Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Jan 11, 2024
1 parent 42feaf3 commit 80880eb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/time-machine.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' path <- exo_time_machine(parent_path = parent_path)
exo_time_machine <- function(parent_path) {

path <- file.path(parent_path, "exo-time-machine")
path <- file.path(parent_path, "time-machine")

withr::local_options(usethis.quiet = TRUE)

Expand All @@ -27,7 +27,7 @@ exo_time_machine <- function(parent_path) {
gert::git_init()

file.copy(
system.file("exo_committed_to_main-Rprofile.R", package = "saperlipopette"),
system.file("exo_time_machine-Rprofile.R", package = "saperlipopette"),
".Rprofile"
)

Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ template:
reference:
- title: Exercises inspired from Oh shit Git!
contents:
- exo_time_machine
- exo_committed_to_main
- exo_latest_message
- exo_one_small_change
Expand Down
3 changes: 2 additions & 1 deletion inst/exo_time_machine-Rprofile.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ cli::cli_alert_info("For more help use {.run tip()}")

tip <- function() {
cli::cli_li("{.code git reflog} to add a first chunk")
cli::cli_li('{.code reset HEAD@{1}}')
cli::cli_li('{.code git reset --hard HEAD@{1}}')
cli::cli_li('Note that --hard does not always make sense, but git reset is always the command')
cli::cli_li('Examine Git history.')

}
6 changes: 4 additions & 2 deletions tests/testthat/_snaps/create-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
+-- one-small-change
| +-- R
| \-- bla
\-- split-changes
+-- split-changes
| \-- R
| \-- script.R
\-- time-machine
\-- R
\-- script.R
[1] ""

7 changes: 7 additions & 0 deletions tests/testthat/_snaps/time-machine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# exo_time_machine() works

Code
gert::git_log(repo = path)[["commit"]]
Output
[1] "e227ecc55e421f70b6e30602e6a2eee02aad42e0"

7 changes: 7 additions & 0 deletions tests/testthat/test-time-machine.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test_that("exo_time_machine() works", {
rlang::local_options(cli.default_handler = function(msg) invisible(NULL))
parent_path <- withr::local_tempdir()
path <- exo_time_machine(parent_path = parent_path)
expect_equal(fs::path_file(path), "time-machine")
expect_snapshot(gert::git_log(repo = path)[["commit"]])
})

0 comments on commit 80880eb

Please sign in to comment.