From ae41c2ce5e95a8dd3e195aaee5340e35d2b7659d Mon Sep 17 00:00:00 2001 From: Arni Magnusson Date: Sun, 26 Nov 2023 18:41:07 +1100 Subject: [PATCH] Add argument 'gitignore' to taf.skeleton() --- DESCRIPTION | 2 +- NEWS.md | 5 ++++- R/taf.skeleton.R | 11 ++++++++++- man/taf.skeleton.Rd | 4 +++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 344ab87..f181cb2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: TAF Version: 4.3.0 -Date: 2023-11-22 +Date: 2023-11-26 Title: Transparent Assessment Framework for Reproducible Research Authors@R: c(person("Arni", "Magnusson", role=c("aut","cre"), email="thisisarni@gmail.com"), person("Colin", "Millar", role="aut"), diff --git a/NEWS.md b/NEWS.md index 7bbe669..e59a7ec 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,13 @@ -# TAF 4.3.0 (2023-11-22) +# TAF 4.3.0 (2023-11-26) * Added function fdim() to show the dimensions of an FLR table. * Added function taf.libraries() to load all packages from TAF library. Code contributed by Iago Mosqueira. +* Added argument 'gitignore' to taf.skeleton() for writing a .gitignore file, + enabled by default. + * Improved draft.software() so it supports packages from r-universe. Code contributed by Iago Mosqueira. diff --git a/R/taf.skeleton.R b/R/taf.skeleton.R index 9ae7458..c5317fb 100644 --- a/R/taf.skeleton.R +++ b/R/taf.skeleton.R @@ -9,6 +9,7 @@ #' TAF package, i.e. \code{library(TAF)}. #' @param model.script model script filename, either \code{model.R} (default) or #' \code{method.R}. +#' @param gitignore whether to write a \file{.gitignore} file. #' #' @return Full path to analysis directory. #' @@ -25,7 +26,7 @@ #' @export taf.skeleton <- function(path = ".", force = FALSE, pkgs = "TAF", - model.script = "model.R") + model.script = "model.R", gitignore=TRUE) { # only overwrite files if force = TRUE safe.cat <- function(..., file, force) { @@ -62,5 +63,13 @@ taf.skeleton <- function(path = ".", force = FALSE, pkgs = "TAF", force = force) } + if (gitignore) { + ignore <- c("/boot/data", "/boot/software", "/data", + paste0("/", file_path_sans_ext(model.script)), "/output", + "/report", "*.Rproj", ".RData", ".Rhistory", ".Rproj.user", + ".Ruserdata") + write(ignore, ".gitignore") + } + invisible(getwd()) } diff --git a/man/taf.skeleton.Rd b/man/taf.skeleton.Rd index 69857d6..73df485 100644 --- a/man/taf.skeleton.Rd +++ b/man/taf.skeleton.Rd @@ -5,7 +5,7 @@ \title{TAF Skeleton} \usage{ taf.skeleton(path = ".", force = FALSE, pkgs = "TAF", - model.script = "model.R") + model.script = "model.R", gitignore = TRUE) } \arguments{ \item{path}{where to create initial directories and R scripts. The default is @@ -18,6 +18,8 @@ TAF package, i.e. \code{library(TAF)}.} \item{model.script}{model script filename, either \code{model.R} (default) or \code{method.R}.} + +\item{gitignore}{whether to write a \file{.gitignore} file.} } \value{ Full path to analysis directory.