From 4ac9fa50bbc870e0a40863ab619072894765fca7 Mon Sep 17 00:00:00 2001 From: hansvancalster Date: Fri, 2 Mar 2018 12:31:51 +0100 Subject: [PATCH 01/11] Allow authority TRUE or FALSE in get_nbn_key I would like to suggest an extra argument authority = FALSE (default). If authority == TRUE, the (Latin) names in name are supposed to include the authority (i.e. Epilobium roseum Schreb. instead of Epilobium roseum). Changes are made to the sql statement in order to reflect this. --- R/get_nbn_key.R | 84 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/R/get_nbn_key.R b/R/get_nbn_key.R index c06907b..8e41d05 100644 --- a/R/get_nbn_key.R +++ b/R/get_nbn_key.R @@ -2,11 +2,12 @@ #' @param name a vector of species names to check #' @param language The language to use. Defaults to "la" 'scientific name" #' @param channel An open RODBC channel to the NBN database +#' @param authority Do the species names include authority? #' @export #' @importFrom RODBC odbcDriverConnect sqlQuery odbcClose #' @importFrom dplyr %>% #' @importFrom assertthat assert_that is.string -get_nbn_key <- function(name, language = "la", channel){ +get_nbn_key <- function(name, language = "la", channel, authority = FALSE){ # nocov start name <- check_character(name, name = "name") assert_that(is.string(language)) @@ -48,7 +49,7 @@ get_nbn_key <- function(name, language = "la", channel){ paste0("'", available, "'", collapse = ", ") ) } - + if (authority == FALSE) { output <- sprintf(" SELECT t.ITEM_NAME AS InputName, @@ -126,4 +127,83 @@ get_nbn_key <- function(name, language = "la", channel){ warning("Duplicate matching keys") } return(output) #nocov end +} else { + output <- sprintf(" + SELECT + t.ITEM_NAME + ' ' + t.AUTHORITY AS InputName, + ns.RECOMMENDED_TAXON_VERSION_KEY as NBNKey, + tr.ITEM_NAME AS GenericName, + CASE + WHEN tli.TAXON_LIST_VERSION_KEY like 'INB%%' + THEN 1 ELSE 0 END AS PreferenceInput, + CASE + WHEN tlir.TAXON_LIST_VERSION_KEY like 'INB%%' + THEN 1 ELSE 0 END AS PreferenceOutput, + tv.COMMENT AS Comment, + tv.Attribute + FROM + ( + ( + ( + ( + dbo.TAXON AS t + INNER JOIN + dbo.TAXON_VERSION AS tv + ON + t.TAXON_KEY = tv.TAXON_KEY + ) + INNER JOIN + dbo.TAXON_LIST_ITEM AS tli + ON + tv.TAXON_VERSION_KEY = tli.TAXON_VERSION_KEY + ) + INNER JOIN + ( + ( + dbo.NAMESERVER AS ns + INNER JOIN + dbo.TAXON_VERSION AS tvr + ON + ns.RECOMMENDED_TAXON_VERSION_KEY = tvr.TAXON_VERSION_KEY + ) + INNER JOIN + dbo.TAXON AS tr + ON + tr.TAXON_KEY = tvr.TAXON_KEY + ) + ON + tv.TAXON_VERSION_KEY = ns.INPUT_TAXON_VERSION_KEY + ) + ) + INNER JOIN + dbo.TAXON_LIST_ITEM AS tlir + ON + tlir.TAXON_LIST_ITEM_KEY = ns.RECOMMENDED_TAXON_LIST_ITEM_KEY + WHERE + t.LANGUAGE = '%s' AND + t.ITEM_NAME + ' ' + t.AUTHORITY IN (%s)", + language, + paste0("'", name, "'", collapse = ", ") + ) %>% + sqlQuery( + channel = channel, + stringsAsFactors = FALSE, + as.is = TRUE + ) %>% + unique() + + if (anyDuplicated(output$InputName) > 1) { + output <- output %>% + group_by_(~InputName) %>% + filter_(~PreferenceInput == max(PreferenceInput)) %>% + filter_(~PreferenceOutput == max(PreferenceOutput)) %>% + ungroup() %>% + select_(~-PreferenceInput, ~-PreferenceOutput) %>% + as.data.frame() + } + if (anyDuplicated(output$InputName) > 1) { + warning("Duplicate matching keys") + } + return(output) #nocov end +} } From b543f71cd7ea7b7523034dbbf6f6e56cc1420a87 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Fri, 27 Jul 2018 16:07:47 +0200 Subject: [PATCH 02/11] use tidyverse on odbc_connect() --- NAMESPACE | 3 +++ R/odbc_connect.R | 33 ++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index fe1541f..e7a4db8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -60,12 +60,14 @@ importFrom(dplyr,"%>%") importFrom(dplyr,collect) importFrom(dplyr,count_) importFrom(dplyr,data_frame) +importFrom(dplyr,filter) importFrom(dplyr,filter_) importFrom(dplyr,funs) importFrom(dplyr,group_by_) importFrom(dplyr,inner_join) importFrom(dplyr,mutate_) importFrom(dplyr,mutate_each_) +importFrom(dplyr,select) importFrom(dplyr,select_) importFrom(dplyr,semi_join) importFrom(dplyr,slice_) @@ -93,6 +95,7 @@ importFrom(methods,setGeneric) importFrom(methods,setMethod) importFrom(methods,setValidity) importFrom(plyr,ddply) +importFrom(rlang,.data) importFrom(stats,aggregate) importFrom(stats,as.formula) importFrom(stats,na.fail) diff --git a/R/odbc_connect.R b/R/odbc_connect.R index 933a8f4..b34a6a9 100644 --- a/R/odbc_connect.R +++ b/R/odbc_connect.R @@ -6,8 +6,9 @@ #' @param password the password to be used in combination with the username. #' @param channel the ODBC channel to the database with the connection strings #' @importFrom assertthat assert_that is.string has_name -#' @importFrom dplyr tbl %>% inner_join filter_ select_ collect -#' @importFrom tidyr spread_ +#' @importFrom dplyr tbl %>% inner_join filter select collect +#' @importFrom rlang .data UQ +#' @importFrom tidyr spread #' @importFrom RODBC odbcDriverConnect #' @export odbc_connect <- function(data.source.name, username, password, channel){ @@ -37,28 +38,38 @@ odbc_connect <- function(data.source.name, username, password, channel){ ) connection <- tbl(channel, "datasource") %>% - filter_(~description == data.source.name) %>% - select_(datasource_id = ~id, datasource_type_id = ~datasource_type) %>% + filter(UQ(as.name("description")) == data.source.name) %>% + select( + datasource_id = .data$id, + datasource_type_id = .data$datasource_type + ) %>% inner_join( tbl(channel, "datasource_type") %>% - select_(datasource_type_id = ~id, datasource_type = ~description), + select( + datasource_type_id = .data$id, + datasource_type = .data$description + ), by = "datasource_type_id" ) %>% - select_(~-datasource_type_id) %>% + select(-.data$datasource_type_id) %>% inner_join( tbl(channel, "datasource_value") %>% - filter_(~is.na(destroy)) %>% - select_(~datasource, ~parameter, ~value), + filter(is.na(UQ(as.name("destroy")))) %>% + select(.data$datasource, .data$parameter, .data$value), by = c("datasource_id" = "datasource") ) %>% inner_join( tbl(channel, "datasource_parameter") %>% - select_(~id, ~description), + select(.data$id, .data$description), by = c("parameter" = "id") ) %>% - select_(~datasource_type, parameter = ~description, ~value) %>% + select( + .data$datasource_type, + parameter = .data$description, + .data$value + ) %>% collect() %>% - spread_(key_col = "parameter", value_col = "value") + spread(key = "parameter", value = "value") if (nrow(connection) == 0) { stop("No connection information found for '", data.source.name, "'.") From 5d859ef8326df7013fa982b852b026b7e2ecb8f7 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Wed, 29 Aug 2018 15:29:59 +0200 Subject: [PATCH 03/11] write_delim_git() and read_delim_git() are moved to the git2r package --- DESCRIPTION | 11 +-- NAMESPACE | 27 ++---- R/auto_commit.R | 99 ---------------------- R/check_git_repo.R | 23 ----- R/cut_date.R | 2 +- R/gitConnection_class.R | 22 +---- R/git_connect.R | 3 - R/git_connection.R | 11 +-- R/git_recent.R | 59 ------------- R/git_sha.R | 61 -------------- R/is_git_repo.R | 10 --- R/list_files_git.R | 52 ------------ R/read_delim_git.R | 47 ----------- R/remove_files_git.R | 67 --------------- R/write_delim_git.R | 74 ---------------- man/auto_commit.Rd | 27 ------ man/check_git_repo.Rd | 19 ----- man/gitConnection-class.Rd | 6 +- man/git_recent.Rd | 29 ------- man/git_sha.Rd | 29 ------- man/is_git_repo.Rd | 19 ----- man/list_files_git.Rd | 36 -------- man/read_delim_git.Rd | 29 ------- man/remove_files_git.Rd | 30 ------- man/write_delim_git.Rd | 34 -------- tests/testthat/test_auto_commit.R | 91 -------------------- tests/testthat/test_list_files_git.R | 85 ------------------- tests/testthat/test_read_delim_git.R | 63 -------------- tests/testthat/test_write_delim_git.R | 116 -------------------------- 29 files changed, 13 insertions(+), 1168 deletions(-) delete mode 100644 R/auto_commit.R delete mode 100644 R/check_git_repo.R delete mode 100644 R/git_recent.R delete mode 100644 R/git_sha.R delete mode 100644 R/is_git_repo.R delete mode 100644 R/list_files_git.R delete mode 100644 R/read_delim_git.R delete mode 100644 R/remove_files_git.R delete mode 100644 R/write_delim_git.R delete mode 100644 man/auto_commit.Rd delete mode 100644 man/check_git_repo.Rd delete mode 100644 man/git_recent.Rd delete mode 100644 man/git_sha.Rd delete mode 100644 man/is_git_repo.Rd delete mode 100644 man/list_files_git.Rd delete mode 100644 man/read_delim_git.Rd delete mode 100644 man/remove_files_git.Rd delete mode 100644 man/write_delim_git.Rd delete mode 100644 tests/testthat/test_auto_commit.R delete mode 100644 tests/testthat/test_list_files_git.R delete mode 100644 tests/testthat/test_read_delim_git.R delete mode 100644 tests/testthat/test_write_delim_git.R diff --git a/DESCRIPTION b/DESCRIPTION index 40e2699..ef405b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,14 +26,11 @@ LazyData: true Suggests: testthat Collate: - 'gitConnection_class.R' - 'auto_commit.R' 'check_character.R' 'check_dataframe_covariate.R' 'check_dataframe_variable.R' 'check_dbtable.R' 'check_dbtable_variable.R' - 'check_git_repo.R' 'check_id.R' 'check_path.R' 'check_single_character.R' @@ -46,20 +43,14 @@ Collate: 'get_nbn_key.R' 'get_nbn_key_multi.R' 'get_nbn_name.R' + 'gitConnection_class.R' 'git_connect.R' 'git_connection.R' - 'git_recent.R' - 'git_sha.R' 'is_chartor.R' - 'is_git_repo.R' - 'list_files_git.R' 'match_nbn_key.R' 'odbc_connect.R' 'odbc_get_id.R' 'odbc_get_multi_id.R' 'odbc_insert.R' - 'read_delim_git.R' 'read_object_environment.R' - 'remove_files_git.R' - 'write_delim_git.R' RoxygenNote: 6.0.1 diff --git a/NAMESPACE b/NAMESPACE index e7a4db8..80881fd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,7 +5,6 @@ export(check_dataframe_covariate) export(check_dataframe_variable) export(check_dbtable) export(check_dbtable_variable) -export(check_git_repo) export(check_id) export(check_path) export(check_single_character) @@ -22,7 +21,6 @@ export(get_nbn_name) export(git_connect) export(git_connection) export(is.chartor) -export(is_git_repo) export(match_nbn_key) export(odbc_connect) export(odbc_get_id) @@ -30,16 +28,6 @@ export(odbc_get_multi_id) export(odbc_insert) export(read_object_environment) exportClasses(gitConnection) -exportMethods(auto_commit) -exportMethods(git_recent) -exportMethods(git_sha) -exportMethods(list_files_git) -exportMethods(read_delim_git) -exportMethods(remove_files_git) -exportMethods(write_delim_git) -importClassesFrom(git2r,cred_ssh_key) -importClassesFrom(git2r,cred_user_pass) -importClassesFrom(git2r,git_repository) importFrom(DBI,dbExistsTable) importFrom(DBI,dbGetInfo) importFrom(DBI,dbGetQuery) @@ -75,14 +63,10 @@ importFrom(dplyr,src_postgres) importFrom(dplyr,summarise_) importFrom(dplyr,tbl) importFrom(dplyr,ungroup) -importFrom(git2r,add) -importFrom(git2r,commit) importFrom(git2r,config) importFrom(git2r,cred_ssh_key) importFrom(git2r,cred_user_pass) -importFrom(git2r,hashfile) -importFrom(git2r,head) -importFrom(git2r,push) +importFrom(git2r,in_repository) importFrom(git2r,repository) importFrom(lazyeval,interp) importFrom(lubridate,is.Date) @@ -91,18 +75,17 @@ importFrom(lubridate,year) importFrom(methods,new) importFrom(methods,setClass) importFrom(methods,setClassUnion) -importFrom(methods,setGeneric) -importFrom(methods,setMethod) +importFrom(methods,setOldClass) importFrom(methods,setValidity) importFrom(plyr,ddply) importFrom(rlang,.data) +importFrom(rlang,UQ) importFrom(stats,aggregate) importFrom(stats,as.formula) importFrom(stats,na.fail) +importFrom(tidyr,spread) importFrom(tidyr,spread_) importFrom(utils,file_test) -importFrom(utils,read.delim) -importFrom(utils,read.table) -importFrom(utils,sessionInfo) +importFrom(utils,head) importFrom(utils,tail) importFrom(utils,write.table) diff --git a/R/auto_commit.R b/R/auto_commit.R deleted file mode 100644 index feff652..0000000 --- a/R/auto_commit.R +++ /dev/null @@ -1,99 +0,0 @@ -#' Commit staged changes in a git repository with automated message -#' -#' The mesagge is based on the information returned by \code{\link[utils]{sessionInfo}} -#' @param package The name of the package from which we autocommit -#' @param connection The path of the repository. Default to \code{rawdata.path} -#' @param ... parameters passed to \code{git_connection} when relevant -#' @name auto_commit -#' @rdname auto_commit -#' @exportMethod auto_commit -#' @docType methods -#' @importFrom methods setGeneric -#' @include gitConnection_class.R -setGeneric( - name = "auto_commit", - def = function( - package, connection, ... - ){ - standard.generic("autocommit") - } -) - -#' @rdname auto_commit -#' @aliases auto_commit,gitConnection-methods -#' @importFrom methods setMethod -#' @importFrom git2r repository commit cred_user_pass head push -setMethod( - f = "auto_commit", - signature = signature(connection = "ANY"), - definition = function( - package, - connection, - ... - ){ - auto_commit( - package = package, - connection = git_connection(repo.path = connection, ...) - ) - } -) - - -#' @rdname auto_commit -#' @aliases auto_commit,git_connection-methods -#' @importFrom methods setMethod -#' @importFrom git2r commit cred_user_pass head push -#' @importFrom utils sessionInfo -setMethod( - f = "auto_commit", - signature = signature(connection = "gitConnection"), - definition = function(package, connection, ...){ - package <- check_single_character(package) - - #format commit message based on sessionInfo() - info <- sessionInfo() - format.other <- function(x){ - paste0(x$Package, " ", x$Version, " built ", x$Built, "\n") - } - message <- paste0( - "Automatic commit from ", package, "\n\n", - info$R.version$version.string, " revision ", info$R.version$"svn rev", - " on ", info$R.version$platform, "\n", - "\nBase packages: ", - paste0(info$basePkgs, collapse = ", "), "\n", - "\nOther package(s):\n", - paste(sapply(info$otherPkgs, format.other), collapse = ""), - "\nLoaded via a namespace:\n", - paste(sapply(info$loadedOnly, format.other), collapse = "") - ) - - committed <- tryCatch( - commit(repo = connection@Repository, message = message), - error = function(e){ - if (e$message == "Error in 'git2r_commit': Nothing added to commit\n") { - FALSE - } else { - e - } - } - ) - if ("error" %in% class(committed)) { - stop(committed) - } - if (class(committed) != "git_commit") { - return(invisible(TRUE)) - } - if (is.null(connection@Credentials)) { - warning("changes committed but not pushed") - } else { - message("Pushing changes to remote repository") - tryCatch( - push(head(connection@Repository), credentials = connection@Credentials), - error = function(e){ - warning(e) - } - ) - } - return(invisible(TRUE)) - } -) diff --git a/R/check_git_repo.R b/R/check_git_repo.R deleted file mode 100644 index 65f021f..0000000 --- a/R/check_git_repo.R +++ /dev/null @@ -1,23 +0,0 @@ -#' Check if the path a git repository -#' Checks is a '.git' subdirectory exists in 'path' -#' @param path the path to check -#' @param error What to do in case \code{path} is not a git repository. Throw an -#' error when \code{error = TRUE}. Return \code{FALSE} when \code{error = FALSE} -#' @export -check_git_repo <- function(path, error = TRUE){ - error <- check_single_logical(x = error, name = "error") - - full.path <- check_path(path, type = "directory") - git.path <- check_path( - paste(full.path, ".git", sep = "/"), - type = "directory", - error = FALSE - ) - if (is.logical(git.path)) { - if (error) { - stop("'", full.path, "' is not a git repository") - } - return(FALSE) - } - return(full.path) -} diff --git a/R/cut_date.R b/R/cut_date.R index 7af72e2..72fb644 100644 --- a/R/cut_date.R +++ b/R/cut_date.R @@ -7,7 +7,7 @@ #' @export #' @importFrom plyr ddply #' @importFrom lubridate year is.Date is.POSIXt -#' @importFrom utils tail +#' @importFrom utils tail head #' @examples #' x <- as.POSIXct( #' c("2015-01-01", "2014-01-02", "2013-01-03", "2012-01-31", "2011-02-01", "2012-12-31") diff --git a/R/gitConnection_class.R b/R/gitConnection_class.R index fb25f98..b622866 100644 --- a/R/gitConnection_class.R +++ b/R/gitConnection_class.R @@ -1,5 +1,5 @@ -#' @importClassesFrom git2r cred_user_pass cred_ssh_key -#' @importFrom methods setClassUnion +#' @importFrom methods setOldClass setClassUnion +setOldClass(c("cred_user_pass", "cred_ssh_key", "git_repository")) setClassUnion("gitCredentials", c("NULL", "cred_user_pass", "cred_ssh_key")) #' The gitConnection class @@ -7,7 +7,6 @@ setClassUnion("gitCredentials", c("NULL", "cred_user_pass", "cred_ssh_key")) #' @section Slots: #' \describe{ #' \item{\code{Repository}}{a git repository} -#' \item{\code{LocalPath}}{a subdirectory wihtin the repository} #' \item{\code{Credentials}}{the credentials for the repository} #' \item{\code{CommitUser}}{the name of the user how will commit} #' \item{\code{CommitEmail}}{the email of the user how will commit} @@ -17,13 +16,11 @@ setClassUnion("gitCredentials", c("NULL", "cred_user_pass", "cred_ssh_key")) #' @exportClass gitConnection #' @aliases gitConnection-class #' @importFrom methods setClass -#' @importClassesFrom git2r git_repository #' @docType class setClass( Class = "gitConnection", representation = representation( Repository = "git_repository", - LocalPath = "character", Credentials = "gitCredentials", CommitUser = "character", CommitEmail = "character" @@ -38,20 +35,7 @@ setValidity( function(object){ assert_that(is.string(object@CommitUser)) assert_that(is.string(object@CommitEmail)) - root <- paste(object@Repository@path, ".", sep = "/") - root <- check_path(path = root, type = "directory") - full.path <- paste(root, object@LocalPath, sep = "/") - full.path <- check_path(full.path, type = "directory") - if (length(grep(root, full.path)) == 0) { - return( - paste0( - "Wrong local path. '", full.path, - "' is not a subdirectory of '", root, "'" - ) - ) - } - repo <- repository(root) - repo.config <- config(repo) + repo.config <- config(object@Repository) assert_that(has_name(repo.config$local, "user.name")) assert_that(has_name(repo.config$local, "user.email")) assert_that(repo.config$local$user.name == object@CommitUser) diff --git a/R/git_connect.R b/R/git_connect.R index 24843ff..cca278d 100644 --- a/R/git_connect.R +++ b/R/git_connect.R @@ -78,7 +78,6 @@ git_connect <- function( ) } assert_that(has_name(connection, "connect_method")) - assert_that(has_name(connection, "path")) assert_that(has_name(connection, "repo")) if ( @@ -102,7 +101,6 @@ git_connect <- function( return( git_connection( repo.path = connection$repo, - local.path = connection$path, key = username, password = password, commit.user = commit.user, @@ -113,7 +111,6 @@ git_connect <- function( return( git_connection( repo.path = connection$repo, - local.path = connection$path, username = username, password = password, commit.user = commit.user, diff --git a/R/git_connection.R b/R/git_connection.R index 3dbd849..66aae70 100644 --- a/R/git_connection.R +++ b/R/git_connection.R @@ -2,7 +2,6 @@ #' @name git_connection #' @rdname gitConnection-class #' @param repo.path The path of the root of the repository -#' @param local.path A path within the repository #' @param key Optional: the path to a private ssh key. The public key is assumed #' to have the same path with a '.pub' extension. Using in case of ssh #' authentication. @@ -15,21 +14,19 @@ #' @export #' @importFrom methods new #' @importFrom assertthat assert_that is.string -#' @importFrom git2r repository config cred_ssh_key cred_user_pass +#' @importFrom git2r in_repository repository config cred_ssh_key cred_user_pass #' @include gitConnection_class.R git_connection <- function( repo.path, - local.path = ".", key, username, password, commit.user, commit.email ){ - assert_that(is.string(local.path)) assert_that(is.string(commit.user)) assert_that(is.string(commit.email)) - repo.path <- check_git_repo(path = repo.path) + repo.path <- in_repository(path = repo.path) repo <- repository(repo.path) config(repo, user.name = commit.user, user.email = commit.email) @@ -38,7 +35,6 @@ git_connection <- function( new( "gitConnection", Repository = repo, - LocalPath = local.path, Credentials = NULL, CommitUser = commit.user, CommitEmail = commit.email @@ -54,7 +50,6 @@ git_connection <- function( new( "gitConnection", Repository = repo, - LocalPath = local.path, Credentials = cred_ssh_key( publickey = paste0(key, ".pub"), privatekey = key @@ -70,7 +65,6 @@ git_connection <- function( new( "gitConnection", Repository = repo, - LocalPath = local.path, Credentials = cred_ssh_key( publickey = paste0(key, ".pub"), privatekey = key, @@ -90,7 +84,6 @@ git_connection <- function( new( "gitConnection", Repository = repo, - LocalPath = local.path, Credentials = cred_user_pass( username = username, password = password diff --git a/R/git_recent.R b/R/git_recent.R deleted file mode 100644 index edde863..0000000 --- a/R/git_recent.R +++ /dev/null @@ -1,59 +0,0 @@ -#' Get the info from the latest commit of a file -#' @inheritParams write_delim_git -#' @name git_recent -#' @rdname git_recent -#' @exportMethod git_recent -#' @docType methods -#' @importFrom methods setGeneric -#' @include git_connection.R -setGeneric( - name = "git_recent", - def = function(file, connection, ...){ - standard.generic("git_recent") - } -) - -#' @rdname git_recent -#' @aliases git_recent,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "git_recent", - signature = signature(connection = "ANY"), - definition = function(file, connection, ...){ - this.connection <- git_connection(repo.path = connection, ...) - git_recent(file = file, connection = this.connection) - } -) - -#' @rdname git_recent -#' @aliases git_recent,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "git_recent", - signature = signature(connection = "gitConnection"), - definition = function(file, connection, ...){ - file <- check_single_character(x = file, name = "file") - - old.wd <- getwd() - setwd(connection@Repository@path) - commit.info <- system( - paste0( - "git log -n 1 --date=iso ", - connection@LocalPath, "/", file - ), - intern = TRUE - ) - setwd(old.wd) - date <- commit.info[grep("^Date:", commit.info)] - date <- as.POSIXct(date, format = "Date: %F %T %z") - commit <- commit.info[grep("^commit", commit.info)] - commit <- gsub("^commit ", "", commit) - author <- commit.info[grep("^Author:", commit.info)] - author <- gsub("^Author: ", "", author) - return(list( - Commit = commit, - Author = author, - Date = date - )) - } -) diff --git a/R/git_sha.R b/R/git_sha.R deleted file mode 100644 index 4180bff..0000000 --- a/R/git_sha.R +++ /dev/null @@ -1,61 +0,0 @@ -#' Get the SHA of the files at the HEAD -#' @inheritParams write_delim_git -#' @name git_sha -#' @rdname git_sha -#' @exportMethod git_sha -#' @docType methods -#' @importFrom methods setGeneric -#' @include git_connection.R -setGeneric( - name = "git_sha", - def = function(file, connection, ...){ - standard.generic("git_sha") - } -) - -#' @rdname git_sha -#' @aliases git_sha,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "git_sha", - signature = signature(connection = "ANY"), - definition = function(file, connection, ...){ - this.connection <- git_connection(repo.path = connection, ...) - git_sha(file = file, connection = this.connection) - } -) - -#' @rdname git_sha -#' @aliases git_sha,git_connection-methods -#' @importFrom methods setMethod -#' @importFrom utils read.table -setMethod( - f = "git_sha", - signature = signature(connection = "gitConnection"), - definition = function(file, connection, ...){ - file <- check_character(x = file, name = "file") - - old.wd <- getwd() - setwd(connection@Repository@path) - blobs <- system( - paste( - "git ls-tree -r HEAD", - connection@LocalPath - ), - intern = TRUE - ) - setwd(old.wd) - blobs <- read.table( - textConnection(paste(blobs, collapse = "\n")), - header = FALSE, - sep = "\t", - col.names = c("SHA", "Path") - ) - blobs$File <- basename(blobs$Path) - blobs <- blobs[blobs$File %in% file, ] - blobs$Path <- dirname(blobs$Path) - blobs$SHA <- gsub("^.*blob ", "", blobs$SHA) - - return(blobs) - } -) diff --git a/R/is_git_repo.R b/R/is_git_repo.R deleted file mode 100644 index 19e5549..0000000 --- a/R/is_git_repo.R +++ /dev/null @@ -1,10 +0,0 @@ -#' It the path a git repository -#' Checks is a '.git' subdirectory exists in 'path' -#' @param path the path to check -#' @export -#' @return A logical vector wit the same length as path -#' @importFrom utils file_test -is_git_repo <- function(path){ - path <- check_single_character(x = path, name = "path") - file_test("-d", paste(path, ".git", sep = "/")) -} diff --git a/R/list_files_git.R b/R/list_files_git.R deleted file mode 100644 index f9c1875..0000000 --- a/R/list_files_git.R +++ /dev/null @@ -1,52 +0,0 @@ -#' List the files in a path of a git repository -#' @inheritParams write_delim_git -#' @inheritParams base::list.files -#' @name list_files_git -#' @rdname list_files_git -#' @exportMethod list_files_git -#' @docType methods -#' @importFrom methods setGeneric -#' @include git_connection.R -setGeneric( - name = "list_files_git", - def = function(connection, pattern = NULL, full.names = FALSE, ...){ - standard.generic("list_files_git") - } -) - -#' @rdname list_files_git -#' @aliases list_files_git,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "list_files_git", - signature = signature(connection = "ANY"), - definition = function(connection, pattern = NULL, full.names = FALSE, ...){ - this.connection <- git_connection(repo.path = connection, ...) - list_files_git( - connection = this.connection, - pattern = pattern, - full.names = full.names - ) - } -) - -#' @rdname list_files_git -#' @aliases list_files_git,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "list_files_git", - signature = signature(connection = "gitConnection"), - definition = function(connection, pattern = NULL, full.names = FALSE, ...){ - if (!is.null(pattern)) { - pattern <- check_single_character(pattern, name = "pattern") - } - full.names <- check_single_logical(full.names, name = "full.names") - - full.path <- paste( - connection@Repository@path, - connection@LocalPath, - sep = "/" - ) - list.files(path = full.path, pattern = pattern, full.names = full.names) - } -) diff --git a/R/read_delim_git.R b/R/read_delim_git.R deleted file mode 100644 index c9760ce..0000000 --- a/R/read_delim_git.R +++ /dev/null @@ -1,47 +0,0 @@ -#' Read a tab delimited file from a git repository -#' @inheritParams write_delim_git -#' @name read_delim_git -#' @rdname read_delim_git -#' @exportMethod read_delim_git -#' @docType methods -#' @importFrom methods setGeneric -#' @include git_connection.R -setGeneric( - name = "read_delim_git", - def = function(file, connection, ...){ - standard.generic("read_delim_git") - } -) - -#' @rdname read_delim_git -#' @aliases read_delim_git,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "read_delim_git", - signature = signature(connection = "ANY"), - definition = function(file, connection, ...){ - this.connection <- git_connection(repo.path = connection, ...) - read_delim_git(file = file, connection = this.connection) - } -) - -#' @rdname read_delim_git -#' @aliases read_delim_git,git_connection-methods -#' @importFrom methods setMethod -#' @importFrom utils read.delim -setMethod( - f = "read_delim_git", - signature = signature(connection = "gitConnection"), - definition = function(file, connection, ...){ - file <- check_single_character(x = file, name = "file") - - filename <- paste( - connection@Repository@path, - connection@LocalPath, - file, - sep = "/" - ) - filename <- check_path(path = filename, type = "file", error = TRUE) - return(read.delim(filename, stringsAsFactors = FALSE)) - } -) diff --git a/R/remove_files_git.R b/R/remove_files_git.R deleted file mode 100644 index 726d097..0000000 --- a/R/remove_files_git.R +++ /dev/null @@ -1,67 +0,0 @@ -#' Remove all the files in a path of a git repository -#' -#' @inheritParams write_delim_git -#' @inheritParams base::list.files -#' @name remove_files_git -#' @rdname remove_files_git -#' @exportMethod remove_files_git -#' @docType methods -#' @importFrom methods setGeneric -#' @include git_connection.R -setGeneric( - name = "remove_files_git", - def = function(connection, pattern = NULL, ...){ - standard.generic("remove_files_git") - } -) - -#' @rdname remove_files_git -#' @aliases remove_files_git,git_connection-methods -#' @importFrom methods setMethod -setMethod( - f = "remove_files_git", - signature = signature(connection = "ANY"), - definition = function(connection, pattern = NULL, ...){ - this.connection <- git_connection( - repo.path = connection, - local.path = list(...)$path, - ... - ) - remove_files_git(connection = this.connection, pattern = pattern) - } -) - -#' @rdname remove_files_git -#' @aliases remove_files_git,git_connection-methods -#' @importFrom methods setMethod -#' @importFrom git2r add -setMethod( - f = "remove_files_git", - signature = signature(connection = "gitConnection"), - definition = function(connection, pattern = NULL, ...){ - to.remove <- list_files_git( - connection = connection, - pattern = pattern, - full.names = TRUE - ) - - success <- file.remove(to.remove) - - if (length(success) > 0 && !all(success)) { - stop( - "Error cleaning existing files in the git repository. Repository: '", - connection@Repository@path, "', Path: '", connection@LocalPath, - "', pattern: '", pattern, "'" - ) - } - if (any(success)) { - to.stage <- gsub( - paste0("^", connection@Repository@path, "/"), - "", - to.remove[success] - ) - add(repo = connection@Repository, path = to.stage) - } - return(invisible(TRUE)) - } -) diff --git a/R/write_delim_git.R b/R/write_delim_git.R deleted file mode 100644 index ceadea3..0000000 --- a/R/write_delim_git.R +++ /dev/null @@ -1,74 +0,0 @@ -#' Write a dataframe as a tab delimited file to a git repository and stage it -#' -#' 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{gitConnection} -#' object -#' @param ... parameters passed to \code{git_connection()} when -#' \code{connection} is a path -#' @return the SHA1 of the file -#' @name write_delim_git -#' @rdname write_delim_git -#' @exportMethod write_delim_git -#' @docType methods -#' @importFrom methods setGeneric -#' @importFrom utils write.table -#' @include git_connection.R -setGeneric( - name = "write_delim_git", - def = function(x, file, connection, ...){ - standard.generic("write_delim_git") - } -) - -#' @rdname write_delim_git -#' @aliases write_delim_git,git_connection-methods -#' @importFrom git2r repository add hashfile -#' @importFrom methods setMethod -setMethod( - f = "write_delim_git", - signature = signature(connection = "ANY"), - definition = function(x, file, connection, ...){ - this.connection <- git_connection(repo.path = connection, ...) - write_delim_git(x = x, file = file, connection = this.connection) - } -) - -#' @rdname write_delim_git -#' @aliases write_delim_git,git_connection-methods -#' @importFrom git2r add hashfile -#' @importFrom methods setMethod -setMethod( - f = "write_delim_git", - signature = signature(connection = "gitConnection"), - definition = function(x, file, connection, ...){ - if (!inherits(x, "data.frame")) { - stop("x is not a data.frame") - } - file <- check_single_character(x = file, name = "file") - - # write the file - filename.full <- paste( - connection@Repository@path, - connection@LocalPath, - file, - sep = "/" - ) - filename.full <- normalizePath( - path = filename.full, - winslash = "/", - mustWork = FALSE - ) - write.table( - x = x, file = filename.full, append = FALSE, - quote = FALSE, sep = "\t", row.names = FALSE, fileEncoding = "UTF-8" - ) - - # stage the file - filename.local <- paste(connection@LocalPath, file, sep = "/") - add(connection@Repository, filename.local) - - return(hashfile(filename.full)) - } -) diff --git a/man/auto_commit.Rd b/man/auto_commit.Rd deleted file mode 100644 index 974b370..0000000 --- a/man/auto_commit.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auto_commit.R -\docType{methods} -\name{auto_commit} -\alias{auto_commit} -\alias{auto_commit,ANY,ANY-method} -\alias{auto_commit,gitConnection-methods} -\alias{auto_commit,ANY,gitConnection-method} -\alias{auto_commit,git_connection-methods} -\title{Commit staged changes in a git repository with automated message} -\usage{ -auto_commit(package, connection, ...) - -\S4method{auto_commit}{ANY,ANY}(package, connection, ...) - -\S4method{auto_commit}{ANY,gitConnection}(package, connection, ...) -} -\arguments{ -\item{package}{The name of the package from which we autocommit} - -\item{connection}{The path of the repository. Default to \code{rawdata.path}} - -\item{...}{parameters passed to \code{git_connection} when relevant} -} -\description{ -The mesagge is based on the information returned by \code{\link[utils]{sessionInfo}} -} diff --git a/man/check_git_repo.Rd b/man/check_git_repo.Rd deleted file mode 100644 index 5b7a157..0000000 --- a/man/check_git_repo.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_git_repo.R -\name{check_git_repo} -\alias{check_git_repo} -\title{Check if the path a git repository -Checks is a '.git' subdirectory exists in 'path'} -\usage{ -check_git_repo(path, error = TRUE) -} -\arguments{ -\item{path}{the path to check} - -\item{error}{What to do in case \code{path} is not a git repository. Throw an -error when \code{error = TRUE}. Return \code{FALSE} when \code{error = FALSE}} -} -\description{ -Check if the path a git repository -Checks is a '.git' subdirectory exists in 'path' -} diff --git a/man/gitConnection-class.Rd b/man/gitConnection-class.Rd index 0d11024..580dd7c 100644 --- a/man/gitConnection-class.Rd +++ b/man/gitConnection-class.Rd @@ -6,14 +6,11 @@ \alias{git_connection} \title{The gitConnection class} \usage{ -git_connection(repo.path, local.path = ".", key, username, password, - commit.user, commit.email) +git_connection(repo.path, key, username, password, commit.user, commit.email) } \arguments{ \item{repo.path}{The path of the root of the repository} -\item{local.path}{A path within the repository} - \item{key}{Optional: the path to a private ssh key. The public key is assumed to have the same path with a '.pub' extension. Using in case of ssh authentication.} @@ -37,7 +34,6 @@ Open a git connection \describe{ \item{\code{Repository}}{a git repository} - \item{\code{LocalPath}}{a subdirectory wihtin the repository} \item{\code{Credentials}}{the credentials for the repository} \item{\code{CommitUser}}{the name of the user how will commit} \item{\code{CommitEmail}}{the email of the user how will commit} diff --git a/man/git_recent.Rd b/man/git_recent.Rd deleted file mode 100644 index 6cbddba..0000000 --- a/man/git_recent.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/git_recent.R -\docType{methods} -\name{git_recent} -\alias{git_recent} -\alias{git_recent,ANY,ANY-method} -\alias{git_recent,git_connection-methods} -\alias{git_recent,ANY,gitConnection-method} -\alias{git_recent,git_connection-methods} -\title{Get the info from the latest commit of a file} -\usage{ -git_recent(file, connection, ...) - -\S4method{git_recent}{ANY,ANY}(file, connection, ...) - -\S4method{git_recent}{ANY,gitConnection}(file, connection, ...) -} -\arguments{ -\item{file}{the name of the file} - -\item{connection}{The path of a git repository or a \code{gitConnection} -object} - -\item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} -} -\description{ -Get the info from the latest commit of a file -} diff --git a/man/git_sha.Rd b/man/git_sha.Rd deleted file mode 100644 index f01aef8..0000000 --- a/man/git_sha.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/git_sha.R -\docType{methods} -\name{git_sha} -\alias{git_sha} -\alias{git_sha,ANY,ANY-method} -\alias{git_sha,git_connection-methods} -\alias{git_sha,ANY,gitConnection-method} -\alias{git_sha,git_connection-methods} -\title{Get the SHA of the files at the HEAD} -\usage{ -git_sha(file, connection, ...) - -\S4method{git_sha}{ANY,ANY}(file, connection, ...) - -\S4method{git_sha}{ANY,gitConnection}(file, connection, ...) -} -\arguments{ -\item{file}{the name of the file} - -\item{connection}{The path of a git repository or a \code{gitConnection} -object} - -\item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} -} -\description{ -Get the SHA of the files at the HEAD -} diff --git a/man/is_git_repo.Rd b/man/is_git_repo.Rd deleted file mode 100644 index 3b11971..0000000 --- a/man/is_git_repo.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/is_git_repo.R -\name{is_git_repo} -\alias{is_git_repo} -\title{It the path a git repository -Checks is a '.git' subdirectory exists in 'path'} -\usage{ -is_git_repo(path) -} -\arguments{ -\item{path}{the path to check} -} -\value{ -A logical vector wit the same length as path -} -\description{ -It the path a git repository -Checks is a '.git' subdirectory exists in 'path' -} diff --git a/man/list_files_git.Rd b/man/list_files_git.Rd deleted file mode 100644 index 33e9867..0000000 --- a/man/list_files_git.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/list_files_git.R -\docType{methods} -\name{list_files_git} -\alias{list_files_git} -\alias{list_files_git,ANY-method} -\alias{list_files_git,git_connection-methods} -\alias{list_files_git,gitConnection-method} -\alias{list_files_git,git_connection-methods} -\title{List the files in a path of a git repository} -\usage{ -list_files_git(connection, pattern = NULL, full.names = FALSE, ...) - -\S4method{list_files_git}{ANY}(connection, pattern = NULL, - full.names = FALSE, ...) - -\S4method{list_files_git}{gitConnection}(connection, pattern = NULL, - full.names = FALSE, ...) -} -\arguments{ -\item{connection}{The path of a git repository or a \code{gitConnection} -object} - -\item{pattern}{an optional \link{regular expression}. Only file names - which match the regular expression will be returned.} - -\item{full.names}{a logical value. If \code{TRUE}, the directory - path is prepended to the file names to give a relative file path. - If \code{FALSE}, the file names (rather than paths) are returned.} - -\item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} -} -\description{ -List the files in a path of a git repository -} diff --git a/man/read_delim_git.Rd b/man/read_delim_git.Rd deleted file mode 100644 index 2d6bba5..0000000 --- a/man/read_delim_git.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_delim_git.R -\docType{methods} -\name{read_delim_git} -\alias{read_delim_git} -\alias{read_delim_git,ANY,ANY-method} -\alias{read_delim_git,git_connection-methods} -\alias{read_delim_git,ANY,gitConnection-method} -\alias{read_delim_git,git_connection-methods} -\title{Read a tab delimited file from a git repository} -\usage{ -read_delim_git(file, connection, ...) - -\S4method{read_delim_git}{ANY,ANY}(file, connection, ...) - -\S4method{read_delim_git}{ANY,gitConnection}(file, connection, ...) -} -\arguments{ -\item{file}{the name of the file} - -\item{connection}{The path of a git repository or a \code{gitConnection} -object} - -\item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} -} -\description{ -Read a tab delimited file from a git repository -} diff --git a/man/remove_files_git.Rd b/man/remove_files_git.Rd deleted file mode 100644 index 22f818b..0000000 --- a/man/remove_files_git.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remove_files_git.R -\docType{methods} -\name{remove_files_git} -\alias{remove_files_git} -\alias{remove_files_git,ANY-method} -\alias{remove_files_git,git_connection-methods} -\alias{remove_files_git,gitConnection-method} -\alias{remove_files_git,git_connection-methods} -\title{Remove all the files in a path of a git repository} -\usage{ -remove_files_git(connection, pattern = NULL, ...) - -\S4method{remove_files_git}{ANY}(connection, pattern = NULL, ...) - -\S4method{remove_files_git}{gitConnection}(connection, pattern = NULL, ...) -} -\arguments{ -\item{connection}{The path of a git repository or a \code{gitConnection} -object} - -\item{pattern}{an optional \link{regular expression}. Only file names - which match the regular expression will be returned.} - -\item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} -} -\description{ -Remove all the files in a path of a git repository -} diff --git a/man/write_delim_git.Rd b/man/write_delim_git.Rd deleted file mode 100644 index 697b92b..0000000 --- a/man/write_delim_git.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/write_delim_git.R -\docType{methods} -\name{write_delim_git} -\alias{write_delim_git} -\alias{write_delim_git,ANY,ANY,ANY-method} -\alias{write_delim_git,git_connection-methods} -\alias{write_delim_git,ANY,ANY,gitConnection-method} -\alias{write_delim_git,git_connection-methods} -\title{Write a dataframe as a tab delimited file to a git repository and stage it} -\usage{ -write_delim_git(x, file, connection, ...) - -\S4method{write_delim_git}{ANY,ANY,ANY}(x, file, connection, ...) - -\S4method{write_delim_git}{ANY,ANY,gitConnection}(x, file, connection, ...) -} -\arguments{ -\item{x}{the data.frame} - -\item{file}{the name of the file} - -\item{connection}{The path of a git repository or a \code{gitConnection} -object} - -\item{...}{parameters passed to \code{git_connection()} when -\code{connection} is a path} -} -\value{ -the SHA1 of the file -} -\description{ -The existing file will be overwritten. -} diff --git a/tests/testthat/test_auto_commit.R b/tests/testthat/test_auto_commit.R deleted file mode 100644 index 5933982..0000000 --- a/tests/testthat/test_auto_commit.R +++ /dev/null @@ -1,91 +0,0 @@ -context("autocommit changes") -describe("auto_commit()", { - package <- "test" - user <- "test" - pwd <- "test" - commit.user <- "me" - commit.email <- "me@me.com" - - # function to create and stage a file - dummy_add <- function(connection){ - content <- paste(sample(letters, 8, replace = TRUE), collapse = "") - writeLines(content, paste(connection, content, sep = "/")) - git2r::add(git2r::repository(connection), content) - } - - # create test repository - origin.path <- tempfile(pattern = "git2r-") - connection <- tempfile(pattern = "git2rclone-") - dir.create(origin.path) - dir.create(connection) - repo_bare <- git2r::init(origin.path, bare = TRUE) - repo <- git2r::clone(origin.path, connection) - git2r::config(repo, user.name = commit.user, user.email = commit.email) - dummy_add(connection) - git2r::commit(repo, "inital") - git2r::push(repo, "origin", "refs/heads/master") - - it("gives a warning when no username and password are provided and returns - TRUE", { - dummy_add(connection = connection) - expect_that( - auto_commit( - package = package, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - gives_warning("changes committed but not pushed") - ) - dummy_add(connection = connection) - expect_that( - auto_commit( - package = package, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_true() - ) - }) - it("returns TRUE when nothing to commit", { - expect_that( - auto_commit( - package = package, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_true() - ) - }) - it("returns TRUE when changes are pushed", { - dummy_add(connection = connection) - expect_that( - auto_commit( - package = package, - connection = connection, - username = user, - password = pwd, - commit.user = commit.user, - commit.email = commit.email - ), - is_true() - ) - }) - it("writes a correct message title", { - dummy_add(connection = connection) - auto_commit( - package = package, - connection = connection, - username = user, - password = pwd, - commit.user = commit.user, - commit.email = commit.email - ) - expect_that( - git2r::reflog(repo)[[1]]@message, - is_identical_to(paste("commit: Automatic commit from", package)) - ) - }) -}) diff --git a/tests/testthat/test_list_files_git.R b/tests/testthat/test_list_files_git.R deleted file mode 100644 index 45c3d0b..0000000 --- a/tests/testthat/test_list_files_git.R +++ /dev/null @@ -1,85 +0,0 @@ -context("list files for a git repository") -describe("list_files_git()", { - files <- sort(c("test.txt", "0123456.txt", "test", "0123456")) - local.path <- "test" - connection <- tempfile(pattern = "git2r-") - connection <- normalizePath(connection, winslash = "/", mustWork = FALSE) - commit.user <- "me" - commit.email <- "me@me.com" - - - it("stops is connection is not a git repository", { - expect_that( - list_files_git( - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - throws_error(paste0("'", connection, "' is not a directory")) - ) - }) - - dir.create(connection) - repo <- git2r::init(connection) - connection <- normalizePath(connection, winslash = "/", mustWork = FALSE) - full.path <- paste(connection, local.path, sep = "/") - full.path <- normalizePath(full.path, winslash = "/", mustWork = FALSE) - it("stops is the local.path doesn't exist", { - expect_that( - list_files_git( - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - throws_error( - paste0("'", connection, "/", local.path, "' is not a directory") - ) - ) - }) - - dir.create(paste(connection, local.path, sep = "/")) - file.create(paste(full.path, files, sep = "/")) - it("list the files according to the pattern", { - expect_that( - list_files_git( - local.path = local.path, - pattern = "^[0123456789].*\\.txt$", - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_identical_to(files[grep("^[0123456789].*\\.txt$", files)]) - ) - expect_that( - list_files_git( - local.path = local.path, - pattern = "\\.txt$", - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_identical_to(files[grep("\\.txt$", files)]) - ) - expect_that( - list_files_git( - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_identical_to(files) - ) - expect_that( - list_files_git( - local.path = local.path, - pattern = ".exe", - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_identical_to(character(0)) - ) - }) -}) diff --git a/tests/testthat/test_read_delim_git.R b/tests/testthat/test_read_delim_git.R deleted file mode 100644 index c7cdcb8..0000000 --- a/tests/testthat/test_read_delim_git.R +++ /dev/null @@ -1,63 +0,0 @@ -context("read data.frame from git") -describe("read_delim_git()", { - file <- "test.txt" - local.path <- "test" - connection <- normalizePath( - tempfile(pattern = "git2r-"), - winslash = "/", - mustWork = FALSE - ) - df <- data.frame(x = 1, y = 1:10) - - - it("stops is connection is not a git repository", { - expect_that( - read_delim_git( - file = file, - local.path = local.path, - connection = connection, - commit.user = "me", - commit.email = "me@me.com" - ), - throws_error(paste0("'", connection, "' is not a directory")) - ) - }) - - dir.create(paste(connection, local.path, sep = "/"), recursive = TRUE) - repo <- git2r::init(connection) - - it("returns FALSE when the file doesn't exists", { - expect_that( - read_delim_git( - file = file, - local.path = local.path, - connection = connection, - commit.user = "me", - commit.email = "me@me.com" - ), - throws_error( - paste0("'", repo@path, "/", local.path, "/", file, "' is not a file") - ) - ) - }) - write_delim_git( - x = df, - file = file, - local.path = local.path, - connection = connection, - commit.user = "me", - commit.email = "me@me.com" - ) - it("read the tab-delimited file", { - expect_that( - read_delim_git( - file = file, - local.path = local.path, - connection = connection, - commit.user = "me", - commit.email = "me@me.com" - ), - is_equivalent_to(df) - ) - }) -}) diff --git a/tests/testthat/test_write_delim_git.R b/tests/testthat/test_write_delim_git.R deleted file mode 100644 index 7a5a1ad..0000000 --- a/tests/testthat/test_write_delim_git.R +++ /dev/null @@ -1,116 +0,0 @@ -context("write data.frame to git") -describe("write_delim_git()", { - commit.user <- "me" - commit.email <- "me@me.com" - x <- data.frame(0) - x1 <- data.frame(1) - file <- "test.txt" - local.path <- "test/subdir" - connection <- normalizePath( - tempfile(pattern = "git2r-"), - winslash = "/", - mustWork = FALSE - ) - - it("stops if connection is not a git repository", { - expect_that( - write_delim_git( - x = x, - file = file, - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - throws_error(paste0("'", connection, "' is not a directory")) - ) - }) - - dir.create(connection) - repo <- git2r::init(connection) - git2r::config(repo, user.name = "me", user.email = "me@me.com") - it("stops if the path doesn't exist", { - expect_that( - write_delim_git( - x = x, - file = file, - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - throws_error(paste0( - "'", - paste( - normalizePath(connection, winslash = "/", mustWork = FALSE), - local.path, - sep = "/" - ), - "' is not a directory" - )) - ) - }) - full.path <- paste(connection, local.path, sep = "/") - dir.create(full.path, recursive = TRUE) - it("stops if x is not a data.frame", { - expect_that( - write_delim_git( - x = matrix(0), - file = file, - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - throws_error("x is not a data.frame") - ) - }) - - full.file.path <- paste(connection, local.path, file, sep = "/") - it("returns the sha1 of the file", { - expect_that( - write_delim_git( - x = x, - file = file, - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_identical_to(git2r::hashfile(full.file.path)) - ) - }) - it("can handle tbl_df", { - expect_that( - write_delim_git( - x = dplyr::as.tbl(x), - file = file, - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - is_identical_to(git2r::hashfile(full.file.path)) - ) - }) - - it("stages the file", { - expect_that( - git2r::status(repo)$staged$new, - is_identical_to(paste(local.path, file, sep = "/")) - ) - junk <- git2r::commit(repo, "a") - write_delim_git( - x = x1, - file = file, - local.path = local.path, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ) - expect_that( - git2r::status(repo)$staged$modified, - is_identical_to(paste(local.path, file, sep = "/")) - ) - }) -}) From 4ec915123eac217a247e17a663552ce43e6d63a1 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Tue, 4 Sep 2018 14:34:38 +0200 Subject: [PATCH 04/11] update documentation on get_nbn_key() --- R/get_nbn_key.R | 199 ++++++++++++++++++++------------------------- man/get_nbn_key.Rd | 4 +- 2 files changed, 93 insertions(+), 110 deletions(-) diff --git a/R/get_nbn_key.R b/R/get_nbn_key.R index 8e41d05..fc8cbde 100644 --- a/R/get_nbn_key.R +++ b/R/get_nbn_key.R @@ -49,142 +49,124 @@ get_nbn_key <- function(name, language = "la", channel, authority = FALSE){ paste0("'", available, "'", collapse = ", ") ) } - if (authority == FALSE) { - output <- sprintf(" - SELECT - t.ITEM_NAME AS InputName, - ns.RECOMMENDED_TAXON_VERSION_KEY as NBNKey, - tr.ITEM_NAME AS GenericName, - CASE - WHEN tli.TAXON_LIST_VERSION_KEY like 'INB%%' - THEN 1 ELSE 0 END AS PreferenceInput, - CASE - WHEN tlir.TAXON_LIST_VERSION_KEY like 'INB%%' - THEN 1 ELSE 0 END AS PreferenceOutput, - tv.COMMENT AS Comment, - tv.Attribute - FROM - ( + if (isTRUE(authority)) { + sql <- sprintf(" + SELECT + t.ITEM_NAME + ' ' + t.AUTHORITY AS InputName, + ns.RECOMMENDED_TAXON_VERSION_KEY as NBNKey, + tr.ITEM_NAME AS GenericName, + CASE + WHEN tli.TAXON_LIST_VERSION_KEY like 'INB%%' + THEN 1 ELSE 0 END AS PreferenceInput, + CASE + WHEN tlir.TAXON_LIST_VERSION_KEY like 'INB%%' + THEN 1 ELSE 0 END AS PreferenceOutput, + tv.COMMENT AS Comment, + tv.Attribute + FROM ( ( ( - dbo.TAXON AS t + ( + dbo.TAXON AS t + INNER JOIN + dbo.TAXON_VERSION AS tv + ON + t.TAXON_KEY = tv.TAXON_KEY + ) INNER JOIN - dbo.TAXON_VERSION AS tv + dbo.TAXON_LIST_ITEM AS tli ON - t.TAXON_KEY = tv.TAXON_KEY + tv.TAXON_VERSION_KEY = tli.TAXON_VERSION_KEY ) INNER JOIN - dbo.TAXON_LIST_ITEM AS tli - ON - tv.TAXON_VERSION_KEY = tli.TAXON_VERSION_KEY - ) - INNER JOIN - ( ( - dbo.NAMESERVER AS ns + ( + dbo.NAMESERVER AS ns + INNER JOIN + dbo.TAXON_VERSION AS tvr + ON + ns.RECOMMENDED_TAXON_VERSION_KEY = tvr.TAXON_VERSION_KEY + ) INNER JOIN - dbo.TAXON_VERSION AS tvr + dbo.TAXON AS tr ON - ns.RECOMMENDED_TAXON_VERSION_KEY = tvr.TAXON_VERSION_KEY + tr.TAXON_KEY = tvr.TAXON_KEY ) - INNER JOIN - dbo.TAXON AS tr ON - tr.TAXON_KEY = tvr.TAXON_KEY + tv.TAXON_VERSION_KEY = ns.INPUT_TAXON_VERSION_KEY ) - ON - tv.TAXON_VERSION_KEY = ns.INPUT_TAXON_VERSION_KEY ) - ) - INNER JOIN - dbo.TAXON_LIST_ITEM AS tlir - ON - tlir.TAXON_LIST_ITEM_KEY = ns.RECOMMENDED_TAXON_LIST_ITEM_KEY - WHERE - t.LANGUAGE = '%s' AND - t.ITEM_NAME IN (%s)", - language, - paste0("'", name, "'", collapse = ", ") - ) %>% - sqlQuery( - channel = channel, - stringsAsFactors = FALSE, - as.is = TRUE - ) %>% - unique() - - if (anyDuplicated(output$InputName) > 1) { - output <- output %>% - group_by_(~InputName) %>% - filter_(~PreferenceInput == max(PreferenceInput)) %>% - filter_(~PreferenceOutput == max(PreferenceOutput)) %>% - ungroup() %>% - select_(~-PreferenceInput, ~-PreferenceOutput) %>% - as.data.frame() - } - if (anyDuplicated(output$InputName) > 1) { - warning("Duplicate matching keys") - } - return(output) #nocov end -} else { - output <- sprintf(" - SELECT - t.ITEM_NAME + ' ' + t.AUTHORITY AS InputName, - ns.RECOMMENDED_TAXON_VERSION_KEY as NBNKey, - tr.ITEM_NAME AS GenericName, - CASE - WHEN tli.TAXON_LIST_VERSION_KEY like 'INB%%' - THEN 1 ELSE 0 END AS PreferenceInput, - CASE - WHEN tlir.TAXON_LIST_VERSION_KEY like 'INB%%' - THEN 1 ELSE 0 END AS PreferenceOutput, - tv.COMMENT AS Comment, - tv.Attribute - FROM - ( + INNER JOIN + dbo.TAXON_LIST_ITEM AS tlir + ON + tlir.TAXON_LIST_ITEM_KEY = ns.RECOMMENDED_TAXON_LIST_ITEM_KEY + WHERE + t.LANGUAGE = '%s' AND + t.ITEM_NAME + ' ' + t.AUTHORITY IN (%s)", + language, + paste0("'", name, "'", collapse = ", ") + ) + } else { + sql <- sprintf(" + SELECT + t.ITEM_NAME AS InputName, + ns.RECOMMENDED_TAXON_VERSION_KEY as NBNKey, + tr.ITEM_NAME AS GenericName, + CASE + WHEN tli.TAXON_LIST_VERSION_KEY like 'INB%%' + THEN 1 ELSE 0 END AS PreferenceInput, + CASE + WHEN tlir.TAXON_LIST_VERSION_KEY like 'INB%%' + THEN 1 ELSE 0 END AS PreferenceOutput, + tv.COMMENT AS Comment, + tv.Attribute + FROM ( ( ( - dbo.TAXON AS t + ( + dbo.TAXON AS t + INNER JOIN + dbo.TAXON_VERSION AS tv + ON + t.TAXON_KEY = tv.TAXON_KEY + ) INNER JOIN - dbo.TAXON_VERSION AS tv + dbo.TAXON_LIST_ITEM AS tli ON - t.TAXON_KEY = tv.TAXON_KEY + tv.TAXON_VERSION_KEY = tli.TAXON_VERSION_KEY ) INNER JOIN - dbo.TAXON_LIST_ITEM AS tli - ON - tv.TAXON_VERSION_KEY = tli.TAXON_VERSION_KEY - ) - INNER JOIN - ( ( - dbo.NAMESERVER AS ns + ( + dbo.NAMESERVER AS ns + INNER JOIN + dbo.TAXON_VERSION AS tvr + ON + ns.RECOMMENDED_TAXON_VERSION_KEY = tvr.TAXON_VERSION_KEY + ) INNER JOIN - dbo.TAXON_VERSION AS tvr + dbo.TAXON AS tr ON - ns.RECOMMENDED_TAXON_VERSION_KEY = tvr.TAXON_VERSION_KEY + tr.TAXON_KEY = tvr.TAXON_KEY ) - INNER JOIN - dbo.TAXON AS tr ON - tr.TAXON_KEY = tvr.TAXON_KEY + tv.TAXON_VERSION_KEY = ns.INPUT_TAXON_VERSION_KEY ) - ON - tv.TAXON_VERSION_KEY = ns.INPUT_TAXON_VERSION_KEY ) - ) - INNER JOIN - dbo.TAXON_LIST_ITEM AS tlir - ON - tlir.TAXON_LIST_ITEM_KEY = ns.RECOMMENDED_TAXON_LIST_ITEM_KEY - WHERE - t.LANGUAGE = '%s' AND - t.ITEM_NAME + ' ' + t.AUTHORITY IN (%s)", - language, - paste0("'", name, "'", collapse = ", ") - ) %>% + INNER JOIN + dbo.TAXON_LIST_ITEM AS tlir + ON + tlir.TAXON_LIST_ITEM_KEY = ns.RECOMMENDED_TAXON_LIST_ITEM_KEY + WHERE + t.LANGUAGE = '%s' AND + t.ITEM_NAME IN (%s)", + language, + paste0("'", name, "'", collapse = ", ") + ) + } + output <- sql %>% sqlQuery( channel = channel, stringsAsFactors = FALSE, @@ -206,4 +188,3 @@ get_nbn_key <- function(name, language = "la", channel, authority = FALSE){ } return(output) #nocov end } -} diff --git a/man/get_nbn_key.Rd b/man/get_nbn_key.Rd index 839b6ec..b3d66ca 100644 --- a/man/get_nbn_key.Rd +++ b/man/get_nbn_key.Rd @@ -4,7 +4,7 @@ \alias{get_nbn_key} \title{Get the NBN key of a species} \usage{ -get_nbn_key(name, language = "la", channel) +get_nbn_key(name, language = "la", channel, authority = FALSE) } \arguments{ \item{name}{a vector of species names to check} @@ -12,6 +12,8 @@ get_nbn_key(name, language = "la", channel) \item{language}{The language to use. Defaults to "la" 'scientific name"} \item{channel}{An open RODBC channel to the NBN database} + +\item{authority}{Do the species names include authority?} } \description{ Get the NBN key of a species From 0a5c1fed97ab455e450abe9a76cbe7fec2b26e0d Mon Sep 17 00:00:00 2001 From: ThierryO Date: Tue, 4 Sep 2018 14:35:04 +0200 Subject: [PATCH 05/11] bugfix in git_connection() --- R/git_connection.R | 5 ++++- tests/testthat/test_git_connection.R | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/R/git_connection.R b/R/git_connection.R index 66aae70..0a79023 100644 --- a/R/git_connection.R +++ b/R/git_connection.R @@ -26,7 +26,10 @@ git_connection <- function( ){ assert_that(is.string(commit.user)) assert_that(is.string(commit.email)) - repo.path <- in_repository(path = repo.path) + assert_that( + in_repository(path = repo.path), + msg = "repo.path is not a git repository" + ) repo <- repository(repo.path) config(repo, user.name = commit.user, user.email = commit.email) diff --git a/tests/testthat/test_git_connection.R b/tests/testthat/test_git_connection.R index 6aa4529..0efb334 100644 --- a/tests/testthat/test_git_connection.R +++ b/tests/testthat/test_git_connection.R @@ -11,7 +11,7 @@ expect_error( commit.user = commit.user, commit.email = commit.email ), - "is not a directory" + "is not a git repository" ) dir.create(connection) expect_error( From f795b7e5eaae3ab2d5cc43528a2b1ff5af04aea5 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Tue, 4 Sep 2018 14:36:29 +0200 Subject: [PATCH 06/11] add connect_ut_db() --- NAMESPACE | 1 + R/connect_result.R | 23 ++++++++++++ man/connect_ut_db.Rd | 39 ++++++++++++++++++++ tests/testthat/test_check_dbtable_variable.R | 31 +++++----------- tests/testthat/test_check_id.R | 37 ++++--------------- 5 files changed, 81 insertions(+), 50 deletions(-) create mode 100644 man/connect_ut_db.Rd diff --git a/NAMESPACE b/NAMESPACE index 80881fd..e3aeb0b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(check_single_posix) export(check_single_probability) export(connect_nbn) export(connect_result) +export(connect_ut_db) export(cut_date) export(get_nbn_key) export(get_nbn_key_multi) diff --git a/R/connect_result.R b/R/connect_result.R index 98750d6..ea45dc8 100644 --- a/R/connect_result.R +++ b/R/connect_result.R @@ -34,3 +34,26 @@ connect_result <- function(username, password, develop = TRUE){ connect_nbn <- function(){ odbcDriverConnect(connection = nbn.dsn) } + +#' connect to the unit test database +#' @inheritParams dplyr::src_postgres +#' @export +#' @importFrom dplyr src_postgres +connect_ut_db <- function( + host = "localhost", + dbname = "n2kunittest", + user = "unittest_analysis", + password = "unittest", + port = 5432, + ... +){ + # nocov start + src_postgres( + host = host, + dbname = dbname, + user = user, + password = password, + ... + ) + # nocov end +} diff --git a/man/connect_ut_db.Rd b/man/connect_ut_db.Rd new file mode 100644 index 0000000..e5b4dae --- /dev/null +++ b/man/connect_ut_db.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/connect_result.R +\name{connect_ut_db} +\alias{connect_ut_db} +\title{connect to the unit test database} +\usage{ +connect_ut_db(host = "localhost", dbname = "n2kunittest", + user = "unittest_analysis", password = "unittest", port = 5432, ...) +} +\arguments{ +\item{host}{Host name and port number of database} + +\item{dbname}{Database name} + +\item{user}{User name and password. + +Generally, you should avoid saving username and password in your +scripts as it is easy to accidentally expose valuable credentials. +Instead, retrieve them from environment variables, or use database +specific credential scores. For example, with MySQL you can set up \code{my.cnf} +as described in \code{\link[RMySQL:MySQL]{RMySQL::MySQL()}}.} + +\item{password}{User name and password. + +Generally, you should avoid saving username and password in your +scripts as it is easy to accidentally expose valuable credentials. +Instead, retrieve them from environment variables, or use database +specific credential scores. For example, with MySQL you can set up \code{my.cnf} +as described in \code{\link[RMySQL:MySQL]{RMySQL::MySQL()}}.} + +\item{port}{Host name and port number of database} + +\item{...}{for the src, other arguments passed on to the underlying +database connector, \code{\link[DBI:dbConnect]{DBI::dbConnect()}}. For the tbl, included for +compatibility with the generic, but otherwise ignored.} +} +\description{ +connect to the unit test database +} diff --git a/tests/testthat/test_check_dbtable_variable.R b/tests/testthat/test_check_dbtable_variable.R index 54cedfe..f8eb59e 100644 --- a/tests/testthat/test_check_dbtable_variable.R +++ b/tests/testthat/test_check_dbtable_variable.R @@ -6,10 +6,7 @@ describe("check_dbtable_variable()", { error <- TRUE it("checks if table is a single character", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_dbtable_variable( table = integer(0), @@ -46,14 +43,12 @@ describe("check_dbtable_variable()", { ), throws_error("table must be a single character") ) + DBI::dbDisconnect(channel$con) }) it("checks if table exists", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_dbtable_variable( table = junk, @@ -63,7 +58,7 @@ describe("check_dbtable_variable()", { ), throws_error( sprintf( - "Table\\(s\\) junk not found in schema public on database n2kresult", + "Table\\(s\\) %s not found in schema public on database", junk ) ) @@ -72,10 +67,7 @@ describe("check_dbtable_variable()", { it("checks if channel is on ODBC connection", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_dbtable_variable( table = table, @@ -85,14 +77,12 @@ describe("check_dbtable_variable()", { ), throws_error("channel does not inherit from class DBIConnection") ) + DBI::dbDisconnect(channel$con) }) it("checks if variable is a non-empty character without missing values", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_dbtable_variable( table = table, @@ -122,14 +112,12 @@ describe("check_dbtable_variable()", { ), throws_error("'variable' must contain at least one value") ) + DBI::dbDisconnect(channel$con) }) it("gives correct output", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_dbtable_variable( table = table, @@ -171,6 +159,7 @@ describe("check_dbtable_variable()", { ) ) ) + DBI::dbDisconnect(channel$con) }) }) diff --git a/tests/testthat/test_check_id.R b/tests/testthat/test_check_id.R index 0f807c2..ed2f904 100644 --- a/tests/testthat/test_check_id.R +++ b/tests/testthat/test_check_id.R @@ -24,10 +24,7 @@ describe("check_id()", { }) it("tests if the table exists in the ODBC connection", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_id( value = value, @@ -37,33 +34,16 @@ describe("check_id()", { ), throws_error( sprintf( - "Table\\(s\\) %s not found in schema public on database n2kresult", + "Table\\(s\\) %s not found in schema public on database", junk ) ) ) - }) - it("tests if data type is correct", { - skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) - expect_error( - check_id( - value = 999999999, - variable = variable.text, - table = table, - channel = channel - ) - ) + DBI::dbDisconnect(channel$con) }) it("tests if the variable table exists in the table", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() value <- 1 expect_that( check_id( @@ -74,21 +54,20 @@ describe("check_id()", { ), throws_error(paste0("Variable\\(s\\) missing from '", table, "': ", junk)) ) + DBI::dbDisconnect(channel$con) }) it("tests if the id exists in the table", { skip_on_cran() - channel <- connect_result( - username = Sys.getenv("N2KRESULT_USERNAME"), - password = Sys.getenv("N2KRESULT_PASSWORD") - ) + channel <- connect_ut_db() expect_that( check_id( - value = 999999999, + value = 99999999, variable = variable, table = table, channel = channel ), is_false() ) + DBI::dbDisconnect(channel$con) }) }) From 7d2152da26e6f16a8ebc9a9f0123b1bfaf2587f7 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Tue, 4 Sep 2018 14:56:24 +0200 Subject: [PATCH 07/11] remove testthat warnings --- NAMESPACE | 1 + R/git_connection.R | 2 +- R/read_object_environment.R | 3 +- .../testthat/test_check_dataframe_covariate.R | 36 +++++++++++-------- .../testthat/test_check_dataframe_variable.R | 21 +++++++---- tests/testthat/test_read_object_environment.R | 20 +++++------ 6 files changed, 49 insertions(+), 34 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e3aeb0b..1b6d4cf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -87,6 +87,7 @@ importFrom(stats,na.fail) importFrom(tidyr,spread) importFrom(tidyr,spread_) importFrom(utils,file_test) +importFrom(utils,hasName) importFrom(utils,head) importFrom(utils,tail) importFrom(utils,write.table) diff --git a/R/git_connection.R b/R/git_connection.R index 0a79023..d867a47 100644 --- a/R/git_connection.R +++ b/R/git_connection.R @@ -27,7 +27,7 @@ git_connection <- function( assert_that(is.string(commit.user)) assert_that(is.string(commit.email)) assert_that( - in_repository(path = repo.path), + suppressWarnings(in_repository(path = repo.path)), msg = "repo.path is not a git repository" ) repo <- repository(repo.path) diff --git a/R/read_object_environment.R b/R/read_object_environment.R index 2f9d667..ef30243 100644 --- a/R/read_object_environment.R +++ b/R/read_object_environment.R @@ -7,6 +7,7 @@ #' @return the object or \code{NULL} is the object doesn't exists in the #' environment #' @export +#' @importFrom utils hasName #' @examples #' object <- "test" #' value <- TRUE @@ -21,7 +22,7 @@ read_object_environment <- function(object, env, warn = TRUE){ } warn <- check_single_logical(warn, name = "warn") - if (!exists(object, envir = env)) { + if (!hasName(env, object)) { if (warn) { warning(object, " doesn't exists in env") } diff --git a/tests/testthat/test_check_dataframe_covariate.R b/tests/testthat/test_check_dataframe_covariate.R index 528b84f..ff1f5cd 100644 --- a/tests/testthat/test_check_dataframe_covariate.R +++ b/tests/testthat/test_check_dataframe_covariate.R @@ -42,11 +42,13 @@ describe("check_dataframe_covariate()", { dataframe", { for (covariate in covariates.one) { expect_that( - check_dataframe_covariate( - df = df[, c("Count", "B", "C")], - covariate = covariate, - response = response, - error = FALSE + suppressWarnings( + check_dataframe_covariate( + df = df[, c("Count", "B", "C")], + covariate = covariate, + response = response, + error = FALSE + ) ), is_false() ) @@ -60,11 +62,13 @@ describe("check_dataframe_covariate()", { gives_warning("Variables missing in df: A") ) expect_that( - check_dataframe_covariate( - df = df, - covariate = covariate, - response = missing.response, - error = FALSE + suppressWarnings( + check_dataframe_covariate( + df = df, + covariate = covariate, + response = missing.response, + error = FALSE + ) ), is_false() ) @@ -80,11 +84,13 @@ describe("check_dataframe_covariate()", { } for (covariate in covariates.two) { expect_that( - check_dataframe_covariate( - df = df[, c("Count", "C")], - covariate = covariate, - response = response, - error = FALSE + suppressWarnings( + check_dataframe_covariate( + df = df[, c("Count", "C")], + covariate = covariate, + response = response, + error = FALSE + ) ), is_false() ) diff --git a/tests/testthat/test_check_dataframe_variable.R b/tests/testthat/test_check_dataframe_variable.R index 92c7dc0..dd111ee 100644 --- a/tests/testthat/test_check_dataframe_variable.R +++ b/tests/testthat/test_check_dataframe_variable.R @@ -138,17 +138,24 @@ describe("check_dataframe_variable()", { ) ) expect_that( - check_dataframe_variable( - df = df, variable = c(variable, missing.var), name = name, error = FALSE + suppressWarnings( + check_dataframe_variable( + df = df, + variable = c(variable, missing.var), + name = name, + error = FALSE + ) ), is_false() ) expect_that( - check_dataframe_variable( - df = df.matrix, - variable = c(variable, missing.var), - name = name, - error = FALSE + suppressWarnings( + check_dataframe_variable( + df = df.matrix, + variable = c(variable, missing.var), + name = name, + error = FALSE + ) ), is_false() ) diff --git a/tests/testthat/test_read_object_environment.R b/tests/testthat/test_read_object_environment.R index 10e18af..cef600b 100644 --- a/tests/testthat/test_read_object_environment.R +++ b/tests/testthat/test_read_object_environment.R @@ -7,19 +7,20 @@ describe("read_object_environment()", { assign(x = object, value = value, envir = env) it("checks if env is an environment", { - expect_that( + expect_error( read_object_environment(object = object, env = object), - throws_error("env is not an environment") + "env is not an environment" ) }) it("returns the object or NULL if the object doesn't exists", { - expect_that( + expect_identical( read_object_environment(object = object, env = env), - is_identical_to(value) + value ) - expect_that( - read_object_environment(object = missing.object, env = env), - is_null() + expect_null( + suppressWarnings( + read_object_environment(object = missing.object, env = env) + ) ) }) it("returns a warning when the object is missing", { @@ -31,9 +32,8 @@ describe("read_object_environment()", { read_object_environment(object = missing.object, env = env, warn = TRUE), gives_warning(paste(missing.object, "doesn't exists in env")) ) - expect_that( - read_object_environment(object = missing.object, env = env, warn = FALSE), - testthat::not(gives_warning()) + expect_silent( + read_object_environment(object = missing.object, env = env, warn = FALSE) ) }) }) From fb1018acf30d28acb6470a3cf63669076d0ea61c Mon Sep 17 00:00:00 2001 From: ThierryO Date: Wed, 5 Sep 2018 10:56:46 +0200 Subject: [PATCH 08/11] add auto_commit() --- DESCRIPTION | 3 +- NAMESPACE | 7 ++ R/auto_commit.R | 102 ++++++++++++++++++++++++++++++ man/auto_commit.Rd | 30 +++++++++ tests/testthat/test_auto_commit.R | 72 +++++++++++++++++++++ 5 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 R/auto_commit.R create mode 100644 man/auto_commit.Rd create mode 100644 tests/testthat/test_auto_commit.R diff --git a/DESCRIPTION b/DESCRIPTION index ef405b2..e59e6dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,6 +26,8 @@ LazyData: true Suggests: testthat Collate: + 'gitConnection_class.R' + 'auto_commit.R' 'check_character.R' 'check_dataframe_covariate.R' 'check_dataframe_variable.R' @@ -43,7 +45,6 @@ Collate: 'get_nbn_key.R' 'get_nbn_key_multi.R' 'get_nbn_name.R' - 'gitConnection_class.R' 'git_connect.R' 'git_connection.R' 'is_chartor.R' diff --git a/NAMESPACE b/NAMESPACE index 1b6d4cf..f3f1fdf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -29,6 +29,7 @@ export(odbc_get_multi_id) export(odbc_insert) export(read_object_environment) exportClasses(gitConnection) +exportMethods(auto_commit) importFrom(DBI,dbExistsTable) importFrom(DBI,dbGetInfo) importFrom(DBI,dbGetQuery) @@ -64,10 +65,13 @@ importFrom(dplyr,src_postgres) importFrom(dplyr,summarise_) importFrom(dplyr,tbl) importFrom(dplyr,ungroup) +importFrom(git2r,commit) importFrom(git2r,config) importFrom(git2r,cred_ssh_key) importFrom(git2r,cred_user_pass) +importFrom(git2r,head) importFrom(git2r,in_repository) +importFrom(git2r,push) importFrom(git2r,repository) importFrom(lazyeval,interp) importFrom(lubridate,is.Date) @@ -76,6 +80,8 @@ importFrom(lubridate,year) importFrom(methods,new) importFrom(methods,setClass) importFrom(methods,setClassUnion) +importFrom(methods,setGeneric) +importFrom(methods,setMethod) importFrom(methods,setOldClass) importFrom(methods,setValidity) importFrom(plyr,ddply) @@ -89,5 +95,6 @@ importFrom(tidyr,spread_) importFrom(utils,file_test) importFrom(utils,hasName) importFrom(utils,head) +importFrom(utils,sessionInfo) importFrom(utils,tail) importFrom(utils,write.table) diff --git a/R/auto_commit.R b/R/auto_commit.R new file mode 100644 index 0000000..66410d6 --- /dev/null +++ b/R/auto_commit.R @@ -0,0 +1,102 @@ +#' Commit staged changes in a git repository with automated message +#' +#' The mesagge is based on the information returned by \code{\link[utils]{sessionInfo}} +#' @param package The name of the package from which we autocommit +#' @param connection The path of the repository. Default to \code{rawdata.path} +#' @param push Logical indicating whether to push the commit. Defaults to FALSE. +#' @param ... parameters passed to \code{git_connection} when relevant +#' @name auto_commit +#' @rdname auto_commit +#' @exportMethod auto_commit +#' @docType methods +#' @importFrom methods setGeneric +#' @include gitConnection_class.R +setGeneric( + name = "auto_commit", + def = function( + package, connection, push = FALSE, ... + ){ + standard.generic("autocommit") + } +) + +#' @rdname auto_commit +#' @aliases auto_commit,gitConnection-methods +#' @importFrom methods setMethod +#' @importFrom git2r repository commit cred_user_pass head push +setMethod( + f = "auto_commit", + signature = signature(connection = "ANY"), + definition = function( + package, + connection, + push = FALSE, + ... + ){ + auto_commit( + package = package, + connection = git_connection(repo.path = connection, ...), + push = push + ) + } +) + + +#' @rdname auto_commit +#' @aliases auto_commit,git_connection-methods +#' @importFrom methods setMethod +#' @importFrom git2r commit push +#' @importFrom utils sessionInfo +setMethod( + f = "auto_commit", + signature = signature(connection = "gitConnection"), + definition = function(package, connection, push = FALSE, ...){ + package <- check_single_character(package) + + #format commit message based on sessionInfo() + info <- sessionInfo() + format.other <- function(x){ + paste0(x$Package, " ", x$Version, " built ", x$Built, "\n") + } + message <- paste0( + "Automatic commit from ", package, "\n\n", + info$R.version$version.string, " revision ", info$R.version$"svn rev", + " on ", info$R.version$platform, "\n", + "\nBase packages: ", + paste0(info$basePkgs, collapse = ", "), "\n", + "\nOther package(s):\n", + paste(sapply(info$otherPkgs, format.other), collapse = ""), + "\nLoaded via a namespace:\n", + paste(sapply(info$loadedOnly, format.other), collapse = "") + ) + + committed <- tryCatch( + commit(repo = connection@Repository, message = message), + error = function(e){ + if (e$message == "Error in 'git2r_commit': Nothing added to commit\n") { + FALSE + } else { + e + } + } + ) + if ("error" %in% class(committed)) { + stop(committed) + } + if (class(committed) != "git_commit") { + return(invisible(TRUE)) + } + if (isTRUE(push)) { + message("Pushing changes to remote repository") + tryCatch( + push(connection@Repository, credentials = connection@Credentials), + error = function(e){ + warning(e) + } + ) + } else { + warning("changes committed but not pushed") + } + return(invisible(TRUE)) + } +) diff --git a/man/auto_commit.Rd b/man/auto_commit.Rd new file mode 100644 index 0000000..b145dd6 --- /dev/null +++ b/man/auto_commit.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/auto_commit.R +\docType{methods} +\name{auto_commit} +\alias{auto_commit} +\alias{auto_commit,ANY,ANY-method} +\alias{auto_commit,gitConnection-methods} +\alias{auto_commit,ANY,gitConnection-method} +\alias{auto_commit,git_connection-methods} +\title{Commit staged changes in a git repository with automated message} +\usage{ +auto_commit(package, connection, push = FALSE, ...) + +\S4method{auto_commit}{ANY,ANY}(package, connection, push = FALSE, ...) + +\S4method{auto_commit}{ANY,gitConnection}(package, connection, push = FALSE, + ...) +} +\arguments{ +\item{package}{The name of the package from which we autocommit} + +\item{connection}{The path of the repository. Default to \code{rawdata.path}} + +\item{push}{Logical indicating whether to push the commit. Defaults to FALSE.} + +\item{...}{parameters passed to \code{git_connection} when relevant} +} +\description{ +The mesagge is based on the information returned by \code{\link[utils]{sessionInfo}} +} diff --git a/tests/testthat/test_auto_commit.R b/tests/testthat/test_auto_commit.R new file mode 100644 index 0000000..d3457a4 --- /dev/null +++ b/tests/testthat/test_auto_commit.R @@ -0,0 +1,72 @@ +context("autocommit changes") +describe("auto_commit()", { + package <- "test" + user <- "test" + pwd <- "test" + commit.user <- "me" + commit.email <- "me@me.com" + + # function to create and stage a file + dummy_add <- function(connection){ + content <- paste(sample(letters, 8, replace = TRUE), collapse = "") + writeLines(content, paste(connection, content, sep = "/")) + git2r::add(git2r::repository(connection), content) + } + + # create test repository + origin.path <- tempfile(pattern = "git2r-") + connection <- tempfile(pattern = "git2rclone-") + dir.create(origin.path) + dir.create(connection) + repo_bare <- git2r::init(origin.path, bare = TRUE) + repo <- git2r::clone(origin.path, connection) + git2r::config(repo, user.name = commit.user, user.email = commit.email) + dummy_add(connection) + git2r::commit(repo, "inital") + git2r::push(repo, "origin", "refs/heads/master") + + it("gives a warning when no username and password are provided and returns + TRUE", { + dummy_add(connection = connection) + expect_that( + output <- auto_commit( + package = package, + connection = connection, + commit.user = commit.user, + commit.email = commit.email + ), + gives_warning("changes committed but not pushed") + ) + expect_true(output) + }) + it("returns TRUE when nothing to commit", { + expect_true( + auto_commit( + package = package, + connection = connection, + commit.user = commit.user, + commit.email = commit.email + ) + ) + }) + it("returns TRUE when changes are pushed", { + dummy_add(connection = connection) + expect_true( + auto_commit( + package = package, + connection = connection, + username = user, + password = pwd, + commit.user = commit.user, + commit.email = commit.email, + push = TRUE + ) + ) + }) + it("writes a correct message title", { + expect_identical( + git2r::reflog(repo)[[1]]$message, + paste("commit: Automatic commit from", package) + ) + }) +}) From 5e3298f1c276b6afff669a3b48e868c2e841a7c0 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Thu, 6 Sep 2018 10:32:46 +0200 Subject: [PATCH 09/11] odbc_get_id() returns an unnamed vector --- R/odbc_get_id.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/odbc_get_id.R b/R/odbc_get_id.R index d2d6385..664d114 100644 --- a/R/odbc_get_id.R +++ b/R/odbc_get_id.R @@ -36,5 +36,6 @@ odbc_get_id <- function( filter_(.dots = dots) %>% select_(id_variable) %>% collect() %>% - unlist() # nocov end + unlist() %>% + unname() # nocov end } From b3fc757b98d680515c694e68a01e2892a372bad4 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Mon, 10 Sep 2018 13:46:20 +0200 Subject: [PATCH 10/11] auto_commit() is moved to git2rdata --- DESCRIPTION | 3 +- NAMESPACE | 7 -- R/auto_commit.R | 102 ------------------------------ man/auto_commit.Rd | 30 --------- tests/testthat/test_auto_commit.R | 72 --------------------- 5 files changed, 1 insertion(+), 213 deletions(-) delete mode 100644 R/auto_commit.R delete mode 100644 man/auto_commit.Rd delete mode 100644 tests/testthat/test_auto_commit.R diff --git a/DESCRIPTION b/DESCRIPTION index e59e6dc..ef405b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,8 +26,6 @@ LazyData: true Suggests: testthat Collate: - 'gitConnection_class.R' - 'auto_commit.R' 'check_character.R' 'check_dataframe_covariate.R' 'check_dataframe_variable.R' @@ -45,6 +43,7 @@ Collate: 'get_nbn_key.R' 'get_nbn_key_multi.R' 'get_nbn_name.R' + 'gitConnection_class.R' 'git_connect.R' 'git_connection.R' 'is_chartor.R' diff --git a/NAMESPACE b/NAMESPACE index f3f1fdf..1b6d4cf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -29,7 +29,6 @@ export(odbc_get_multi_id) export(odbc_insert) export(read_object_environment) exportClasses(gitConnection) -exportMethods(auto_commit) importFrom(DBI,dbExistsTable) importFrom(DBI,dbGetInfo) importFrom(DBI,dbGetQuery) @@ -65,13 +64,10 @@ importFrom(dplyr,src_postgres) importFrom(dplyr,summarise_) importFrom(dplyr,tbl) importFrom(dplyr,ungroup) -importFrom(git2r,commit) importFrom(git2r,config) importFrom(git2r,cred_ssh_key) importFrom(git2r,cred_user_pass) -importFrom(git2r,head) importFrom(git2r,in_repository) -importFrom(git2r,push) importFrom(git2r,repository) importFrom(lazyeval,interp) importFrom(lubridate,is.Date) @@ -80,8 +76,6 @@ importFrom(lubridate,year) importFrom(methods,new) importFrom(methods,setClass) importFrom(methods,setClassUnion) -importFrom(methods,setGeneric) -importFrom(methods,setMethod) importFrom(methods,setOldClass) importFrom(methods,setValidity) importFrom(plyr,ddply) @@ -95,6 +89,5 @@ importFrom(tidyr,spread_) importFrom(utils,file_test) importFrom(utils,hasName) importFrom(utils,head) -importFrom(utils,sessionInfo) importFrom(utils,tail) importFrom(utils,write.table) diff --git a/R/auto_commit.R b/R/auto_commit.R deleted file mode 100644 index 66410d6..0000000 --- a/R/auto_commit.R +++ /dev/null @@ -1,102 +0,0 @@ -#' Commit staged changes in a git repository with automated message -#' -#' The mesagge is based on the information returned by \code{\link[utils]{sessionInfo}} -#' @param package The name of the package from which we autocommit -#' @param connection The path of the repository. Default to \code{rawdata.path} -#' @param push Logical indicating whether to push the commit. Defaults to FALSE. -#' @param ... parameters passed to \code{git_connection} when relevant -#' @name auto_commit -#' @rdname auto_commit -#' @exportMethod auto_commit -#' @docType methods -#' @importFrom methods setGeneric -#' @include gitConnection_class.R -setGeneric( - name = "auto_commit", - def = function( - package, connection, push = FALSE, ... - ){ - standard.generic("autocommit") - } -) - -#' @rdname auto_commit -#' @aliases auto_commit,gitConnection-methods -#' @importFrom methods setMethod -#' @importFrom git2r repository commit cred_user_pass head push -setMethod( - f = "auto_commit", - signature = signature(connection = "ANY"), - definition = function( - package, - connection, - push = FALSE, - ... - ){ - auto_commit( - package = package, - connection = git_connection(repo.path = connection, ...), - push = push - ) - } -) - - -#' @rdname auto_commit -#' @aliases auto_commit,git_connection-methods -#' @importFrom methods setMethod -#' @importFrom git2r commit push -#' @importFrom utils sessionInfo -setMethod( - f = "auto_commit", - signature = signature(connection = "gitConnection"), - definition = function(package, connection, push = FALSE, ...){ - package <- check_single_character(package) - - #format commit message based on sessionInfo() - info <- sessionInfo() - format.other <- function(x){ - paste0(x$Package, " ", x$Version, " built ", x$Built, "\n") - } - message <- paste0( - "Automatic commit from ", package, "\n\n", - info$R.version$version.string, " revision ", info$R.version$"svn rev", - " on ", info$R.version$platform, "\n", - "\nBase packages: ", - paste0(info$basePkgs, collapse = ", "), "\n", - "\nOther package(s):\n", - paste(sapply(info$otherPkgs, format.other), collapse = ""), - "\nLoaded via a namespace:\n", - paste(sapply(info$loadedOnly, format.other), collapse = "") - ) - - committed <- tryCatch( - commit(repo = connection@Repository, message = message), - error = function(e){ - if (e$message == "Error in 'git2r_commit': Nothing added to commit\n") { - FALSE - } else { - e - } - } - ) - if ("error" %in% class(committed)) { - stop(committed) - } - if (class(committed) != "git_commit") { - return(invisible(TRUE)) - } - if (isTRUE(push)) { - message("Pushing changes to remote repository") - tryCatch( - push(connection@Repository, credentials = connection@Credentials), - error = function(e){ - warning(e) - } - ) - } else { - warning("changes committed but not pushed") - } - return(invisible(TRUE)) - } -) diff --git a/man/auto_commit.Rd b/man/auto_commit.Rd deleted file mode 100644 index b145dd6..0000000 --- a/man/auto_commit.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auto_commit.R -\docType{methods} -\name{auto_commit} -\alias{auto_commit} -\alias{auto_commit,ANY,ANY-method} -\alias{auto_commit,gitConnection-methods} -\alias{auto_commit,ANY,gitConnection-method} -\alias{auto_commit,git_connection-methods} -\title{Commit staged changes in a git repository with automated message} -\usage{ -auto_commit(package, connection, push = FALSE, ...) - -\S4method{auto_commit}{ANY,ANY}(package, connection, push = FALSE, ...) - -\S4method{auto_commit}{ANY,gitConnection}(package, connection, push = FALSE, - ...) -} -\arguments{ -\item{package}{The name of the package from which we autocommit} - -\item{connection}{The path of the repository. Default to \code{rawdata.path}} - -\item{push}{Logical indicating whether to push the commit. Defaults to FALSE.} - -\item{...}{parameters passed to \code{git_connection} when relevant} -} -\description{ -The mesagge is based on the information returned by \code{\link[utils]{sessionInfo}} -} diff --git a/tests/testthat/test_auto_commit.R b/tests/testthat/test_auto_commit.R deleted file mode 100644 index d3457a4..0000000 --- a/tests/testthat/test_auto_commit.R +++ /dev/null @@ -1,72 +0,0 @@ -context("autocommit changes") -describe("auto_commit()", { - package <- "test" - user <- "test" - pwd <- "test" - commit.user <- "me" - commit.email <- "me@me.com" - - # function to create and stage a file - dummy_add <- function(connection){ - content <- paste(sample(letters, 8, replace = TRUE), collapse = "") - writeLines(content, paste(connection, content, sep = "/")) - git2r::add(git2r::repository(connection), content) - } - - # create test repository - origin.path <- tempfile(pattern = "git2r-") - connection <- tempfile(pattern = "git2rclone-") - dir.create(origin.path) - dir.create(connection) - repo_bare <- git2r::init(origin.path, bare = TRUE) - repo <- git2r::clone(origin.path, connection) - git2r::config(repo, user.name = commit.user, user.email = commit.email) - dummy_add(connection) - git2r::commit(repo, "inital") - git2r::push(repo, "origin", "refs/heads/master") - - it("gives a warning when no username and password are provided and returns - TRUE", { - dummy_add(connection = connection) - expect_that( - output <- auto_commit( - package = package, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ), - gives_warning("changes committed but not pushed") - ) - expect_true(output) - }) - it("returns TRUE when nothing to commit", { - expect_true( - auto_commit( - package = package, - connection = connection, - commit.user = commit.user, - commit.email = commit.email - ) - ) - }) - it("returns TRUE when changes are pushed", { - dummy_add(connection = connection) - expect_true( - auto_commit( - package = package, - connection = connection, - username = user, - password = pwd, - commit.user = commit.user, - commit.email = commit.email, - push = TRUE - ) - ) - }) - it("writes a correct message title", { - expect_identical( - git2r::reflog(repo)[[1]]$message, - paste("commit: Automatic commit from", package) - ) - }) -}) From 2a508ee1b145c3c79da77c169d0632c61531eb85 Mon Sep 17 00:00:00 2001 From: ThierryO Date: Tue, 2 Oct 2018 15:53:17 +0200 Subject: [PATCH 11/11] bump package version --- DESCRIPTION | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ef405b2..ac8f7c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,9 +1,16 @@ Package: n2khelper Title: Auxiliary Functions for the Analysis and Reporting of the Natura 2000 Monitoring -Version: 0.4.1.1 -Date: 2017-11-25 -Authors@R: c(person("Thierry", "Onkelinx", email = "thierry.onkelinx@inbo.be", role = c("aut", "cre"))) +Version: 0.4.2 +Date: 2018-10-02 +Authors@R: c( + person( + "Thierry", "Onkelinx", role = c("aut", "cre"), + email = "thierry.onkelinx@inbo.be", + comment = c(ORCID = "0000-0001-8804-4216")), + person( + family = "Research Institute for Nature and Forest", + role = c("cph", "fnd"), email = "info@inbo.be")) Description: Auxiliary functions for analysing Natura 2000 monitoring data. URL: https://doi.org/10.5281/zenodo.835732 BugReports: https://github.com/inbo/n2khelper/issues