From cca8c2c35767b0fc46f72a9dab843a00fe4c624a Mon Sep 17 00:00:00 2001 From: nayib Date: Fri, 20 May 2022 08:33:09 -0600 Subject: [PATCH 1/3] Ref #116 git commands now working --- R/credential_cache.R | 12 +++++------- R/git.R | 8 +++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/credential_cache.R b/R/credential_cache.R index bba51a1..d84cb0d 100644 --- a/R/credential_cache.R +++ b/R/credential_cache.R @@ -16,13 +16,11 @@ #' @export set_git_credentials_cache <- function(hours = 4, global = TRUE) { -if (global == TRUE) { - system(paste( - "git config --global credential.helper cache --timeout=", - hours * 60 * 60, "'"), show.output.on.console = FALSE) + if (global == TRUE) { + system(paste0('git config --global credential.helper "cache --timeout=', + hours * 60 * 60, '"')) } else { - system(paste( - "git config credential.helper cache --timeout=", - hours * 60 * 60, "'"), show.output.on.console = FALSE) + system(paste0('git config credential.helper "cache --timeout=', + hours * 60 * 60, '"')) } } diff --git a/R/git.R b/R/git.R index b50f88c..c7fe380 100644 --- a/R/git.R +++ b/R/git.R @@ -101,9 +101,11 @@ incluye_upstream <- function(instancia = "guardada") { set_git_timeout <- function(timeout = 14400, global = FALSE) { if (global == TRUE) { - instruction <- paste0("git config --global credential.helper cache --timeout=", timeout) + instruction <- paste0('git config --global credential.helper "cache --timeout=', + timeout, '"') } else { - instruction <- paste0("git config credential.helper cache --timeout=", timeout) + instruction <- paste0('git config credential.helper "cache --timeout=', + timeout, '"') } system(instruction) @@ -133,7 +135,7 @@ set_git_timeout <- function(timeout = 14400, global = FALSE) { #' @param global si el cambio debe ser global o local para el repositorio #' #' @export -fijar_tiempo_credenciales <- function(pausa = 14000, global = FALSE) { +fijar_tiempo_credenciales <- function(pausa = 14400, global = FALSE) { if (global == FALSE) { set_git_timeout(timeout = pausa, global = FALSE) From ca50011ad02b1cf70659249869cab8a891e638ea Mon Sep 17 00:00:00 2001 From: nayib Date: Fri, 20 May 2022 14:40:39 -0600 Subject: [PATCH 2/3] Ref #104 setting up test environment --- DESCRIPTION | 3 ++- tests/testthat.R | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/testthat.R diff --git a/DESCRIPTION b/DESCRIPTION index c959a5c..c2730bd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,7 +43,7 @@ Suggests: readr (>= 1.3.1), rmarkdown (>= 1.12), rstudioapi (>= 0.10), - testthat (>= 2.1.1), + testthat (>= 3.0.0), tidyr (>= 0.8.3), pkgdown (>= 2.0.3) VignetteBuilder: @@ -56,3 +56,4 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 URL: https://github.com/ixpantia/ixplorer BugReports: https://github.com/ixpantia/ixplorer/issues +Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..0805668 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(ixplorer) + +test_check("ixplorer") From bbfcb51e0b1ba79d767463f59ed611e10a50c19c Mon Sep 17 00:00:00 2001 From: nayib Date: Fri, 20 May 2022 15:18:11 -0600 Subject: [PATCH 3/3] Ref #104 first tests, and code fixes due to tests --- R/credential_cache.R | 2 +- R/git.R | 2 +- tests/testthat/tests.R | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tests/testthat/tests.R diff --git a/R/credential_cache.R b/R/credential_cache.R index d84cb0d..db73cbd 100644 --- a/R/credential_cache.R +++ b/R/credential_cache.R @@ -17,7 +17,7 @@ set_git_credentials_cache <- function(hours = 4, global = TRUE) { if (global == TRUE) { - system(paste0('git config --global credential.helper "cache --timeout=', + system(paste0('git config --global credential.helper --replace-all "cache --timeout=', hours * 60 * 60, '"')) } else { system(paste0('git config credential.helper "cache --timeout=', diff --git a/R/git.R b/R/git.R index c7fe380..4424f5e 100644 --- a/R/git.R +++ b/R/git.R @@ -101,7 +101,7 @@ incluye_upstream <- function(instancia = "guardada") { set_git_timeout <- function(timeout = 14400, global = FALSE) { if (global == TRUE) { - instruction <- paste0('git config --global credential.helper "cache --timeout=', + instruction <- paste0('git config --global credential.helper --replace-all "cache --timeout=', timeout, '"') } else { instruction <- paste0('git config credential.helper "cache --timeout=', diff --git a/tests/testthat/tests.R b/tests/testthat/tests.R new file mode 100644 index 0000000..af81695 --- /dev/null +++ b/tests/testthat/tests.R @@ -0,0 +1,12 @@ +library(testthat) +library(ixplorer) + + +testthat::test_that("git commands are well executed", { + testthat::expect_silent(set_git_credentials_cache(global = TRUE, hours = 6)) + testthat::expect_silent(set_git_credentials_cache(global = FALSE, hours = 8)) + testthat::expect_silent(ixplorer::set_git_timeout(timeout = 14403, global = TRUE)) + testthat::expect_silent(ixplorer::set_git_timeout(timeout = 14403, global = FALSE)) + testthat::expect_silent(ixplorer::fijar_tiempo_credenciales(pausa = 14404, global = FALSE)) + testthat::expect_silent(ixplorer::fijar_tiempo_credenciales(pausa = 14405, global = TRUE)) +})