Skip to content

Commit

Permalink
write_delim_git() uses the force argument of add()
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Dec 27, 2017
1 parent e0f5a63 commit 3a44df0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion R/git_recent.r
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/git_sha.r
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/list_files_git.r
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion R/read_delim_git.r
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/remove_files_git.r
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 14 additions & 6 deletions R/write_delim_git.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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))
}
Expand Down
3 changes: 2 additions & 1 deletion man/write_delim_git.Rd

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

0 comments on commit 3a44df0

Please sign in to comment.