Skip to content

Commit

Permalink
Merge pull request #117 from nayib-ixpantia/T116
Browse files Browse the repository at this point in the history
Git commands fixing and tests
  • Loading branch information
andreavargasmon authored May 20, 2022
2 parents 601cea6 + bbfcb51 commit 5eff045
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
12 changes: 5 additions & 7 deletions R/credential_cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 --replace-all "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, '"'))
}
}
8 changes: 5 additions & 3 deletions R/git.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 --replace-all "cache --timeout=',
timeout, '"')
} else {
instruction <- paste0("git config credential.helper cache --timeout=", timeout)
instruction <- paste0('git config credential.helper "cache --timeout=',
timeout, '"')
}

system(instruction)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(ixplorer)

test_check("ixplorer")
12 changes: 12 additions & 0 deletions tests/testthat/tests.R
Original file line number Diff line number Diff line change
@@ -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))
})

0 comments on commit 5eff045

Please sign in to comment.