Created
August 19, 2024 01:15
-
-
Save jjesusfilho/da1a5873ac18ca690cdd33155225dab3 to your computer and use it in GitHub Desktop.
Obtêm tabela de commits com data e autor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Extrai tabela de commits realizados em repositório. | |
#' | |
#' @param owner Proprietário | |
#' @param repo Repositório | |
#' @param since data inicial no formato "yyyy-mm-dd". Padrão "1970-01-01" | |
#' @param until data final no formato "yyyy-mm-dd". Padrão data atual. | |
#' @param limit Número máximo de commits. Padrão para Inf. | |
#' @param ... Outros argumentos passados para `gh::gh` | |
#' | |
#' @return tibble | |
#' @export | |
#' | |
github_commits <- function(owner = NULL, | |
repo = NULL, | |
since = NULL, | |
until = NULL, | |
limit = Inf, | |
... | |
){ | |
if(is.null(since)){ | |
since <- lubridate::origin |> as.character() | |
} | |
if(is.null(until)){ | |
until <- lubridate::today() |> as.character() | |
} | |
params <- list(since = since, until = until) | |
gh::gh("/repos/{owner}/{repo}/commits", owner = owner,repo = repo, | |
.limit = limit, | |
.params = params, | |
...) |> | |
purrr::map_dfr(~{ | |
autor <- .x |> | |
purrr::pluck("commit","author","name") | |
suppressMessages( | |
data <- .x |> | |
purrr::pluck("commit","committer","date") |> | |
lubridate::as_datetime(tz = "America/Sao_Paulo") | |
) | |
mensagem <- .x |> | |
purrr::pluck("commit","message") | |
tibble::tibble(autor, data, mensagem) | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment