Skip to content

Commit

Permalink
Set overwrite param for example_repo and use withr
Browse files Browse the repository at this point in the history
  • Loading branch information
Noam Ross committed Nov 14, 2023
1 parent aea93ec commit ee28b4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/example_repo.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#' @param reporter the reporter to use when building targets with [targets::tar_make()]. Defaults to "silent".
#' @param s3 Whether the repository should use S3 storage for targets. Note that
#' the S3 endpoint and bucket must already be available.
#' @param overwrite Whether to overwrite the directory if it already exists.
#' @return The path to the created repository
#' @export
create_example_repo <- function(dir = fs::file_temp("relic_example_"), reporter = "silent", s3 = TRUE) {
check_installed(c("targets", "glue"))
if (dir_exists(dir)) dir_delete(dir)
create_example_repo <- function(dir = fs::file_temp("relic_example_"), reporter = "silent", s3 = TRUE, overwrite = TRUE) {
check_installed(c("targets", "glue", "withr"))
if (dir_exists(dir)) if (overwrite) dir_delete(dir) else abort("Directory already exists")
dir_create(dir)
od <- setwd(dir)
on.exit(setwd(od))
withr::local_dir(dir)
repo <- git2r::init()
# Configure the repository to use a generic user name and email address
git2r::config(repo, user.name = "relic-bot", user.email = "relic@relic.r.pacakge")
Expand Down
5 changes: 4 additions & 1 deletion man/create_example_repo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee28b4a

Please sign in to comment.