Skip to content

Commit

Permalink
Merge pull request #103 from danielgranadoscampos/T102
Browse files Browse the repository at this point in the history
General fixes for R CMD  warnings and code cleaning
  • Loading branch information
ronnyhdez authored Mar 4, 2022
2 parents 99eb4fa + cfeed91 commit fe5b30d
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 163 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Imports:
shiny.i18n (>= 0.2.0),
shiny (>= 1.3.2),
stringr (>= 1.4.0),
shinyWidgets (>= 0.2.1)
shinyWidgets (>= 0.2.1),
purrr (>= 0.3.4),
gert (>= 1.5.0)
Suggests:
knitr (>= 1.23),
readr (>= 1.3.1),
Expand Down
1 change: 0 additions & 1 deletion R/get_instance.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @return a character of the active issue in the session
#' @export
#'
#' @examples
get_instance <- function() {


Expand Down
79 changes: 19 additions & 60 deletions R/git.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,27 @@ add_upstream <- function(instance = "saved") {
# Look for instance ---------------------------------------------------------
if (instance == "saved") {

# It looks in session
if (Sys.getenv("ixplorer_instance") != "") {

instance <- Sys.getenv("ixplorer_instance")
message ("You are currently on ", instance)

# If there is no enviroment variable it means user is looking for
# a previously saved instance
} else if (Sys.getenv("ixplorer_instance") == "") {

saved_instances <- keyring::keyring_list() %>%
filter(stringr::str_detect(keyring, "ixplorer_"))

# if there are saved instances, then it chooses the instance that was last saved
if (nrow(saved_instances) > 0) {

last_saved <- saved_instances[1,1]
instance <- last_saved
message("You are currently on ", instance)

# When there are no saved instances, then a message is printed
} else {
message("There are no saved instances, try the authentication gadget")
}
instance <- get_instance()

if (instance == "none") {
stop("There are no saved instances. Try the authentication gadget")
}

# If the user chooses an instance other than "saved" then it looks for
# the specified instance in previously saved keyrings

} else {

saved_instances <- keyring::keyring_list() %>%
select(keyring) %>%
filter(keyring == paste0("ixplorer_",instance))

if (nrow(saved_instances) > 0) {

instance <- toString(saved_instances[1])

# If the instance specified was not found a message is printed
} else {
message("No credentials for ", instance)
} else {

stop("No credentials for ", instance)
}

}

# Completing the repo url ---------------------------------------------------
Expand All @@ -77,27 +55,6 @@ add_upstream <- function(instance = "saved") {
git2r::remote_add(repo = camino, name = "upstream", url = proyecto_madre)


# previous code -------------------------------------------------------------
# credentials <- tryCatch(
# keyring::key_get(paste0("token_", instance)),
# error = function(cond) "no_credentials")


# if (credentials != "no_credentials") {
# credentials <- credentials %>%
# stringr::str_split("/", simplify = TRUE) %>%
# tibble::as_tibble() %>%
# magrittr::set_names(c("url", "token",
# "user", "persistence")) %>%
# dplyr::mutate(persistence = as.logical(persistence))
#
# } else {
# stop(paste("No credentials yet for", instance))
# }
#
# if (credentials$persistence == FALSE) {
# keyring::key_delete(paste0("token_", instance))
# }
}


Expand All @@ -123,11 +80,12 @@ incluye_upstream <- function(instancia = "guardada") {


#' @title Extend git credential cache time-out
#'
#' @description Set the number of seconds before the git credential cache times
#' out. Note that this is written for work on remote servers where we do not
#' want to store our git credentials (other might have acces to it, or
#' impersonate us). On a trusted machine the most common setting would be ( on
#' a linux machine) <git credential.helper store>. However, some caching is
#' want to store our git credentials because other might have access to it, or
#' impersonate us. On a trusted machine the most common setting would be (on
#' a linux machine) git credential.helper store. However, some caching is
#' required when working on a remote server because frequent commit-push
#' cycles where you have to write out your username and password every time is
#' not nice.
Expand All @@ -153,13 +111,14 @@ set_git_timeout <- function(timeout = 14400, global = FALSE) {


#' @title Extienda el tiempo de sus credenciales de git
#' @description Esta es una función traducida que llama a set_git_timeout().
#'
#' @description Esta es una función traducida que llama a set_git_timeout.
#' Establezca la cantidad de segundos para que se agote el
#' tiempo de espera del caché de credenciales de git. Tenga en cuenta que
#' esto está escrito para trabajar en servidores remotos donde no queremos
#' almacenar nuestras credenciales de git (otros pueden tener acceso o
#' hacerse pasar por nosotros). En una máquina confiable, la configuración más
#' común sería (en una máquina Linux) <git credential.helper store>. Sin
#' común sería (en una máquina Linux) git credential.helper store. Sin
#' embargo, se requiere algo de almacenamiento en caché cuando se trabaja en
#' un servidor remoto porque los ciclos frecuentes de envío y confirmación en
#' los que tiene que escribir su nombre de usuario y contraseña cada vez no son
Expand All @@ -170,16 +129,16 @@ set_git_timeout <- function(timeout = 14400, global = FALSE) {
#' desea. También por defecto, el tiempo de espera se establece en 4 horas
#' (14400 segundos).
#'
#' @param detencion
#' @param global
#' @param detencion número de segundos antes del tiempo de espera
#' @param global si el cambio debe ser global o local para el repositorio
#'
#' @export
fijar_tiempo_credenciales <- function(pausa = 14000, global = FALSE) {

if (global == FALSE) {
set_git_timeout(tiempo = detencion, global = FALSE)
set_git_timeout(timeout = pausa, global = FALSE)
} else {
set_git_timeout(tiempo = dentencion, global = TRUE)
set_git_timeout(timeout = pausa, global = TRUE)
}

}
Expand Down
2 changes: 1 addition & 1 deletion R/list_closed_tickets.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (instance == "saved") {
instance <- get_instance()

if (instance == "none") {
stop("There are no saved instances")
stop("There are no saved instances. Try the authentication gadget")
}

} else {
Expand Down
8 changes: 5 additions & 3 deletions man/fijar_tiempo_credenciales.Rd

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

6 changes: 3 additions & 3 deletions man/set_git_timeout.Rd

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

2 changes: 1 addition & 1 deletion man/synch_branch.Rd

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

4 changes: 0 additions & 4 deletions tests/testthat.R

This file was deleted.

6 changes: 0 additions & 6 deletions tests/testthat/.ixplorer_api

This file was deleted.

6 changes: 0 additions & 6 deletions tests/testthat/.ixplorer_project

This file was deleted.

6 changes: 0 additions & 6 deletions tests/testthat/.ixplorer_repo

This file was deleted.

6 changes: 0 additions & 6 deletions tests/testthat/.ixplorer_url

This file was deleted.

6 changes: 0 additions & 6 deletions tests/testthat/.ixplorer_user

This file was deleted.

56 changes: 0 additions & 56 deletions tests/testthat/test-verify.R

This file was deleted.

Binary file added vignettes/img/clone_wiki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions vignettes/ixplorer.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,16 @@ instancia guardada en
credenciales de git en su servior remoto. El default es de 4 horas. La
función toma su tiempo en segundos.




#### Publicar un wiki

* **publica_wiki()**. Los wikis son de especial importancia cuando se quiere
documentar de manera sencilla lo que sucede en el repositorio. Para publicar un
wiki con publica_wiki(), el primer paso es crear la primera página manualmente.
Esto se logra en la pestaña de "wiki" en el repositorio.
El siguiente paso es clonar el repositorio del wiki.
Este url para clonar el wiki es diferente al que usamos para clonar el repositorio
donde encontramos nuestro código. Una vez que clonamos este repositorio podemos
usar publica_wiki().

![](img/clone_wiki.png)

10 changes: 10 additions & 0 deletions vignettes/ixplorer_en.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,17 @@ instance saved.
git credentials on your remote server. The default is 4 hours. The
function takes its time in seconds.

#### Publishing on wiki
* **publish_wiki()**: Allows you to publish a wiki in your repo from an Rmarkdown.
Wikis are especially important when you want to easily document what happens in
the repository. To publish a wiki with publish_wiki(), the first step is to create
the first page manually. This is accomplished in the "wiki" tab in the repository.
The next step is to clone the wiki repository.
This url to clone the wiki is different from the one we use to clone the
repository where we find our code. Once we clone this repository we can use
publish_wiki().

![](img/clone_wiki.png)



0 comments on commit fe5b30d

Please sign in to comment.