From 3a44df00384e6cc7c7af03345f6125f6be2cbd39 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Wed, 27 Dec 2017 11:17:13 +0100 Subject: [PATCH] write_delim_git() uses the force argument of add() --- R/git_recent.r | 2 +- R/git_sha.r | 2 +- R/list_files_git.r | 2 +- R/read_delim_git.r | 6 +++++- R/remove_files_git.r | 2 +- R/write_delim_git.r | 20 ++++++++++++++------ man/write_delim_git.Rd | 3 ++- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/R/git_recent.r b/R/git_recent.r index c546e8f94..ca6cb4ea9 100644 --- a/R/git_recent.r +++ b/R/git_recent.r @@ -1,5 +1,5 @@ #' Get the info from the latest commit of a file -#' @inheritParams write_delim_git +#' @inheritParams read_delim_git #' @name git_recent #' @rdname git_recent #' @exportMethod git_recent diff --git a/R/git_sha.r b/R/git_sha.r index c8a5b3f4b..0722d88e9 100644 --- a/R/git_sha.r +++ b/R/git_sha.r @@ -1,5 +1,5 @@ #' Get the SHA of the files at the HEAD -#' @inheritParams write_delim_git +#' @inheritParams read_delim_git #' @name git_sha #' @rdname git_sha #' @exportMethod git_sha diff --git a/R/list_files_git.r b/R/list_files_git.r index baae7e14f..b637efd93 100644 --- a/R/list_files_git.r +++ b/R/list_files_git.r @@ -1,5 +1,5 @@ #' List the files in a path of a git repository -#' @inheritParams write_delim_git +#' @inheritParams read_delim_git #' @inheritParams base::list.files #' @name list_files_git #' @rdname list_files_git diff --git a/R/read_delim_git.r b/R/read_delim_git.r index b2f54ec00..89b16f9f9 100644 --- a/R/read_delim_git.r +++ b/R/read_delim_git.r @@ -1,5 +1,9 @@ #' Read a tab delimited file from a git repository -#' @inheritParams write_delim_git +#' @param file the name of the file +#' @param connection The path of a git repository or a \code{git_connection} +#' object +#' @param ... parameters passed to \code{git_connection()} when +#' \code{connection} is a path #' @name read_delim_git #' @rdname read_delim_git #' @exportMethod read_delim_git diff --git a/R/remove_files_git.r b/R/remove_files_git.r index 084098414..47901309b 100644 --- a/R/remove_files_git.r +++ b/R/remove_files_git.r @@ -1,6 +1,6 @@ #' Remove all the files in a path of a git repository #' -#' @inheritParams write_delim_git +#' @inheritParams read_delim_git #' @inheritParams base::list.files #' @name remove_files_git #' @rdname remove_files_git diff --git a/R/write_delim_git.r b/R/write_delim_git.r index d0aade56d..5f9cf2db9 100644 --- a/R/write_delim_git.r +++ b/R/write_delim_git.r @@ -2,12 +2,11 @@ #' #' The existing file will be overwritten. #' @param x the data.frame -#' @param file the name of the file -#' @param connection The path of a git repository or a \code{git_connection} -#' object #' @param ... parameters passed to \code{git_connection()} when -#' \code{connection} is a path +#' \code{connection} is a path. When \code{force} is available it is passed +#' to \code{add()}. #' @return the SHA1 of the file +#' @inheritParams read_delim_git #' @name write_delim_git #' @rdname write_delim_git #' @exportMethod write_delim_git @@ -38,7 +37,7 @@ setMethod( #' @rdname write_delim_git #' @aliases write_delim_git,git_connection-methods #' @importFrom methods setMethod -#' @importFrom assertthat assert_that is.string +#' @importFrom assertthat assert_that is.string has_name setMethod( f = "write_delim_git", signature = signature(connection = "git_connection"), @@ -69,7 +68,16 @@ setMethod( } else { filename.local <- paste(connection@LocalPath, file, sep = "/") } - add(repo = connection@Repository, path = filename.local) + dots <- list(...) + if (has_name(dots, "force")) { + add( + repo = connection@Repository, + path = filename.local, + force = dots$force + ) + } else { + add(repo = connection@Repository, path = filename.local) + } return(hashfile(filename.full)) } diff --git a/man/write_delim_git.Rd b/man/write_delim_git.Rd index 21a21e33d..f2293dacb 100644 --- a/man/write_delim_git.Rd +++ b/man/write_delim_git.Rd @@ -24,7 +24,8 @@ write_delim_git(x, file, connection, ...) object} \item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} +\code{connection} is a path. When \code{force} is available it is passed +to \code{add()}.} } \value{ the SHA1 of the file