From caae4597ce4e1f469a31469242e6ea4f81e4bf5a Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 08:25:37 +0000 Subject: [PATCH 1/7] Replace `get_repos` with `pull_repos`. --- NAMESPACE | 4 +-- R/EngineGraphQLGitHub.R | 12 ++++---- R/EngineGraphQLGitLab.R | 12 ++++---- R/EngineRestGitHub.R | 14 ++++----- R/EngineRestGitLab.R | 18 +++++------ R/GitHost.R | 12 ++++---- R/GitStats.R | 10 +++---- R/gitstats_functions.R | 16 +++++----- man/EngineGraphQLGitHub.Rd | 20 ++++++------- man/EngineGraphQLGitLab.Rd | 20 ++++++------- man/EngineRestGitHub.Rd | 30 +++++++++---------- man/EngineRestGitLab.Rd | 30 +++++++++---------- man/GitHost.Rd | 20 ++++++------- man/GitStats.Rd | 20 ++++++------- man/{get_repos.Rd => pull_repos.Rd} | 10 +++---- ...ributors.Rd => pull_repos_contributors.Rd} | 6 ++-- .../testthat/_snaps/03-EngineGraphQLGitHub.md | 6 ++-- .../testthat/_snaps/03-EngineGraphQLGitLab.md | 4 +-- tests/testthat/_snaps/03-EngineRestGitHub.md | 8 ++--- tests/testthat/_snaps/03-EngineRestGitLab.md | 8 ++--- tests/testthat/_snaps/05-repos-functions.md | 8 ++--- tests/testthat/_snaps/GitHost.md | 8 ++--- tests/testthat/_snaps/GitStats.md | 6 ++-- tests/testthat/helper.R | 16 +++++----- tests/testthat/test-03-EngineGraphQLGitHub.R | 24 +++++++-------- tests/testthat/test-03-EngineGraphQLGitLab.R | 12 ++++---- tests/testthat/test-03-EngineRestGitHub.R | 16 +++++----- tests/testthat/test-03-EngineRestGitLab.R | 14 ++++----- tests/testthat/test-05-repos-functions.R | 8 ++--- tests/testthat/test-GitHost.R | 10 +++---- tests/testthat/test-GitStats.R | 8 ++--- 31 files changed, 205 insertions(+), 205 deletions(-) rename man/{get_repos.Rd => pull_repos.Rd} (89%) rename man/{get_repos_contributors.Rd => pull_repos_contributors.Rd} (78%) diff --git a/NAMESPACE b/NAMESPACE index e4a5b3ae..9c1def7a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,11 +3,11 @@ export("%>%") export(create_gitstats) export(get_commits) -export(get_repos) -export(get_repos_contributors) export(get_users) export(plot_commits) export(plot_repos) +export(pull_repos) +export(pull_repos_contributors) export(reset) export(reset_language) export(set_host) diff --git a/R/EngineGraphQLGitHub.R b/R/EngineGraphQLGitHub.R index 276625b1..2f97b648 100644 --- a/R/EngineGraphQLGitHub.R +++ b/R/EngineGraphQLGitHub.R @@ -45,14 +45,14 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", #' @param org An organization. #' @param settings A list of `GitStats` settings. #' @return A table. - get_repos = function(org, + pull_repos = function(org, settings) { if (settings$search_param %in% c("org", "team")) { if (settings$search_param == "org") { if (!private$scan_all) { cli::cli_alert_info("[GitHub][Engine:{cli::col_yellow('GraphQL')}][org:{org}] Pulling repositories...") } - repos_table <- private$pull_repos( + repos_table <- private$pull_repos_from_org( from = "org", org = org ) %>% @@ -83,7 +83,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", #' @param org An organization. #' @param settings A list of `GitStats` settings. #' @return Nothing. - get_repos_supportive = function(org, + pull_repos_supportive = function(org, settings) { NULL }, @@ -99,7 +99,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", date_from, date_until, settings) { - repos_table <- self$get_repos( + repos_table <- self$pull_repos( org = org, settings = list(search_param = "org") ) @@ -160,7 +160,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", # @param org An organization. # @param user A user. # @return A list of repositories from organization. - pull_repos = function(from, + pull_repos_from_org = function(from, org = NULL, user = NULL) { full_repos_list <- list() @@ -200,7 +200,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", for (member in team) { for (login in member$logins) { user_repos <- - private$pull_repos( + private$pull_repos_from_org( from = "user", user = login ) diff --git a/R/EngineGraphQLGitLab.R b/R/EngineGraphQLGitLab.R index 7a5dab06..3fd4b387 100644 --- a/R/EngineGraphQLGitLab.R +++ b/R/EngineGraphQLGitLab.R @@ -43,14 +43,14 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab", #' @param org An organization. #' @param settings A list of `GitStats` settings. #' @return A table. - get_repos = function(org, + pull_repos = function(org, settings) { org <- gsub("%2f", "/", org) if (settings$search_param == "org") { if (!private$scan_all) { cli::cli_alert_info("[GitLab][Engine:{cli::col_yellow('GraphQL')}][org:{org}] Pulling repositories...") } - repos_table <- private$pull_repos( + repos_table <- private$pull_repos_from_org( from = "org", org = org ) %>% @@ -65,7 +65,7 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab", #' @param org An organization. #' @param settings A list of `GitStats` settings. #' @return Nothing. - get_repos_supportive = function(org, + pull_repos_supportive = function(org, settings) { NULL }, @@ -94,9 +94,9 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab", # @param org An organization. # @param user A user. # @return A list of repositories from organization. - pull_repos = function(from, - org = NULL, - users = NULL) { + pull_repos_from_org = function(from, + org = NULL, + users = NULL) { full_repos_list <- list() next_page <- TRUE repo_cursor <- "" diff --git a/R/EngineRestGitHub.R b/R/EngineRestGitHub.R index 07173e86..12fb0ad6 100644 --- a/R/EngineRestGitHub.R +++ b/R/EngineRestGitHub.R @@ -8,7 +8,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", #' @param org An organization #' @param settings A list of `GitStats` settings. #' @return Table of repositories. - get_repos = function(org, + pull_repos = function(org, settings) { if (settings$search_param == "phrase") { if (!private$scan_all) { @@ -21,7 +21,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", ) %>% private$tailor_repos_info() %>% private$prepare_repos_table() %>% - private$get_repos_issues() + private$pull_repos_issues() } else { repos_table <- NULL } @@ -33,7 +33,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", #' @param org An organization. #' @param settings A list of `GitStats` settings. #' @return A table of repositories. - get_repos_supportive = function(org, + pull_repos_supportive = function(org, settings) { repos_table <- NULL if (settings$search_param %in% c("org")) { @@ -45,7 +45,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", ) %>% private$tailor_repos_info() %>% private$prepare_repos_table() %>% - private$get_repos_issues() + private$pull_repos_issues() } return(repos_table) }, @@ -76,7 +76,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", date_from, date_until = Sys.date(), settings) { - repos_table <- self$get_repos_supportive( + repos_table <- self$pull_repos_supportive( org = org, settings = list(search_param = "org") ) @@ -110,7 +110,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", #' @description A method to add information on repository contributors. #' @param repos_table A table of repositories. #' @return A table of repositories with added information on contributors. - get_repos_contributors = function(repos_table) { + pull_repos_contributors = function(repos_table) { if (nrow(repos_table) > 0) { if (!private$scan_all) { cli::cli_alert_info("[GitHub][Engine:{cli::col_green('REST')}] Pulling contributors...") @@ -320,7 +320,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", # @description A method to add information on open and closed issues of a repository. # @param repos_table A table of repositories. # @return A table of repositories with added information on issues. - get_repos_issues = function(repos_table) { + pull_repos_issues = function(repos_table) { if (nrow(repos_table) > 0) { repos_iterator <- paste0(repos_table$organization, "/", repos_table$name) issues <- purrr::map_dfr(repos_iterator, function(repo_path) { diff --git a/R/EngineRestGitLab.R b/R/EngineRestGitLab.R index 16d49f78..7400880e 100644 --- a/R/EngineRestGitLab.R +++ b/R/EngineRestGitLab.R @@ -9,7 +9,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", #' @param org A character, a group of projects. #' @param settings A list of `GitStats` settings. #' @return A table. - get_repos = function(org, + pull_repos = function(org, settings) { if (settings$search_param == "phrase") { if (!private$scan_all) { @@ -22,7 +22,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", ) %>% private$tailor_repos_info() %>% private$prepare_repos_table() %>% - private$get_repos_issues() + private$pull_repos_issues() } else if (settings$search_param == "team") { if (!private$scan_all) { cli::cli_alert_info("[GitLab][Engine:{cli::col_green('REST')}][org:{gsub('%2f', '/', org)}][team:{settings$team_name}] Pulling repositories...") @@ -31,9 +31,9 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", repos_table <- private$pull_repos_from_org(org) %>% private$tailor_repos_info() %>% private$prepare_repos_table() %>% - private$get_repos_issues() + private$pull_repos_issues() suppressMessages({ - repos_table <- self$get_repos_contributors( + repos_table <- self$pull_repos_contributors( repos_table = repos_table ) %>% private$filter_repos_by_team(team = settings$team) @@ -48,7 +48,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", #' @param org An organization. #' @param settings A list of `GitStats` settings. #' @return Nothing. - get_repos_supportive = function(org, + pull_repos_supportive = function(org, settings) { repos_table <- NULL if (settings$search_param == "org") { @@ -59,7 +59,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", repos_table <- private$pull_repos_from_org(org) %>% private$tailor_repos_info() %>% private$prepare_repos_table() %>% - private$get_repos_issues() + private$pull_repos_issues() } return(repos_table) }, @@ -67,7 +67,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", #' @description A method to add information on repository contributors. #' @param repos_table A table of repositories. #' @return A table of repositories with added information on contributors. - get_repos_contributors = function(repos_table) { + pull_repos_contributors = function(repos_table) { if (nrow(repos_table) > 0) { if (!private$scan_all) { cli::cli_alert_info("[GitLab][Engine:{cli::col_green('REST')}] Pulling contributors...") @@ -105,7 +105,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", date_from, date_until = Sys.date(), settings) { - repos_table <- self$get_repos_supportive( + repos_table <- self$pull_repos_supportive( org = org, settings = list(search_param = "org") ) @@ -280,7 +280,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", # @description A method to add information on open and closed issues of a repository. # @param repos_table A table of repositories. # @return A table of repositories with added information on issues. - get_repos_issues = function(repos_table) { + pull_repos_issues = function(repos_table) { if (nrow(repos_table) > 0) { issues <- purrr::map(repos_table$id, function(repos_id) { id <- gsub("gid://gitlab/Project/", "", repos_id) diff --git a/R/GitHost.R b/R/GitHost.R index a131dbb5..eefa9518 100644 --- a/R/GitHost.R +++ b/R/GitHost.R @@ -56,7 +56,7 @@ GitHost <- R6::R6Class("GitHost", #' @param add_contributors A boolean to decide wether to add contributors #' column to repositories table. #' @return A data.frame of repositories. - get_repos = function(settings, add_contributors = FALSE) { + pull_repos = function(settings, add_contributors = FALSE) { repos_table <- private$pull_repos_from_orgs( settings = settings ) @@ -66,7 +66,7 @@ GitHost <- R6::R6Class("GitHost", } if (add_contributors) { - repos_table <- self$get_repos_contributors(repos_table) + repos_table <- self$pull_repos_contributors(repos_table) } if (nrow(repos_table) > 0 && settings$language != "All") { @@ -82,12 +82,12 @@ GitHost <- R6::R6Class("GitHost", #' @description A method to add information on repository contributors. #' @param repos_table A table of repositories. #' @return A table of repositories with added information on contributors. - get_repos_contributors = function(repos_table) { + pull_repos_contributors = function(repos_table) { repos_table <- repos_table %>% dplyr::filter(grepl(gsub("/v+.*", "", private$api_url), api_url)) repos_table <- purrr::map_dfr(private$engines, function (engine) { if (inherits(engine, "EngineRest")) { - engine$get_repos_contributors( + engine$pull_repos_contributors( repos_table ) } else { @@ -309,7 +309,7 @@ GitHost <- R6::R6Class("GitHost", repos_table <- purrr::map(orgs, function(org) { tryCatch({ repos_list <- purrr::map(private$engines, function (engine) { - engine$get_repos( + engine$pull_repos( org = org, settings = settings ) @@ -324,7 +324,7 @@ GitHost <- R6::R6Class("GitHost", } } repos_list <<- purrr::map(private$engines, function (engine) { - engine$get_repos_supportive( + engine$pull_repos_supportive( org = org, settings = settings ) diff --git a/R/GitStats.R b/R/GitStats.R index 940b2a72..67400233 100644 --- a/R/GitStats.R +++ b/R/GitStats.R @@ -120,7 +120,7 @@ GitStats <- R6::R6Class("GitStats", #' @param add_contributors A boolean to decide whether to add contributors #' information to repositories. #' @return A data.frame of repositories - get_repos = function(add_contributors = FALSE) { + pull_repos = function(add_contributors = FALSE) { if (private$settings$search_param == "team") { if (length(private$settings$team) == 0) { cli::cli_abort("You have to specify a team first with 'set_team_member()'.") @@ -131,7 +131,7 @@ GitStats <- R6::R6Class("GitStats", } } - repos_table <- purrr::map(private$hosts, ~ .$get_repos( + repos_table <- purrr::map(private$hosts, ~ .$pull_repos( settings = private$settings, add_contributors = add_contributors )) %>% @@ -148,11 +148,11 @@ GitStats <- R6::R6Class("GitStats", #' @description A method to add information on repository contributors. #' @return A table of repositories with added information on contributors. - get_repos_contributors = function() { + pull_repos_contributors = function() { if (length(private$repos) == 0) { - cli::cli_abort("You need to pull repos first with `get_repos()`.") + cli::cli_abort("You need to pull repos first with `pull_repos()`.") } else { - private$repos <- purrr::map_dfr(private$hosts, ~ .$get_repos_contributors( + private$repos <- purrr::map_dfr(private$hosts, ~ .$pull_repos_contributors( repos_table = private$repos )) } diff --git a/R/gitstats_functions.R b/R/gitstats_functions.R index 8447dcc2..38e8d532 100644 --- a/R/gitstats_functions.R +++ b/R/gitstats_functions.R @@ -110,7 +110,7 @@ set_team_member <- function(gitstats_obj, } #' @title Get information on repositories. -#' @name get_repos +#' @name pull_repos #' @description List all repositories for an organization, a team or by a #' keyword. #' @param gitstats_obj A GitStats object. @@ -125,7 +125,7 @@ set_team_member <- function(gitstats_obj, #' `GitStats` iterates additionally over pulled repositories and reaches to #' the `contributors APIs`, which makes it slower, but gives additional #' information. The same may be achieved with running separately function -#' `get_repos_contributors()` on the `GitStats` object with the `repositories` +#' `pull_repos_contributors()` on the `GitStats` object with the `repositories` #' output. \cr\cr When pulling repositories by \bold{`team`} the parameter #' always turns to `TRUE` and pulls information on `contributors`. #' @return A `GitStats` class object with updated `$repos` field. @@ -142,22 +142,22 @@ set_team_member <- function(gitstats_obj, #' token = Sys.getenv("GITLAB_PAT_PUBLIC"), #' orgs = "mbtests" #' ) %>% -#' get_repos() +#' pull_repos() #' } #' @export -get_repos <- function(gitstats_obj, add_contributors = FALSE) { - gitstats_obj$get_repos(add_contributors = add_contributors) +pull_repos <- function(gitstats_obj, add_contributors = FALSE) { + gitstats_obj$pull_repos(add_contributors = add_contributors) return(invisible(gitstats_obj)) } #' @title Add information on contributors to your repositories. -#' @name get_repos_contributors +#' @name pull_repos_contributors #' @param gitstats_obj A GitStats object. #' @description A method to add information on repository contributors. #' @return A table of repositories with added information on contributors. #' @export -get_repos_contributors <- function(gitstats_obj) { - gitstats_obj$get_repos_contributors() +pull_repos_contributors <- function(gitstats_obj) { + gitstats_obj$pull_repos_contributors() return(invisible(gitstats_obj)) } diff --git a/man/EngineGraphQLGitHub.Rd b/man/EngineGraphQLGitHub.Rd index 7d401621..c55aea28 100644 --- a/man/EngineGraphQLGitHub.Rd +++ b/man/EngineGraphQLGitHub.Rd @@ -14,8 +14,8 @@ A class for methods wrapping GitHub's GraphQL API responses. \itemize{ \item \href{#method-new}{\code{EngineGraphQLGitHub$new()}} \item \href{#method-get_orgs}{\code{EngineGraphQLGitHub$get_orgs()}} -\item \href{#method-get_repos}{\code{EngineGraphQLGitHub$get_repos()}} -\item \href{#method-get_repos_supportive}{\code{EngineGraphQLGitHub$get_repos_supportive()}} +\item \href{#method-pull_repos}{\code{EngineGraphQLGitHub$pull_repos()}} +\item \href{#method-pull_repos_supportive}{\code{EngineGraphQLGitHub$pull_repos_supportive()}} \item \href{#method-get_commits}{\code{EngineGraphQLGitHub$get_commits()}} \item \href{#method-get_commits_supportive}{\code{EngineGraphQLGitHub$get_commits_supportive()}} \item \href{#method-clone}{\code{EngineGraphQLGitHub$clone()}} @@ -61,13 +61,13 @@ Get all groups from GitLab. } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos}{}}} -\subsection{Method \code{get_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos}{}}} +\subsection{Method \code{pull_repos()}}{ A method to retrieve all repositories for an organization in a table format. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$get_repos(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$pull_repos(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -84,12 +84,12 @@ A table. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_supportive}{}}} -\subsection{Method \code{get_repos_supportive()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_supportive}{}}} +\subsection{Method \code{pull_repos_supportive()}}{ An empty method to satisfy engine iterator. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$get_repos_supportive(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$pull_repos_supportive(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/EngineGraphQLGitLab.Rd b/man/EngineGraphQLGitLab.Rd index 482ed5ed..57e43bc2 100644 --- a/man/EngineGraphQLGitLab.Rd +++ b/man/EngineGraphQLGitLab.Rd @@ -14,8 +14,8 @@ A class for methods wrapping GitLab's GraphQL API responses. \itemize{ \item \href{#method-new}{\code{EngineGraphQLGitLab$new()}} \item \href{#method-get_orgs}{\code{EngineGraphQLGitLab$get_orgs()}} -\item \href{#method-get_repos}{\code{EngineGraphQLGitLab$get_repos()}} -\item \href{#method-get_repos_supportive}{\code{EngineGraphQLGitLab$get_repos_supportive()}} +\item \href{#method-pull_repos}{\code{EngineGraphQLGitLab$pull_repos()}} +\item \href{#method-pull_repos_supportive}{\code{EngineGraphQLGitLab$pull_repos_supportive()}} \item \href{#method-get_commits}{\code{EngineGraphQLGitLab$get_commits()}} \item \href{#method-clone}{\code{EngineGraphQLGitLab$clone()}} } @@ -60,13 +60,13 @@ Get all groups from GitLab. } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos}{}}} -\subsection{Method \code{get_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos}{}}} +\subsection{Method \code{pull_repos()}}{ A method to retrieve all repositories for an organization in a table format. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$get_repos(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$pull_repos(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -83,12 +83,12 @@ A table. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_supportive}{}}} -\subsection{Method \code{get_repos_supportive()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_supportive}{}}} +\subsection{Method \code{pull_repos_supportive()}}{ An empty method to satisfy engine iterator. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$get_repos_supportive(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$pull_repos_supportive(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/EngineRestGitHub.Rd b/man/EngineRestGitHub.Rd index 27734d27..1c9a93e6 100644 --- a/man/EngineRestGitHub.Rd +++ b/man/EngineRestGitHub.Rd @@ -12,11 +12,11 @@ A class for methods wrapping GitHub's REST API responses. \section{Methods}{ \subsection{Public methods}{ \itemize{ -\item \href{#method-get_repos}{\code{EngineRestGitHub$get_repos()}} -\item \href{#method-get_repos_supportive}{\code{EngineRestGitHub$get_repos_supportive()}} +\item \href{#method-pull_repos}{\code{EngineRestGitHub$pull_repos()}} +\item \href{#method-pull_repos_supportive}{\code{EngineRestGitHub$pull_repos_supportive()}} \item \href{#method-get_commits}{\code{EngineRestGitHub$get_commits()}} \item \href{#method-get_commits_supportive}{\code{EngineRestGitHub$get_commits_supportive()}} -\item \href{#method-get_repos_contributors}{\code{EngineRestGitHub$get_repos_contributors()}} +\item \href{#method-pull_repos_contributors}{\code{EngineRestGitHub$pull_repos_contributors()}} \item \href{#method-clone}{\code{EngineRestGitHub$clone()}} } } @@ -30,12 +30,12 @@ A class for methods wrapping GitHub's REST API responses. \out{} } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos}{}}} -\subsection{Method \code{get_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos}{}}} +\subsection{Method \code{pull_repos()}}{ Method to get repositories with phrase in code blobs. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitHub$get_repos(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitHub$pull_repos(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -52,13 +52,13 @@ Table of repositories. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_supportive}{}}} -\subsection{Method \code{get_repos_supportive()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_supportive}{}}} +\subsection{Method \code{pull_repos_supportive()}}{ An supportive method to pull repos by org in case GraphQL Engine breaks. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitHub$get_repos_supportive(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitHub$pull_repos_supportive(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -138,12 +138,12 @@ A table of commits. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_contributors}{}}} -\subsection{Method \code{get_repos_contributors()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_contributors}{}}} +\subsection{Method \code{pull_repos_contributors()}}{ A method to add information on repository contributors. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitHub$get_repos_contributors(repos_table)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitHub$pull_repos_contributors(repos_table)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/EngineRestGitLab.Rd b/man/EngineRestGitLab.Rd index 8cf27ade..253e43ea 100644 --- a/man/EngineRestGitLab.Rd +++ b/man/EngineRestGitLab.Rd @@ -12,9 +12,9 @@ A class for methods wrapping GitLab's REST API responses. \section{Methods}{ \subsection{Public methods}{ \itemize{ -\item \href{#method-get_repos}{\code{EngineRestGitLab$get_repos()}} -\item \href{#method-get_repos_supportive}{\code{EngineRestGitLab$get_repos_supportive()}} -\item \href{#method-get_repos_contributors}{\code{EngineRestGitLab$get_repos_contributors()}} +\item \href{#method-pull_repos}{\code{EngineRestGitLab$pull_repos()}} +\item \href{#method-pull_repos_supportive}{\code{EngineRestGitLab$pull_repos_supportive()}} +\item \href{#method-pull_repos_contributors}{\code{EngineRestGitLab$pull_repos_contributors()}} \item \href{#method-get_commits}{\code{EngineRestGitLab$get_commits()}} \item \href{#method-clone}{\code{EngineRestGitLab$clone()}} } @@ -29,13 +29,13 @@ A class for methods wrapping GitLab's REST API responses. \out{} } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos}{}}} -\subsection{Method \code{get_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos}{}}} +\subsection{Method \code{pull_repos()}}{ A method to retrieve all repositories for an organization in a table format. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitLab$get_repos(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitLab$pull_repos(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -52,12 +52,12 @@ A table. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_supportive}{}}} -\subsection{Method \code{get_repos_supportive()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_supportive}{}}} +\subsection{Method \code{pull_repos_supportive()}}{ An empty method to satisfy engine iterator. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitLab$get_repos_supportive(org, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitLab$pull_repos_supportive(org, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -74,12 +74,12 @@ Nothing. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_contributors}{}}} -\subsection{Method \code{get_repos_contributors()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_contributors}{}}} +\subsection{Method \code{pull_repos_contributors()}}{ A method to add information on repository contributors. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitLab$get_repos_contributors(repos_table)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitLab$pull_repos_contributors(repos_table)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/GitHost.Rd b/man/GitHost.Rd index a1088b4f..0e19daa8 100644 --- a/man/GitHost.Rd +++ b/man/GitHost.Rd @@ -12,8 +12,8 @@ A GitHost superclass \subsection{Public methods}{ \itemize{ \item \href{#method-new}{\code{GitHost$new()}} -\item \href{#method-get_repos}{\code{GitHost$get_repos()}} -\item \href{#method-get_repos_contributors}{\code{GitHost$get_repos_contributors()}} +\item \href{#method-pull_repos}{\code{GitHost$pull_repos()}} +\item \href{#method-pull_repos_contributors}{\code{GitHost$pull_repos_contributors()}} \item \href{#method-get_commits}{\code{GitHost$get_commits()}} \item \href{#method-get_users}{\code{GitHost$get_users()}} \item \href{#method-clone}{\code{GitHost$clone()}} @@ -45,13 +45,13 @@ A new \code{GitHost} object } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos}{}}} -\subsection{Method \code{get_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos}{}}} +\subsection{Method \code{pull_repos()}}{ A method to list all repositories for an organization, a team or by a keyword. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitHost$get_repos(settings, add_contributors = FALSE)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitHost$pull_repos(settings, add_contributors = FALSE)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -69,12 +69,12 @@ A data.frame of repositories. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_contributors}{}}} -\subsection{Method \code{get_repos_contributors()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_contributors}{}}} +\subsection{Method \code{pull_repos_contributors()}}{ A method to add information on repository contributors. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitHost$get_repos_contributors(repos_table)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitHost$pull_repos_contributors(repos_table)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/GitStats.Rd b/man/GitStats.Rd index b0613286..65089f84 100644 --- a/man/GitStats.Rd +++ b/man/GitStats.Rd @@ -12,8 +12,8 @@ An R6 class object with methods to derive information from multiple Git platform \item \href{#method-setup}{\code{GitStats$setup()}} \item \href{#method-set_host}{\code{GitStats$set_host()}} \item \href{#method-set_team_member}{\code{GitStats$set_team_member()}} -\item \href{#method-get_repos}{\code{GitStats$get_repos()}} -\item \href{#method-get_repos_contributors}{\code{GitStats$get_repos_contributors()}} +\item \href{#method-pull_repos}{\code{GitStats$pull_repos()}} +\item \href{#method-pull_repos_contributors}{\code{GitStats$pull_repos_contributors()}} \item \href{#method-get_commits}{\code{GitStats$get_commits()}} \item \href{#method-get_users}{\code{GitStats$get_users()}} \item \href{#method-show_orgs}{\code{GitStats$show_orgs()}} @@ -101,13 +101,13 @@ Nothing, pass information on team member to \code{GitStats}. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos}{}}} -\subsection{Method \code{get_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos}{}}} +\subsection{Method \code{pull_repos()}}{ A method to list all repositories for an organization, a team or by a keyword. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$get_repos(add_contributors = FALSE)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$pull_repos(add_contributors = FALSE)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -123,12 +123,12 @@ A data.frame of repositories } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_repos_contributors}{}}} -\subsection{Method \code{get_repos_contributors()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_repos_contributors}{}}} +\subsection{Method \code{pull_repos_contributors()}}{ A method to add information on repository contributors. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$get_repos_contributors()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$pull_repos_contributors()}\if{html}{\out{
}} } \subsection{Returns}{ diff --git a/man/get_repos.Rd b/man/pull_repos.Rd similarity index 89% rename from man/get_repos.Rd rename to man/pull_repos.Rd index a6e14aec..69eac1cd 100644 --- a/man/get_repos.Rd +++ b/man/pull_repos.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{get_repos} -\alias{get_repos} +\name{pull_repos} +\alias{pull_repos} \title{Get information on repositories.} \usage{ -get_repos(gitstats_obj, add_contributors = FALSE) +pull_repos(gitstats_obj, add_contributors = FALSE) } \arguments{ \item{gitstats_obj}{A GitStats object.} @@ -20,7 +20,7 @@ does not convey information on contributors. \cr\cr When set to \code{TRUE}, \code{GitStats} iterates additionally over pulled repositories and reaches to the \verb{contributors APIs}, which makes it slower, but gives additional information. The same may be achieved with running separately function -\code{get_repos_contributors()} on the \code{GitStats} object with the \code{repositories} +\code{pull_repos_contributors()} on the \code{GitStats} object with the \code{repositories} output. \cr\cr When pulling repositories by \bold{\code{team}} the parameter always turns to \code{TRUE} and pulls information on \code{contributors}.} } @@ -44,6 +44,6 @@ my_gitstats <- create_gitstats() \%>\% token = Sys.getenv("GITLAB_PAT_PUBLIC"), orgs = "mbtests" ) \%>\% - get_repos() + pull_repos() } } diff --git a/man/get_repos_contributors.Rd b/man/pull_repos_contributors.Rd similarity index 78% rename from man/get_repos_contributors.Rd rename to man/pull_repos_contributors.Rd index f3bb43ff..6a3e224d 100644 --- a/man/get_repos_contributors.Rd +++ b/man/pull_repos_contributors.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{get_repos_contributors} -\alias{get_repos_contributors} +\name{pull_repos_contributors} +\alias{pull_repos_contributors} \title{Add information on contributors to your repositories.} \usage{ -get_repos_contributors(gitstats_obj) +pull_repos_contributors(gitstats_obj) } \arguments{ \item{gitstats_obj}{A GitStats object.} diff --git a/tests/testthat/_snaps/03-EngineGraphQLGitHub.md b/tests/testthat/_snaps/03-EngineGraphQLGitHub.md index 5a51233d..9f933a7f 100644 --- a/tests/testthat/_snaps/03-EngineGraphQLGitHub.md +++ b/tests/testthat/_snaps/03-EngineGraphQLGitHub.md @@ -4220,17 +4220,17 @@ -# `get_repos()` works as expected +# `pull_repos()` works as expected Code - gh_repos_org <- test_gql_gh$get_repos(org = "r-world-devs", settings = settings) + gh_repos_org <- test_gql_gh$pull_repos(org = "r-world-devs", settings = settings) Message i [GitHub][Engine:GraphQL][org:r-world-devs] Pulling repositories... --- Code - gh_repos_team <- test_gql_gh$get_repos(org = "r-world-devs", settings = settings) + gh_repos_team <- test_gql_gh$pull_repos(org = "r-world-devs", settings = settings) Message i [GitHub][Engine:GraphQL][org:r-world-devs][team:] Pulling repositories... diff --git a/tests/testthat/_snaps/03-EngineGraphQLGitLab.md b/tests/testthat/_snaps/03-EngineGraphQLGitLab.md index bab86930..d587b301 100644 --- a/tests/testthat/_snaps/03-EngineGraphQLGitLab.md +++ b/tests/testthat/_snaps/03-EngineGraphQLGitLab.md @@ -1,7 +1,7 @@ -# `get_repos()` works as expected +# `pull_repos()` works as expected Code - gl_repos_org <- test_gql_gl$get_repos(org = "mbtests", settings = settings) + gl_repos_org <- test_gql_gl$pull_repos(org = "mbtests", settings = settings) Message i [GitLab][Engine:GraphQL][org:mbtests] Pulling repositories... diff --git a/tests/testthat/_snaps/03-EngineRestGitHub.md b/tests/testthat/_snaps/03-EngineRestGitHub.md index 3425a5fd..b83ee59e 100644 --- a/tests/testthat/_snaps/03-EngineRestGitHub.md +++ b/tests/testthat/_snaps/03-EngineRestGitHub.md @@ -10,18 +10,18 @@ Message i [GitHub][Engine:REST] Pulling commits stats... -# `get_repos_contributors()` adds contributors to repos table +# `pull_repos_contributors()` adds contributors to repos table Code - gh_repos_by_phrase_table <- test_rest$get_repos_contributors(test_mocker$use( + gh_repos_by_phrase_table <- test_rest$pull_repos_contributors(test_mocker$use( "gh_repos_by_phrase_table")) Message i [GitHub][Engine:REST] Pulling contributors... -# `get_repos()` works +# `pull_repos()` works Code - result <- test_rest$get_repos(org = "r-world-devs", settings = settings) + result <- test_rest$pull_repos(org = "r-world-devs", settings = settings) Message i [GitHub][Engine:REST][phrase:shiny][org:r-world-devs] Searching repositories... diff --git a/tests/testthat/_snaps/03-EngineRestGitLab.md b/tests/testthat/_snaps/03-EngineRestGitLab.md index deca82bf..8a17b10d 100644 --- a/tests/testthat/_snaps/03-EngineRestGitLab.md +++ b/tests/testthat/_snaps/03-EngineRestGitLab.md @@ -2,18 +2,18 @@ x HTTP 401 Unauthorized. -# `get_repos_contributors()` adds contributors to repos table +# `pull_repos_contributors()` adds contributors to repos table Code - gl_repos_table <- test_rest$get_repos_contributors(test_mocker$use( + gl_repos_table <- test_rest$pull_repos_contributors(test_mocker$use( "gl_repos_table")) Message i [GitLab][Engine:REST] Pulling contributors... -# `get_repos_by_phrase()` works +# `pull_repos_by_phrase()` works Code - result <- test_rest$get_repos(org = "erasmusmc-public-health", settings = settings) + result <- test_rest$pull_repos(org = "erasmusmc-public-health", settings = settings) Message i [GitLab][Engine:REST][phrase:covid][org:erasmusmc-public-health] Searching repositories... diff --git a/tests/testthat/_snaps/05-repos-functions.md b/tests/testthat/_snaps/05-repos-functions.md index 675ed26c..c4ec7880 100644 --- a/tests/testthat/_snaps/05-repos-functions.md +++ b/tests/testthat/_snaps/05-repos-functions.md @@ -1,16 +1,16 @@ -# get_repos pulls repos in the table format +# pull_repos pulls repos in the table format Code - get_repos(test_gitstats) + pull_repos(test_gitstats) Message i [GitHub][Engine:GraphQL][org:r-world-devs] Pulling repositories... i [GitHub][Engine:GraphQL][org:openpharma] Pulling repositories... i [GitLab][Engine:GraphQL][org:mbtests] Pulling repositories... -# get_repos_contributors adds contributors column to repos table +# pull_repos_contributors adds contributors column to repos table Code - get_repos_contributors(test_gitstats) + pull_repos_contributors(test_gitstats) Message i [GitHub][Engine:REST] Pulling contributors... i [GitLab][Engine:REST] Pulling contributors... diff --git a/tests/testthat/_snaps/GitHost.md b/tests/testthat/_snaps/GitHost.md index d9f1c292..3037601a 100644 --- a/tests/testthat/_snaps/GitHost.md +++ b/tests/testthat/_snaps/GitHost.md @@ -63,19 +63,19 @@ Message i Filtering by language. -# get_repos returns table of repositories +# pull_repos returns table of repositories Code - repos_table <- test_host$get_repos(settings = list(search_param = "org", + repos_table <- test_host$pull_repos(settings = list(search_param = "org", language = "All")) Message i [GitHub][Engine:GraphQL][org:openpharma] Pulling repositories... i [GitHub][Engine:GraphQL][org:r-world-devs] Pulling repositories... -# get_repos_contributors returns table with contributors +# pull_repos_contributors returns table with contributors Code - repos_table_2 <- test_host$get_repos_contributors(repos_table_1) + repos_table_2 <- test_host$pull_repos_contributors(repos_table_1) Message i [GitHub][Engine:REST] Pulling contributors... diff --git a/tests/testthat/_snaps/GitStats.md b/tests/testthat/_snaps/GitStats.md index dce1cb5b..ba9de215 100644 --- a/tests/testthat/_snaps/GitStats.md +++ b/tests/testthat/_snaps/GitStats.md @@ -47,14 +47,14 @@ Add first your hosts with `set_connection()`. -# GitStats throws error when get_repos_contributors is run with empty repos field +# GitStats throws error when pull_repos_contributors is run with empty repos field - You need to pull repos first with `get_repos()`. + You need to pull repos first with `pull_repos()`. # Add_repos_contributors adds repos contributors to repos table Code - test_gitstats$get_repos_contributors() + test_gitstats$pull_repos_contributors() Message i [GitHub][Engine:REST] Pulling contributors... i [GitLab][Engine:REST] Pulling contributors... diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index db742526..0749d981 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -220,26 +220,26 @@ expect_users_table <- function(get_user_object) { expect_gt(nrow(get_user_object), 1) } -expect_repos_table_with_contributors <- function(get_repos_object) { +expect_repos_table_with_contributors <- function(pull_repos_object) { repo_cols <- c( "id", "name", "stars", "forks", "created_at", "last_activity_at", "languages", "issues_open", "issues_closed", "organization", "repo_url", "api_url", "contributors" ) - expect_s3_class(get_repos_object, "data.frame") - expect_named(get_repos_object, repo_cols) - expect_gt(nrow(get_repos_object), 0) + expect_s3_class(pull_repos_object, "data.frame") + expect_named(pull_repos_object, repo_cols) + expect_gt(nrow(pull_repos_object), 0) } -expect_repos_table <- function(get_repos_object) { +expect_repos_table <- function(pull_repos_object) { repo_cols <- c( "id", "name", "stars", "forks", "created_at", "last_activity_at", "languages", "issues_open", "issues_closed", "organization", "repo_url", "api_url" ) - expect_s3_class(get_repos_object, "data.frame") - expect_named(get_repos_object, repo_cols) - expect_gt(nrow(get_repos_object), 0) + expect_s3_class(pull_repos_object, "data.frame") + expect_named(pull_repos_object, repo_cols) + expect_gt(nrow(pull_repos_object), 0) } expect_commits_table <- function(get_commits_object, with_stats = TRUE) { diff --git a/tests/testthat/test-03-EngineGraphQLGitHub.R b/tests/testthat/test-03-EngineGraphQLGitHub.R index 84d061f4..d68b1faa 100644 --- a/tests/testthat/test-03-EngineGraphQLGitHub.R +++ b/tests/testthat/test-03-EngineGraphQLGitHub.R @@ -47,13 +47,13 @@ test_that("`pull_repos_page_from_org()` pulls repos page from GitHub organizatio test_mocker$cache(gh_repos_page) }) -test_that("`pull_repos()` prepares formatted list", { +test_that("`pull_repos_from_org()` prepares formatted list", { mockery::stub( - test_gql_gh$pull_repos, + test_gql_gh$pull_repos_from_org, "private$pull_repos_page", test_mocker$use("gh_repos_page") ) - gh_repos_from_org <- test_gql_gh$pull_repos( + gh_repos_from_org <- test_gql_gh$pull_repos_from_org( from = "org", org = "r-world-devs" ) @@ -84,13 +84,13 @@ test_that("`pull_repos_page()` pulls repos page from GitHub user", { test_mocker$cache(gh_repos_user_page) }) -test_that("`pull_repos()` from user prepares formatted list", { +test_that("`pull_repos_from_org()` from user prepares formatted list", { mockery::stub( - test_gql_gh$pull_repos, + test_gql_gh$pull_repos_from_org, "private$pull_repos_page", test_mocker$use("gh_repos_user_page") ) - gh_repos_from_user <- test_gql_gh$pull_repos( + gh_repos_from_user <- test_gql_gh$pull_repos_from_org( from = "user", user = "maciekbanas" ) @@ -213,15 +213,15 @@ test_gql_gh <- EngineGraphQLGitHub$new( token = Sys.getenv("GITHUB_PAT") ) -test_that("`get_repos()` works as expected", { +test_that("`pull_repos()` works as expected", { mockery::stub( - test_gql_gh$get_repos, + test_gql_gh$pull_repos, "private$pull_repos", test_mocker$use("gh_repos_from_org") ) settings <- list(search_param = "org") expect_snapshot( - gh_repos_org <- test_gql_gh$get_repos( + gh_repos_org <- test_gql_gh$pull_repos( org = "r-world-devs", settings = settings ) @@ -231,7 +231,7 @@ test_that("`get_repos()` works as expected", { ) mockery::stub( - test_gql_gh$get_repos, + test_gql_gh$pull_repos, "private$pull_repos_from_team", test_mocker$use("gh_repos_from_team") ) @@ -240,7 +240,7 @@ test_that("`get_repos()` works as expected", { team = test_team ) expect_snapshot( - gh_repos_team <- test_gql_gh$get_repos( + gh_repos_team <- test_gql_gh$pull_repos( org = "r-world-devs", settings = settings ) @@ -268,7 +268,7 @@ test_that("`get_commits()` retrieves commits in the table format", { mockery::stub( test_gql_gh$get_commits, - "self$get_repos", + "self$pull_repos", repos_table ) diff --git a/tests/testthat/test-03-EngineGraphQLGitLab.R b/tests/testthat/test-03-EngineGraphQLGitLab.R index 280d379b..ecc82e3a 100644 --- a/tests/testthat/test-03-EngineGraphQLGitLab.R +++ b/tests/testthat/test-03-EngineGraphQLGitLab.R @@ -23,13 +23,13 @@ test_that("`pull_repos_page()` pulls repos page from GitLab group", { test_mocker$cache(gl_repos_page) }) -test_that("`pull_repos()` prepares formatted list", { +test_that("`pull_repos_from_org()` prepares formatted list", { mockery::stub( - test_gql_gl$pull_repos, + test_gql_gl$pull_repos_from_org, "private$pull_repos_page", test_mocker$use("gl_repos_page") ) - gl_repos_from_org <- test_gql_gl$pull_repos( + gl_repos_from_org <- test_gql_gl$pull_repos_from_org( from = "org", org = "mbtests" ) @@ -71,15 +71,15 @@ test_gql_gl <- EngineGraphQLGitLab$new( token = Sys.getenv("GITLAB_PAT_PUBLIC") ) -test_that("`get_repos()` works as expected", { +test_that("`pull_repos()` works as expected", { mockery::stub( - test_gql_gl$get_repos, + test_gql_gl$pull_repos, "private$pull_repos", test_mocker$use("gl_repos_from_org") ) settings <- list(search_param = "org") expect_snapshot( - gl_repos_org <- test_gql_gl$get_repos( + gl_repos_org <- test_gql_gl$pull_repos( org = "mbtests", settings = settings ) diff --git a/tests/testthat/test-03-EngineRestGitHub.R b/tests/testthat/test-03-EngineRestGitHub.R index 139a3438..95780006 100644 --- a/tests/testthat/test-03-EngineRestGitHub.R +++ b/tests/testthat/test-03-EngineRestGitHub.R @@ -106,10 +106,10 @@ test_that("`prepare_repos_table()` prepares repos table", { test_mocker$cache(gh_repos_by_phrase_table) }) -test_that("`get_repos_issues()` adds issues to repos table", { +test_that("`pull_repos_issues()` adds issues to repos table", { gh_repos_by_phrase_table <- test_mocker$use("gh_repos_by_phrase_table") - gh_repos_by_phrase_table <- test_rest_priv$get_repos_issues( + gh_repos_by_phrase_table <- test_rest_priv$pull_repos_issues( gh_repos_by_phrase_table ) expect_gt( @@ -207,9 +207,9 @@ test_that("`get_commits_stats()` works as expected", { # public methods -test_that("`get_repos_contributors()` adds contributors to repos table", { +test_that("`pull_repos_contributors()` adds contributors to repos table", { expect_snapshot( - gh_repos_by_phrase_table <- test_rest$get_repos_contributors( + gh_repos_by_phrase_table <- test_rest$pull_repos_contributors( test_mocker$use("gh_repos_by_phrase_table") ) ) @@ -223,9 +223,9 @@ test_that("`get_repos_contributors()` adds contributors to repos table", { test_mocker$cache(gh_repos_by_phrase_table) }) -test_that("`get_repos()` works", { +test_that("`pull_repos()` works", { mockery::stub( - test_rest$get_repos, + test_rest$pull_repos, "private$search_repos_by_phrase", test_mocker$use("gh_repos_by_phrase") ) @@ -236,7 +236,7 @@ test_that("`get_repos()` works", { ) expect_snapshot( - result <- test_rest$get_repos( + result <- test_rest$pull_repos( org = "r-world-devs", settings = settings ) @@ -248,7 +248,7 @@ test_that("`get_repos()` works", { test_that("supportive method for getting commits works", { mockery::stub( test_rest$get_commits_supportive, - "self$get_repos_supportive", + "self$pull_repos_supportive", test_mocker$use("gh_repos_table") ) mockery::stub( diff --git a/tests/testthat/test-03-EngineRestGitLab.R b/tests/testthat/test-03-EngineRestGitLab.R index e13fe165..5cf72684 100644 --- a/tests/testthat/test-03-EngineRestGitLab.R +++ b/tests/testthat/test-03-EngineRestGitLab.R @@ -156,9 +156,9 @@ test_that("`prepare_commits_table()` prepares table of commits properly", { ) }) -test_that("`get_repos_issues()` adds issues to repos table", { +test_that("`pull_repos_issues()` adds issues to repos table", { gl_repos_by_phrase_table <- test_mocker$use("gl_repos_by_phrase_table") - gl_repos_by_phrase_table <- test_rest_priv$get_repos_issues( + gl_repos_by_phrase_table <- test_rest_priv$pull_repos_issues( gl_repos_by_phrase_table ) expect_gt( @@ -174,9 +174,9 @@ test_that("`get_repos_issues()` adds issues to repos table", { # public methods -test_that("`get_repos_contributors()` adds contributors to repos table", { +test_that("`pull_repos_contributors()` adds contributors to repos table", { expect_snapshot( - gl_repos_table <- test_rest$get_repos_contributors( + gl_repos_table <- test_rest$pull_repos_contributors( test_mocker$use("gl_repos_table") ) ) @@ -190,9 +190,9 @@ test_that("`get_repos_contributors()` adds contributors to repos table", { test_mocker$cache(gl_repos_table) }) -test_that("`get_repos_by_phrase()` works", { +test_that("`pull_repos_by_phrase()` works", { mockery::stub( - test_rest$get_repos, + test_rest$pull_repos, "private$search_repos_by_phrase", test_mocker$use("gl_repos_by_phrase") ) @@ -202,7 +202,7 @@ test_that("`get_repos_by_phrase()` works", { phrase = "covid" ) expect_snapshot( - result <- test_rest$get_repos( + result <- test_rest$pull_repos( org = "erasmusmc-public-health", settings = settings ) diff --git a/tests/testthat/test-05-repos-functions.R b/tests/testthat/test-05-repos-functions.R index e65414ed..18693649 100644 --- a/tests/testthat/test-05-repos-functions.R +++ b/tests/testthat/test-05-repos-functions.R @@ -1,16 +1,16 @@ test_gitstats <- create_test_gitstats(hosts = 2) -test_that("get_repos pulls repos in the table format", { +test_that("pull_repos pulls repos in the table format", { expect_snapshot( - get_repos(test_gitstats) + pull_repos(test_gitstats) ) repos_table <- test_gitstats$show_repos() expect_repos_table(repos_table) }) -test_that("get_repos_contributors adds contributors column to repos table", { +test_that("pull_repos_contributors adds contributors column to repos table", { expect_snapshot( - get_repos_contributors( + pull_repos_contributors( test_gitstats ) ) diff --git a/tests/testthat/test-GitHost.R b/tests/testthat/test-GitHost.R index 003a05d5..1eac245d 100644 --- a/tests/testthat/test-GitHost.R +++ b/tests/testthat/test-GitHost.R @@ -291,14 +291,14 @@ test_host <- create_testhost( orgs = c("openpharma", "r-world-devs") ) -test_that("get_repos returns table of repositories", { +test_that("pull_repos returns table of repositories", { mockery::stub( - test_host$get_repos, + test_host$pull_repos, "private$pull_repos_from_org", test_mocker$use("gh_repos_table") ) expect_snapshot( - repos_table <- test_host$get_repos( + repos_table <- test_host$pull_repos( settings = list(search_param = "org", language = "All") ) @@ -308,11 +308,11 @@ test_that("get_repos returns table of repositories", { ) }) -test_that("get_repos_contributors returns table with contributors", { +test_that("pull_repos_contributors returns table with contributors", { repos_table_1 <- test_mocker$use("gh_repos_table") expect_snapshot( - repos_table_2 <- test_host$get_repos_contributors(repos_table_1) + repos_table_2 <- test_host$pull_repos_contributors(repos_table_1) ) expect_repos_table_with_contributors(repos_table_2) expect_gt( diff --git a/tests/testthat/test-GitStats.R b/tests/testthat/test-GitStats.R index 67b2dd2c..f9e13523 100644 --- a/tests/testthat/test-GitStats.R +++ b/tests/testthat/test-GitStats.R @@ -57,20 +57,20 @@ test_that("GitStats get users info", { test_gitstats <- create_test_gitstats(hosts = 2) -test_that("GitStats throws error when get_repos_contributors is run with empty repos field", { +test_that("GitStats throws error when pull_repos_contributors is run with empty repos field", { expect_snapshot_error( - test_gitstats$get_repos_contributors() + test_gitstats$pull_repos_contributors() ) }) test_that("Add_repos_contributors adds repos contributors to repos table", { suppressMessages({ - test_gitstats$get_repos() + test_gitstats$pull_repos() }) repos_without_contributors <- test_gitstats$show_repos() expect_snapshot( - test_gitstats$get_repos_contributors() + test_gitstats$pull_repos_contributors() ) repos_with_contributors <- test_gitstats$show_repos() expect_repos_table_with_contributors(repos_with_contributors) From cc7f647e44f96bf6b4a990c5a1793fd96e5ad61b Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 09:48:13 +0000 Subject: [PATCH 2/7] Change function names. --- DESCRIPTION | 2 +- NAMESPACE | 6 +-- NEWS.md | 7 +-- R/EngineGraphQL.R | 2 +- R/EngineGraphQLGitHub.R | 6 +-- R/EngineGraphQLGitLab.R | 4 +- R/EngineRestGitHub.R | 8 ++-- R/EngineRestGitLab.R | 2 +- R/GitHost.R | 14 +++--- R/GitStats.R | 12 ++--- R/gitstats_functions.R | 30 ++++++------ README.Rmd | 2 +- README.md | 2 +- devel/example_workflow.R | 48 +++++++++++-------- man/EngineGraphQL.Rd | 10 ++-- man/EngineGraphQLGitHub.Rd | 32 ++++++------- man/EngineGraphQLGitLab.Rd | 22 ++++----- man/EngineRestGitHub.Rd | 25 ++++++---- man/EngineRestGitLab.Rd | 15 ++++-- man/GitHost.Rd | 20 ++++---- man/GitStats.Rd | 30 ++++++------ man/{get_commits.Rd => pull_commits.Rd} | 10 ++-- man/{get_users.Rd => pull_users.Rd} | 8 ++-- man/{setup.Rd => set_params.Rd} | 8 ++-- .../testthat/_snaps/03-EngineGraphQLGitHub.md | 4 +- tests/testthat/_snaps/03-EngineRestGitHub.md | 6 +-- tests/testthat/_snaps/03-EngineRestGitLab.md | 4 +- tests/testthat/_snaps/GitStats.md | 2 +- tests/testthat/_snaps/get_users.md | 4 +- ...s-functions.md => pull_repos-functions.md} | 0 .../_snaps/{setup.md => set_params.md} | 6 +-- tests/testthat/helper.R | 18 +++---- tests/testthat/test-03-EngineGraphQLGitHub.R | 10 ++-- tests/testthat/test-03-EngineRestGitHub.R | 14 +++--- tests/testthat/test-03-EngineRestGitLab.R | 6 +-- tests/testthat/test-04-EngineGraphQL.R | 8 ++-- tests/testthat/test-GitHost.R | 2 +- tests/testthat/test-GitStats.R | 4 +- ...unctions.R => test-pull_repos-functions.R} | 0 .../{test-get_users.R => test-pull_users.R} | 8 ++-- tests/testthat/test-reset.R | 36 ++++++++------ .../{test-setup.R => test-set_params.R} | 18 +++---- tests/testthat/test-set_team_member.R | 2 +- 43 files changed, 250 insertions(+), 227 deletions(-) rename man/{get_commits.Rd => pull_commits.Rd} (84%) rename man/{get_users.Rd => pull_users.Rd} (84%) rename man/{setup.Rd => set_params.Rd} (92%) rename tests/testthat/_snaps/{05-repos-functions.md => pull_repos-functions.md} (100%) rename tests/testthat/_snaps/{setup.md => set_params.md} (87%) rename tests/testthat/{test-05-repos-functions.R => test-pull_repos-functions.R} (100%) rename tests/testthat/{test-get_users.R => test-pull_users.R} (78%) rename tests/testthat/{test-setup.R => test-set_params.R} (83%) diff --git a/DESCRIPTION b/DESCRIPTION index ccaf8467..f3e97033 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: GitStats Title: Get Statistics from Git Hosting Services -Version: 0.1.0.9004 +Version: 0.1.0.9005 Authors@R: c( person(given = "Maciej", family = "Banaś", email = "banasmaciek@gmail.com", role = c("aut", "cre")), person(given = "Kamil", family = "Koziej", email = "koziej.k@gmail.com", role = "aut"), diff --git a/NAMESPACE b/NAMESPACE index 9c1def7a..820beedf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,17 +2,17 @@ export("%>%") export(create_gitstats) -export(get_commits) -export(get_users) export(plot_commits) export(plot_repos) +export(pull_commits) export(pull_repos) export(pull_repos_contributors) +export(pull_users) export(reset) export(reset_language) export(set_host) +export(set_params) export(set_team_member) -export(setup) export(show_commits) export(show_orgs) export(show_repos) diff --git a/NEWS.md b/NEWS.md index 88b4641c..92263c4f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,11 @@ +GitStats (development version) -GitStats 0.1.0.9004 - +- changed names of `get_*` to `pull_*` functions (I: #294), +- changed name of `setup` to `set_params` function (I: #294), - set new name for `set_connection` function: `set_host` as it is more informative (and shorter) (I: #271), - changed name of a function: `add_team_member` to `set_team_member` (I: #271), - added setting tokens by default - if a user does have all the PATs set up in environment variables (as e.g. `GITHUB_PAT` or `GITLAB_PAT`), there is no need to pass them as an arugment to `set_connection` (I: #120 PR: #268), -- added `get_users()` function to pull information on users (I: #199 PR: #238), +- added `pull_users()` function to pull information on users (I: #199 PR: #238), - added possibility of scanning whole internal git platforms if no `orgs` are passed (I: #258), - added switching to REST engine in case GraphQL fails with 502 error (I: #225 PRs: #227 (for repos) #261 (for commits)) - added `show_orgs()` function to print all organizations (I: #283), diff --git a/R/EngineGraphQL.R b/R/EngineGraphQL.R index 56fc46e7..18b013bb 100644 --- a/R/EngineGraphQL.R +++ b/R/EngineGraphQL.R @@ -39,7 +39,7 @@ EngineGraphQL <- R6::R6Class("EngineGraphQL", #' @description Get information on users in the form of table #' @param users A character vector of users #' @return A table - get_users = function(users) { + pull_users = function(users) { purrr::map(users, function(user) { private$pull_user(username = user) %>% private$prepare_user_table() diff --git a/R/EngineGraphQLGitHub.R b/R/EngineGraphQLGitHub.R index 2f97b648..511b9ed7 100644 --- a/R/EngineGraphQLGitHub.R +++ b/R/EngineGraphQLGitHub.R @@ -21,7 +21,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", }, #' @description Get all groups from GitLab. - get_orgs = function() { + pull_orgs = function() { end_cursor <- NULL has_next_page <- TRUE full_orgs_list <- list() @@ -95,7 +95,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A table of commits. - get_commits = function(org, + pull_commits = function(org, date_from, date_until, settings) { @@ -146,7 +146,7 @@ EngineGraphQLGitHub <- R6::R6Class("EngineGraphQLGitHub", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A table of commits. - get_commits_supportive = function(org, + pull_commits_supportive = function(org, date_from, date_until = Sys.date(), settings) { diff --git a/R/EngineGraphQLGitLab.R b/R/EngineGraphQLGitLab.R index 3fd4b387..72020e1a 100644 --- a/R/EngineGraphQLGitLab.R +++ b/R/EngineGraphQLGitLab.R @@ -20,7 +20,7 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab", }, #' @description Get all groups from GitLab. - get_orgs = function() { + pull_orgs = function() { group_cursor <- "" has_next_page <- TRUE full_orgs_list <- list() @@ -79,7 +79,7 @@ EngineGraphQLGitLab <- R6::R6Class("EngineGraphQLGitLab", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A table of commits. - get_commits = function(org, + pull_commits = function(org, date_from, date_until = Sys.date(), settings) { diff --git a/R/EngineRestGitHub.R b/R/EngineRestGitHub.R index 12fb0ad6..21d2bd28 100644 --- a/R/EngineRestGitHub.R +++ b/R/EngineRestGitHub.R @@ -59,7 +59,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A table of commits. - get_commits = function(org, + pull_commits = function(org, date_from, date_until = Sys.date(), settings) { @@ -72,7 +72,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A table of commits. - get_commits_supportive = function(org, + pull_commits_supportive = function(org, date_from, date_until = Sys.date(), settings) { @@ -102,7 +102,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", commits_table <- repos_list_with_commits %>% private$tailor_commits_info(org = org) %>% private$prepare_commits_table() %>% - private$get_commits_stats() + private$pull_commits_stats() return(commits_table) }, @@ -474,7 +474,7 @@ EngineRestGitHub <- R6::R6Class("EngineRestGitHub", # @description A wrapper to pull stats for all commits. # @param commits_table A table with commits. # @return A data.frame - get_commits_stats = function(commits_table) { + pull_commits_stats = function(commits_table) { cli::cli_alert_info("[GitHub][Engine:{cli::col_green('REST')}] Pulling commits stats...") repo_fullnames <- paste0(commits_table$organization, "/", commits_table$repository) commit_stats <- purrr::map2_dfr(commits_table$id, repo_fullnames, diff --git a/R/EngineRestGitLab.R b/R/EngineRestGitLab.R index 7400880e..34f1363c 100644 --- a/R/EngineRestGitLab.R +++ b/R/EngineRestGitLab.R @@ -101,7 +101,7 @@ EngineRestGitLab <- R6::R6Class("EngineRestGitLab", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A table of commits. - get_commits = function(org, + pull_commits = function(org, date_from, date_until = Sys.date(), settings) { diff --git a/R/GitHost.R b/R/GitHost.R index eefa9518..90c63f2a 100644 --- a/R/GitHost.R +++ b/R/GitHost.R @@ -44,7 +44,7 @@ GitHost <- R6::R6Class("GitHost", private$engines$graphql <- private$setup_engine(type = "graphql") if (private$scan_all) { cli::cli_alert_info("[{private$host}][Engine:{cli::col_yellow('GraphQL')}] Pulling all organizations...") - private$orgs <- private$engines$graphql$get_orgs() + private$orgs <- private$engines$graphql$pull_orgs() } else { private$orgs <- private$engines$rest$check_organizations(orgs) } @@ -101,13 +101,13 @@ GitHost <- R6::R6Class("GitHost", #' @param date_until An end date to look commits for. #' @param settings A list of `GitStats` settings. #' @return A data.frame of commits - get_commits = function(date_from, + pull_commits = function(date_from, date_until = Sys.Date(), settings) { if (settings$search_param == "phrase") { cli::cli_abort(c( "x" = "Pulling commits by phrase in code blobs is not supported.", - "i" = "Please change your `search_param` either to 'org' or 'team' with `setup()`." + "i" = "Please change your `search_param` either to 'org' or 'team' with `set_params()`." )) } if (private$scan_all) { @@ -115,7 +115,7 @@ GitHost <- R6::R6Class("GitHost", } commits_table <- purrr::map(private$orgs, function(org) { tryCatch({ - commits_table_org <- purrr::map(private$engines, ~ .$get_commits( + commits_table_org <- purrr::map(private$engines, ~ .$pull_commits( org = org, date_from = date_from, date_until = date_until, @@ -132,7 +132,7 @@ GitHost <- R6::R6Class("GitHost", } cli::cli_alert_info("Switching to REST engine.") commits_table_org <<- purrr::map(private$engines, function (engine) { - engine$get_commits_supportive( + engine$pull_commits_supportive( org = org, date_from = date_from, date_until = date_until, @@ -154,10 +154,10 @@ GitHost <- R6::R6Class("GitHost", #' @description Get information about users #' @param users A character vector of users #' @return Table of users - get_users = function(users) { + pull_users = function(users) { users_table <- purrr::map(private$engines, function(engine) { if (inherits(engine, "EngineGraphQL")) { - engine$get_users(users) + engine$pull_users(users) } else { NULL } diff --git a/R/GitStats.R b/R/GitStats.R index 67400233..a2f8c197 100644 --- a/R/GitStats.R +++ b/R/GitStats.R @@ -19,7 +19,7 @@ GitStats <- R6::R6Class("GitStats", #' @param print_out A boolean stating if you want to print output after #' pulling. #' @return Nothing. - setup = function(search_param, + set_params = function(search_param, team_name, phrase, language, @@ -162,7 +162,7 @@ GitStats <- R6::R6Class("GitStats", #' @param date_from A starting date to look commits for #' @param date_until An end date to look commits for #' @return A data.frame of commits - get_commits = function(date_from, + pull_commits = function(date_from, date_until) { if (is.null(date_from)) { stop("You need to define `date_from`.", call. = FALSE) @@ -175,7 +175,7 @@ GitStats <- R6::R6Class("GitStats", } commits_table <- purrr::map(private$hosts, function(host) { - commits_table_host <- host$get_commits( + commits_table_host <- host$pull_commits( date_from = date_from, date_until = date_until, settings = private$settings @@ -201,10 +201,10 @@ GitStats <- R6::R6Class("GitStats", #' @description Get information on users. #' @param users Character vector of users. #' @return A data.frame of users. - get_users = function(users) { + pull_users = function(users) { private$check_for_host() users_table <- purrr::map(private$hosts, function(host) { - host$get_users(users) + host$pull_users(users) }) %>% unique() %>% purrr::list_rbind() @@ -305,7 +305,7 @@ GitStats <- R6::R6Class("GitStats", # @description Helper to check if there are any hosts check_for_host = function() { if (length(private$hosts) == 0) { - cli::cli_abort("Add first your hosts with `set_connection()`.") + cli::cli_abort("Add first your hosts with `set_host()`.") } }, diff --git a/R/gitstats_functions.R b/R/gitstats_functions.R index 38e8d532..2bcef453 100644 --- a/R/gitstats_functions.R +++ b/R/gitstats_functions.R @@ -49,7 +49,7 @@ set_host <- function(gitstats_obj, } #' @title Set up your search settings. -#' @name setup +#' @name set_params #' @param gitstats_obj A GitStats object. #' @param search_param One of three: team, orgs or phrase. #' @param team_name Name of a team. @@ -60,20 +60,20 @@ set_host <- function(gitstats_obj, #' @examples #' \dontrun{ #' my_gitstats <- create_gitstats() %>% -#' setup( +#' set_params( #' search_param = "team", #' team_name = "Avengers", #' language = "R" #' ) #' } #' @export -setup <- function(gitstats_obj, +set_params <- function(gitstats_obj, search_param = NULL, team_name = NULL, phrase = NULL, language = "All", print_out = TRUE) { - gitstats_obj$setup( + gitstats_obj$set_params( search_param = search_param, team_name = team_name, phrase = phrase, @@ -162,7 +162,7 @@ pull_repos_contributors <- function(gitstats_obj) { } #' @title Get information on commits. -#' @name get_commits +#' @name pull_commits #' @description List all repositories for an organization, a team. #' @param gitstats_obj A GitStats object. #' @param date_from A starting date to look commits for @@ -181,18 +181,18 @@ pull_repos_contributors <- function(gitstats_obj) { #' token = Sys.getenv("GITLAB_PAT_PUBLIC"), #' orgs = "mbtests" #' ) %>% -#' setup( +#' set_params( #' search_param = "team", #' team_name = "rwdevs" #' ) %>% #' set_team_member("Maciej Banaś", "maciekbanas") %>% -#' get_commits(date_from = "2018-01-01") +#' pull_commits(date_from = "2018-01-01") #' } #' @export -get_commits <- function(gitstats_obj, +pull_commits <- function(gitstats_obj, date_from = NULL, date_until = Sys.time()) { - gitstats_obj$get_commits( + gitstats_obj$pull_commits( date_from = date_from, date_until = date_until ) @@ -201,7 +201,7 @@ get_commits <- function(gitstats_obj, } #' @title Get users statistics. -#' @name get_users +#' @name pull_users #' @description Get information on users. #' @param gitstats_obj A GitStats object. #' @param users A character vector of users. @@ -218,13 +218,13 @@ get_commits <- function(gitstats_obj, #' token = Sys.getenv("GITLAB_PAT_PUBLIC"), #' orgs = "mbtests" #' ) %>% -#' get_users(c("maciekabanas", "marcinkowskak")) +#' pull_users(c("maciekabanas", "marcinkowskak")) #' } #' @return A table of users. #' @export -get_users <- function(gitstats_obj, +pull_users <- function(gitstats_obj, users){ - gitstats_obj$get_users( + gitstats_obj$pull_users( users = users ) return(invisible(gitstats_obj)) @@ -238,7 +238,7 @@ get_users <- function(gitstats_obj, #' @return A GitStats object. #' @export reset <- function(gitstats_obj){ - priv <- environment(gitstats_obj$setup)$private + priv <- environment(gitstats_obj$set_params)$private priv$settings <- list( search_param = "org", phrase = NULL, @@ -258,7 +258,7 @@ reset <- function(gitstats_obj){ #' @return A GitStats object. #' @export reset_language <- function(gitstats_obj){ - priv <- environment(gitstats_obj$setup)$private + priv <- environment(gitstats_obj$set_params)$private priv$settings$language <- "All" cli::cli_alert_info("Setting language parameter to 'All'.") return(gitstats_obj) diff --git a/README.Rmd b/README.Rmd index 6f32db11..4816f6f1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -75,7 +75,7 @@ setup(git_stats, # now pull repos and commits by default by team get_repos(git_stats) -get_commits(git_stats, +pull_commits(git_stats, date_from = "2023-01-01", date_until = "2023-03-31" ) diff --git a/README.md b/README.md index 57b4d85a..c0ffa8ec 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ get_repos(git_stats) #> $ api_url "https://api.github.com/repositories/r-world-devs/Git… #> $ contributors "maciekbanas, Cotau", "krystian8207", "krystian8207, … -get_commits(git_stats, +pull_commits(git_stats, date_from = "2023-01-01", date_until = "2023-03-31" ) diff --git a/devel/example_workflow.R b/devel/example_workflow.R index a6be4e11..8db60881 100644 --- a/devel/example_workflow.R +++ b/devel/example_workflow.R @@ -15,18 +15,20 @@ git_stats <- create_gitstats() %>% git_stats # examples for getting repos (default search parameter is 'org') -get_repos(git_stats) -get_repos_contributors(git_stats) +pull_repos(git_stats) +pull_repos_contributors(git_stats) dplyr::glimpse(show_repos(git_stats)) -get_repos(git_stats, add_contributors = TRUE) +pull_repos(git_stats, add_contributors = TRUE) -get_commits(git_stats, date_from = "2022-01-01") +pull_commits(git_stats, date_from = "2022-01-01") # setup your language you are interested in -setup(git_stats, - language = "Python") -get_repos(git_stats) +set_params( + git_stats, + language = "Python" +) +pull_repos(git_stats) # set your team members git_stats %>% @@ -38,43 +40,47 @@ git_stats %>% set_team_member("Maciej Banaś", "maciekbanas") # You can set your search preferences -setup(git_stats, - search_param = "team", - team_name = "RWD", - language = "R") +set_params( + git_stats, + search_param = "team", + team_name = "RWD", + language = "R" +) # now pull repos by default by team -get_repos(git_stats) -git_stats$show_repos() -get_commits(git_stats, date_from = "2020-01-01") +pull_repos(git_stats) +show_repos(git_stats) +pull_commits(git_stats, date_from = "2020-01-01") reset_language(git_stats) # Change your settings to searches by phrase: -setup(git_stats, - search_param = "phrase", - phrase = "shiny") +set_params( + git_stats, + search_param = "phrase", + phrase = "shiny" +) # Search by phrase -get_repos(git_stats) +pull_repos(git_stats) # you can plot repos sorted by last activity plot_repos(git_stats) # error should pop out when search param set to 'phrase': -get_commits(git_stats, date_from = "2020-01-01") +pull_commits(git_stats, date_from = "2020-01-01") reset(git_stats) # now it should work -get_commits(git_stats, date_from = "2020-01-01") +pull_commits(git_stats, date_from = "2020-01-01") # examples for plotting commits plot_commits(git_stats) # get information on users git_stats %>% - get_users(c("maciekbanas", "kalimu", "marcinkowskak", "Cotau", "krystian8207")) + pull_users(c("maciekbanas", "kalimu", "marcinkowskak", "Cotau", "krystian8207")) git_stats$show_users() # SHOWCASES diff --git a/man/EngineGraphQL.Rd b/man/EngineGraphQL.Rd index da8c6b09..f32b66b4 100644 --- a/man/EngineGraphQL.Rd +++ b/man/EngineGraphQL.Rd @@ -20,7 +20,7 @@ A class for methods wrapping GitHub's GraphQL API responses. \itemize{ \item \href{#method-new}{\code{EngineGraphQL$new()}} \item \href{#method-gql_response}{\code{EngineGraphQL$gql_response()}} -\item \href{#method-get_users}{\code{EngineGraphQL$get_users()}} +\item \href{#method-pull_users}{\code{EngineGraphQL$pull_users()}} \item \href{#method-clone}{\code{EngineGraphQL$clone()}} } } @@ -68,12 +68,12 @@ A list. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_users}{}}} -\subsection{Method \code{get_users()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_users}{}}} +\subsection{Method \code{pull_users()}}{ Get information on users in the form of table \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQL$get_users(users)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQL$pull_users(users)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/EngineGraphQLGitHub.Rd b/man/EngineGraphQLGitHub.Rd index c55aea28..316c0a65 100644 --- a/man/EngineGraphQLGitHub.Rd +++ b/man/EngineGraphQLGitHub.Rd @@ -13,19 +13,19 @@ A class for methods wrapping GitHub's GraphQL API responses. \subsection{Public methods}{ \itemize{ \item \href{#method-new}{\code{EngineGraphQLGitHub$new()}} -\item \href{#method-get_orgs}{\code{EngineGraphQLGitHub$get_orgs()}} +\item \href{#method-pull_orgs}{\code{EngineGraphQLGitHub$pull_orgs()}} \item \href{#method-pull_repos}{\code{EngineGraphQLGitHub$pull_repos()}} \item \href{#method-pull_repos_supportive}{\code{EngineGraphQLGitHub$pull_repos_supportive()}} -\item \href{#method-get_commits}{\code{EngineGraphQLGitHub$get_commits()}} -\item \href{#method-get_commits_supportive}{\code{EngineGraphQLGitHub$get_commits_supportive()}} +\item \href{#method-pull_commits}{\code{EngineGraphQLGitHub$pull_commits()}} +\item \href{#method-pull_commits_supportive}{\code{EngineGraphQLGitHub$pull_commits_supportive()}} \item \href{#method-clone}{\code{EngineGraphQLGitHub$clone()}} } } \if{html}{ \out{
Inherited methods} \itemize{ -\item \out{}\href{../../GitStats/html/EngineGraphQL.html#method-get_users}{\code{GitStats::EngineGraphQL$get_users()}}\out{} \item \out{}\href{../../GitStats/html/EngineGraphQL.html#method-gql_response}{\code{GitStats::EngineGraphQL$gql_response()}}\out{} +\item \out{}\href{../../GitStats/html/EngineGraphQL.html#method-pull_users}{\code{GitStats::EngineGraphQL$pull_users()}}\out{} } \out{
} } @@ -51,12 +51,12 @@ Create \code{EngineGraphQLGitHub} object. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_orgs}{}}} -\subsection{Method \code{get_orgs()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_orgs}{}}} +\subsection{Method \code{pull_orgs()}}{ Get all groups from GitLab. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$get_orgs()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$pull_orgs()}\if{html}{\out{
}} } } @@ -106,13 +106,13 @@ Nothing. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits}{}}} -\subsection{Method \code{get_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits}{}}} +\subsection{Method \code{pull_commits()}}{ Method to pull all commits from organization, optionally filtered by team members. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$get_commits(org, date_from, date_until, settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$pull_commits(org, date_from, date_until, settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -133,12 +133,12 @@ A table of commits. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits_supportive}{}}} -\subsection{Method \code{get_commits_supportive()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits_supportive}{}}} +\subsection{Method \code{pull_commits_supportive()}}{ Method to get commits. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$get_commits_supportive( +\if{html}{\out{
}}\preformatted{EngineGraphQLGitHub$pull_commits_supportive( org, date_from, date_until = Sys.date(), diff --git a/man/EngineGraphQLGitLab.Rd b/man/EngineGraphQLGitLab.Rd index 57e43bc2..1ef48f85 100644 --- a/man/EngineGraphQLGitLab.Rd +++ b/man/EngineGraphQLGitLab.Rd @@ -13,18 +13,18 @@ A class for methods wrapping GitLab's GraphQL API responses. \subsection{Public methods}{ \itemize{ \item \href{#method-new}{\code{EngineGraphQLGitLab$new()}} -\item \href{#method-get_orgs}{\code{EngineGraphQLGitLab$get_orgs()}} +\item \href{#method-pull_orgs}{\code{EngineGraphQLGitLab$pull_orgs()}} \item \href{#method-pull_repos}{\code{EngineGraphQLGitLab$pull_repos()}} \item \href{#method-pull_repos_supportive}{\code{EngineGraphQLGitLab$pull_repos_supportive()}} -\item \href{#method-get_commits}{\code{EngineGraphQLGitLab$get_commits()}} +\item \href{#method-pull_commits}{\code{EngineGraphQLGitLab$pull_commits()}} \item \href{#method-clone}{\code{EngineGraphQLGitLab$clone()}} } } \if{html}{ \out{
Inherited methods} \itemize{ -\item \out{}\href{../../GitStats/html/EngineGraphQL.html#method-get_users}{\code{GitStats::EngineGraphQL$get_users()}}\out{} \item \out{}\href{../../GitStats/html/EngineGraphQL.html#method-gql_response}{\code{GitStats::EngineGraphQL$gql_response()}}\out{} +\item \out{}\href{../../GitStats/html/EngineGraphQL.html#method-pull_users}{\code{GitStats::EngineGraphQL$pull_users()}}\out{} } \out{
} } @@ -50,12 +50,12 @@ Create \code{EngineGraphQLGitLab} object. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_orgs}{}}} -\subsection{Method \code{get_orgs()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_orgs}{}}} +\subsection{Method \code{pull_orgs()}}{ Get all groups from GitLab. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$get_orgs()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$pull_orgs()}\if{html}{\out{
}} } } @@ -105,12 +105,12 @@ Nothing. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits}{}}} -\subsection{Method \code{get_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits}{}}} +\subsection{Method \code{pull_commits()}}{ Method to get commits. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$get_commits( +\if{html}{\out{
}}\preformatted{EngineGraphQLGitLab$pull_commits( org, date_from, date_until = Sys.date(), diff --git a/man/EngineRestGitHub.Rd b/man/EngineRestGitHub.Rd index 1c9a93e6..bdb9cfa1 100644 --- a/man/EngineRestGitHub.Rd +++ b/man/EngineRestGitHub.Rd @@ -14,8 +14,8 @@ A class for methods wrapping GitHub's REST API responses. \itemize{ \item \href{#method-pull_repos}{\code{EngineRestGitHub$pull_repos()}} \item \href{#method-pull_repos_supportive}{\code{EngineRestGitHub$pull_repos_supportive()}} -\item \href{#method-get_commits}{\code{EngineRestGitHub$get_commits()}} -\item \href{#method-get_commits_supportive}{\code{EngineRestGitHub$get_commits_supportive()}} +\item \href{#method-pull_commits}{\code{EngineRestGitHub$pull_commits()}} +\item \href{#method-pull_commits_supportive}{\code{EngineRestGitHub$pull_commits_supportive()}} \item \href{#method-pull_repos_contributors}{\code{EngineRestGitHub$pull_repos_contributors()}} \item \href{#method-clone}{\code{EngineRestGitHub$clone()}} } @@ -75,12 +75,17 @@ A table of repositories. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits}{}}} -\subsection{Method \code{get_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits}{}}} +\subsection{Method \code{pull_commits()}}{ Method to get commits. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitHub$get_commits(org, date_from, date_until = Sys.date(), settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitHub$pull_commits( + org, + date_from, + date_until = Sys.date(), + settings +)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -107,12 +112,12 @@ A table of commits. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits_supportive}{}}} -\subsection{Method \code{get_commits_supportive()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits_supportive}{}}} +\subsection{Method \code{pull_commits_supportive()}}{ A suportive method to get commits, run when GraphQL fails. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitHub$get_commits_supportive( +\if{html}{\out{
}}\preformatted{EngineRestGitHub$pull_commits_supportive( org, date_from, date_until = Sys.date(), diff --git a/man/EngineRestGitLab.Rd b/man/EngineRestGitLab.Rd index 253e43ea..aa6242f0 100644 --- a/man/EngineRestGitLab.Rd +++ b/man/EngineRestGitLab.Rd @@ -15,7 +15,7 @@ A class for methods wrapping GitLab's REST API responses. \item \href{#method-pull_repos}{\code{EngineRestGitLab$pull_repos()}} \item \href{#method-pull_repos_supportive}{\code{EngineRestGitLab$pull_repos_supportive()}} \item \href{#method-pull_repos_contributors}{\code{EngineRestGitLab$pull_repos_contributors()}} -\item \href{#method-get_commits}{\code{EngineRestGitLab$get_commits()}} +\item \href{#method-pull_commits}{\code{EngineRestGitLab$pull_commits()}} \item \href{#method-clone}{\code{EngineRestGitLab$clone()}} } } @@ -94,13 +94,18 @@ A table of repositories with added information on contributors. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits}{}}} -\subsection{Method \code{get_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits}{}}} +\subsection{Method \code{pull_commits()}}{ GitLab private method to derive commits from repo with REST API. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{EngineRestGitLab$get_commits(org, date_from, date_until = Sys.date(), settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{EngineRestGitLab$pull_commits( + org, + date_from, + date_until = Sys.date(), + settings +)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/GitHost.Rd b/man/GitHost.Rd index 0e19daa8..2bc95c90 100644 --- a/man/GitHost.Rd +++ b/man/GitHost.Rd @@ -14,8 +14,8 @@ A GitHost superclass \item \href{#method-new}{\code{GitHost$new()}} \item \href{#method-pull_repos}{\code{GitHost$pull_repos()}} \item \href{#method-pull_repos_contributors}{\code{GitHost$pull_repos_contributors()}} -\item \href{#method-get_commits}{\code{GitHost$get_commits()}} -\item \href{#method-get_users}{\code{GitHost$get_users()}} +\item \href{#method-pull_commits}{\code{GitHost$pull_commits()}} +\item \href{#method-pull_users}{\code{GitHost$pull_users()}} \item \href{#method-clone}{\code{GitHost$clone()}} } } @@ -89,12 +89,12 @@ A table of repositories with added information on contributors. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits}{}}} -\subsection{Method \code{get_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits}{}}} +\subsection{Method \code{pull_commits()}}{ A method to get information on commits. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitHost$get_commits(date_from, date_until = Sys.Date(), settings)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitHost$pull_commits(date_from, date_until = Sys.Date(), settings)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -113,12 +113,12 @@ A data.frame of commits } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_users}{}}} -\subsection{Method \code{get_users()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_users}{}}} +\subsection{Method \code{pull_users()}}{ Get information about users \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitHost$get_users(users)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitHost$pull_users(users)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/GitStats.Rd b/man/GitStats.Rd index 65089f84..43f3f0aa 100644 --- a/man/GitStats.Rd +++ b/man/GitStats.Rd @@ -9,13 +9,13 @@ An R6 class object with methods to derive information from multiple Git platform \section{Methods}{ \subsection{Public methods}{ \itemize{ -\item \href{#method-setup}{\code{GitStats$setup()}} +\item \href{#method-set_params}{\code{GitStats$set_params()}} \item \href{#method-set_host}{\code{GitStats$set_host()}} \item \href{#method-set_team_member}{\code{GitStats$set_team_member()}} \item \href{#method-pull_repos}{\code{GitStats$pull_repos()}} \item \href{#method-pull_repos_contributors}{\code{GitStats$pull_repos_contributors()}} -\item \href{#method-get_commits}{\code{GitStats$get_commits()}} -\item \href{#method-get_users}{\code{GitStats$get_users()}} +\item \href{#method-pull_commits}{\code{GitStats$pull_commits()}} +\item \href{#method-pull_users}{\code{GitStats$pull_users()}} \item \href{#method-show_orgs}{\code{GitStats$show_orgs()}} \item \href{#method-show_repos}{\code{GitStats$show_repos()}} \item \href{#method-show_commits}{\code{GitStats$show_commits()}} @@ -25,12 +25,12 @@ An R6 class object with methods to derive information from multiple Git platform } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-setup}{}}} -\subsection{Method \code{setup()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-set_params}{}}} +\subsection{Method \code{set_params()}}{ Set up your search settings. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$setup(search_param, team_name, phrase, language, print_out)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$set_params(search_param, team_name, phrase, language, print_out)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -136,12 +136,12 @@ A table of repositories with added information on contributors. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_commits}{}}} -\subsection{Method \code{get_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_commits}{}}} +\subsection{Method \code{pull_commits()}}{ A method to get information on commits. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$get_commits(date_from, date_until)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$pull_commits(date_from, date_until)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -158,12 +158,12 @@ A data.frame of commits } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-get_users}{}}} -\subsection{Method \code{get_users()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-pull_users}{}}} +\subsection{Method \code{pull_users()}}{ Get information on users. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$get_users(users)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$pull_users(users)}\if{html}{\out{
}} } \subsection{Arguments}{ diff --git a/man/get_commits.Rd b/man/pull_commits.Rd similarity index 84% rename from man/get_commits.Rd rename to man/pull_commits.Rd index 391dcf16..38a63607 100644 --- a/man/get_commits.Rd +++ b/man/pull_commits.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{get_commits} -\alias{get_commits} +\name{pull_commits} +\alias{pull_commits} \title{Get information on commits.} \usage{ -get_commits(gitstats_obj, date_from = NULL, date_until = Sys.time()) +pull_commits(gitstats_obj, date_from = NULL, date_until = Sys.time()) } \arguments{ \item{gitstats_obj}{A GitStats object.} @@ -32,11 +32,11 @@ my_gitstats <- create_gitstats() \%>\% token = Sys.getenv("GITLAB_PAT_PUBLIC"), orgs = "mbtests" ) \%>\% - setup( + set_params( search_param = "team", team_name = "rwdevs" ) \%>\% set_team_member("Maciej Banaś", "maciekbanas") \%>\% - get_commits(date_from = "2018-01-01") + pull_commits(date_from = "2018-01-01") } } diff --git a/man/get_users.Rd b/man/pull_users.Rd similarity index 84% rename from man/get_users.Rd rename to man/pull_users.Rd index 7a0edbb3..5e016dd5 100644 --- a/man/get_users.Rd +++ b/man/pull_users.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{get_users} -\alias{get_users} +\name{pull_users} +\alias{pull_users} \title{Get users statistics.} \usage{ -get_users(gitstats_obj, users) +pull_users(gitstats_obj, users) } \arguments{ \item{gitstats_obj}{A GitStats object.} @@ -30,6 +30,6 @@ Get information on users. token = Sys.getenv("GITLAB_PAT_PUBLIC"), orgs = "mbtests" ) \%>\% - get_users(c("maciekabanas", "marcinkowskak")) + pull_users(c("maciekabanas", "marcinkowskak")) } } diff --git a/man/setup.Rd b/man/set_params.Rd similarity index 92% rename from man/setup.Rd rename to man/set_params.Rd index 8baa0ef0..e8f771dc 100644 --- a/man/setup.Rd +++ b/man/set_params.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{setup} -\alias{setup} +\name{set_params} +\alias{set_params} \title{Set up your search settings.} \usage{ -setup( +set_params( gitstats_obj, search_param = NULL, team_name = NULL, @@ -35,7 +35,7 @@ Set up your search settings. \examples{ \dontrun{ my_gitstats <- create_gitstats() \%>\% - setup( + set_params( search_param = "team", team_name = "Avengers", language = "R" diff --git a/tests/testthat/_snaps/03-EngineGraphQLGitHub.md b/tests/testthat/_snaps/03-EngineGraphQLGitHub.md index 9f933a7f..0b24694b 100644 --- a/tests/testthat/_snaps/03-EngineGraphQLGitHub.md +++ b/tests/testthat/_snaps/03-EngineGraphQLGitHub.md @@ -4234,10 +4234,10 @@ Message i [GitHub][Engine:GraphQL][org:r-world-devs][team:] Pulling repositories... -# `get_commits()` retrieves commits in the table format +# `pull_commits()` retrieves commits in the table format Code - commits_table <- test_gql_gh$get_commits(org = "r-world-devs", date_from = "2023-01-01", + commits_table <- test_gql_gh$pull_commits(org = "r-world-devs", date_from = "2023-01-01", date_until = "2023-02-28", settings = settings) Message i [GitHub][Engine:GraphQL][org:r-world-devs] Pulling commits... diff --git a/tests/testthat/_snaps/03-EngineRestGitHub.md b/tests/testthat/_snaps/03-EngineRestGitHub.md index b83ee59e..2cc88b66 100644 --- a/tests/testthat/_snaps/03-EngineRestGitHub.md +++ b/tests/testthat/_snaps/03-EngineRestGitHub.md @@ -2,10 +2,10 @@ x HTTP 401 Unauthorized. -# `get_commits_stats()` works as expected +# `pull_commits_stats()` works as expected Code - gh_rest_commits_table_with_stats <- test_rest_priv$get_commits_stats( + gh_rest_commits_table_with_stats <- test_rest_priv$pull_commits_stats( commits_table = test_mocker$use("gh_rest_commits_table")[1:5, ]) Message i [GitHub][Engine:REST] Pulling commits stats... @@ -28,7 +28,7 @@ # supportive method for getting commits works Code - gh_rest_commits_table <- test_rest$get_commits_supportive(org = "r-world-devs", + gh_rest_commits_table <- test_rest$pull_commits_supportive(org = "r-world-devs", date_from = "2023-01-01", date_until = "2023-07-01", settings = test_settings) Message i [GitHub][Engine:REST][org:r-world-devs] Pulling commits... diff --git a/tests/testthat/_snaps/03-EngineRestGitLab.md b/tests/testthat/_snaps/03-EngineRestGitLab.md index 8a17b10d..1a00ecd5 100644 --- a/tests/testthat/_snaps/03-EngineRestGitLab.md +++ b/tests/testthat/_snaps/03-EngineRestGitLab.md @@ -17,10 +17,10 @@ Message i [GitLab][Engine:REST][phrase:covid][org:erasmusmc-public-health] Searching repositories... -# `get_commits()` works as expected +# `pull_commits()` works as expected Code - result <- test_rest$get_commits(org = "mbtests", date_from = "2023-01-01", + result <- test_rest$pull_commits(org = "mbtests", date_from = "2023-01-01", date_until = "2023-04-20", settings = settings) Message i [GitLab][Engine:REST][org:mbtests] Pulling repositories... diff --git a/tests/testthat/_snaps/GitStats.md b/tests/testthat/_snaps/GitStats.md index ba9de215..e2427a01 100644 --- a/tests/testthat/_snaps/GitStats.md +++ b/tests/testthat/_snaps/GitStats.md @@ -45,7 +45,7 @@ # check_for_host works - Add first your hosts with `set_connection()`. + Add first your hosts with `set_host()`. # GitStats throws error when pull_repos_contributors is run with empty repos field diff --git a/tests/testthat/_snaps/get_users.md b/tests/testthat/_snaps/get_users.md index ff166294..433fc08e 100644 --- a/tests/testthat/_snaps/get_users.md +++ b/tests/testthat/_snaps/get_users.md @@ -1,4 +1,4 @@ -# get_users shows error when no hosts are defined +# pull_users shows error when no hosts are defined - Add first your hosts with `set_connection()`. + Add first your hosts with `set_host()`. diff --git a/tests/testthat/_snaps/05-repos-functions.md b/tests/testthat/_snaps/pull_repos-functions.md similarity index 100% rename from tests/testthat/_snaps/05-repos-functions.md rename to tests/testthat/_snaps/pull_repos-functions.md diff --git a/tests/testthat/_snaps/setup.md b/tests/testthat/_snaps/set_params.md similarity index 87% rename from tests/testthat/_snaps/setup.md rename to tests/testthat/_snaps/set_params.md index db4888b5..f17b24e5 100644 --- a/tests/testthat/_snaps/setup.md +++ b/tests/testthat/_snaps/set_params.md @@ -5,7 +5,7 @@ # Setting up settings to `phrase` works correctly Code - setup(test_gitstats, search_param = "phrase", phrase = "covid") + set_params(test_gitstats, search_param = "phrase", phrase = "covid") Message v Your search preferences set to phrase: covid. Output @@ -22,7 +22,7 @@ # Setting language works correctly Code - setup(test_gitstats, language = "Python") + set_params(test_gitstats, language = "Python") Message v Your programming language is set to Python. Output @@ -39,7 +39,7 @@ # Setting language to 'All' resets language settings Code - setup(test_gitstats, language = "All") + set_params(test_gitstats, language = "All") Output A object for 0 hosts: Hosts: diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 0749d981..b1038781 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -1,6 +1,6 @@ create_test_gitstats <- function(hosts = 0, priv_mode = FALSE) { test_gitstats <- create_gitstats() %>% - setup(print_out = FALSE) + set_params(print_out = FALSE) if (hosts == 1) { suppressMessages({ @@ -25,7 +25,7 @@ create_test_gitstats <- function(hosts = 0, priv_mode = FALSE) { }) } if (priv_mode) { - test_gitstats <- environment(test_gitstats$setup)$private + test_gitstats <- environment(test_gitstats$set_params)$private } return(test_gitstats) } @@ -242,18 +242,18 @@ expect_repos_table <- function(pull_repos_object) { expect_gt(nrow(pull_repos_object), 0) } -expect_commits_table <- function(get_commits_object, with_stats = TRUE) { +expect_commits_table <- function(pull_commits_object, with_stats = TRUE) { commit_cols <- c( "id", "committed_date", "author", "additions", "deletions", "repository", "organization", "api_url" ) - expect_s3_class(get_commits_object, "data.frame") - expect_named(get_commits_object, commit_cols) - expect_gt(nrow(get_commits_object), 0) - expect_s3_class(get_commits_object$committed_date, "POSIXt") + expect_s3_class(pull_commits_object, "data.frame") + expect_named(pull_commits_object, commit_cols) + expect_gt(nrow(pull_commits_object), 0) + expect_s3_class(pull_commits_object$committed_date, "POSIXt") if (with_stats) { - expect_type(get_commits_object$additions, "integer") - expect_type(get_commits_object$deletions, "integer") + expect_type(pull_commits_object$additions, "integer") + expect_type(pull_commits_object$deletions, "integer") } } diff --git a/tests/testthat/test-03-EngineGraphQLGitHub.R b/tests/testthat/test-03-EngineGraphQLGitHub.R index d68b1faa..e83654f0 100644 --- a/tests/testthat/test-03-EngineGraphQLGitHub.R +++ b/tests/testthat/test-03-EngineGraphQLGitHub.R @@ -250,15 +250,15 @@ test_that("`pull_repos()` works as expected", { ) }) -test_that("`get_commits()` retrieves commits in the table format", { +test_that("`pull_commits()` retrieves commits in the table format", { mockery::stub( - test_gql_gh$get_commits, + test_gql_gh$pull_commits, "private$pull_commits_from_repos", test_mocker$use("commits_from_repos") ) mockery::stub( - test_gql_gh$get_commits, + test_gql_gh$pull_commits, "private$prepare_commits_table", test_mocker$use("commits_table") ) @@ -267,7 +267,7 @@ test_that("`get_commits()` retrieves commits in the table format", { dplyr::filter(name == "GitStats") mockery::stub( - test_gql_gh$get_commits, + test_gql_gh$pull_commits, "self$pull_repos", repos_table ) @@ -275,7 +275,7 @@ test_that("`get_commits()` retrieves commits in the table format", { settings <- list(search_param = "org") expect_snapshot( - commits_table <- test_gql_gh$get_commits( + commits_table <- test_gql_gh$pull_commits( org = "r-world-devs", date_from = "2023-01-01", date_until = "2023-02-28", diff --git a/tests/testthat/test-03-EngineRestGitHub.R b/tests/testthat/test-03-EngineRestGitHub.R index 95780006..6261579e 100644 --- a/tests/testthat/test-03-EngineRestGitHub.R +++ b/tests/testthat/test-03-EngineRestGitHub.R @@ -195,9 +195,9 @@ test_that("`prepare_commits_table()` prepares commits table (for orgs and for te test_mocker$cache(gh_rest_commits_table_team) }) -test_that("`get_commits_stats()` works as expected", { +test_that("`pull_commits_stats()` works as expected", { expect_snapshot( - gh_rest_commits_table_with_stats <- test_rest_priv$get_commits_stats( + gh_rest_commits_table_with_stats <- test_rest_priv$pull_commits_stats( commits_table = test_mocker$use("gh_rest_commits_table")[1:5,] ) ) @@ -247,25 +247,25 @@ test_that("`pull_repos()` works", { test_that("supportive method for getting commits works", { mockery::stub( - test_rest$get_commits_supportive, + test_rest$pull_commits_supportive, "self$pull_repos_supportive", test_mocker$use("gh_repos_table") ) mockery::stub( - test_rest$get_commits_supportive, + test_rest$pull_commits_supportive, "private$pull_commits_from_org", test_mocker$use("gh_rest_commits_from_org") ) mockery::stub( - test_rest$get_commits_supportive, - "private$get_commits_stats", + test_rest$pull_commits_supportive, + "private$pull_commits_stats", test_mocker$use("gh_rest_commits_table_with_stats") ) test_settings <- list( search_param = "org" ) expect_snapshot( - gh_rest_commits_table <- test_rest$get_commits_supportive( + gh_rest_commits_table <- test_rest$pull_commits_supportive( org = "r-world-devs", date_from = "2023-01-01", date_until = "2023-07-01", diff --git a/tests/testthat/test-03-EngineRestGitLab.R b/tests/testthat/test-03-EngineRestGitLab.R index 5cf72684..77c8d785 100644 --- a/tests/testthat/test-03-EngineRestGitLab.R +++ b/tests/testthat/test-03-EngineRestGitLab.R @@ -210,9 +210,9 @@ test_that("`pull_repos_by_phrase()` works", { expect_repos_table(result) }) -test_that("`get_commits()` works as expected", { +test_that("`pull_commits()` works as expected", { mockery::stub( - test_rest$get_commits, + test_rest$pull_commits, "private$pull_commits_from_org", test_mocker$use("gl_commits_org") ) @@ -220,7 +220,7 @@ test_that("`get_commits()` works as expected", { search_param = "org" ) expect_snapshot( - result <- test_rest$get_commits( + result <- test_rest$pull_commits( org = "mbtests", date_from = "2023-01-01", date_until = "2023-04-20", diff --git a/tests/testthat/test-04-EngineGraphQL.R b/tests/testthat/test-04-EngineGraphQL.R index 1b01dd24..6443acb5 100644 --- a/tests/testthat/test-04-EngineGraphQL.R +++ b/tests/testthat/test-04-EngineGraphQL.R @@ -3,8 +3,8 @@ test_gql <- EngineGraphQLGitHub$new( token = Sys.getenv("GITHUB_PAT") ) -test_that("get_users build users table for GitHub", { - users_result <- test_gql$get_users( +test_that("pull_users build users table for GitHub", { + users_result <- test_gql$pull_users( users = c("maciekbanas", "Cotau", "marcinkowskak") ) expect_users_table( @@ -17,8 +17,8 @@ test_gql_gl <- EngineGraphQLGitLab$new( token = Sys.getenv("GITLAB_PAT_PUBLIC") ) -test_that("get_users build users table for GitLab", { - users_result <- test_gql_gl$get_users( +test_that("pull_users build users table for GitLab", { + users_result <- test_gql_gl$pull_users( users = c("maciekbanas", "Cotau", "marcinkowskak") ) expect_users_table( diff --git a/tests/testthat/test-GitHost.R b/tests/testthat/test-GitHost.R index 1eac245d..022b6d01 100644 --- a/tests/testthat/test-GitHost.R +++ b/tests/testthat/test-GitHost.R @@ -7,7 +7,7 @@ test_host <- create_testhost( ) test_that("GitHost gets users tables", { - users_table <- test_host$get_users( + users_table <- test_host$pull_users( users = c("maciekbanas", "kalimu", "galachad") ) expect_users_table(users_table) diff --git a/tests/testthat/test-GitStats.R b/tests/testthat/test-GitStats.R index f9e13523..f9154cb2 100644 --- a/tests/testthat/test-GitStats.R +++ b/tests/testthat/test-GitStats.R @@ -17,7 +17,7 @@ test_that("GitStats prints the proper info when connections are added.", { }) suppressMessages({ - setup( + set_params( test_gitstats, search_param = "team", team_name = "RWD-IE" @@ -47,7 +47,7 @@ test_that("check_for_host works", { test_that("GitStats get users info", { test_gitstats <- create_test_gitstats(hosts = 2) - users_result <- test_gitstats$get_users( + users_result <- test_gitstats$pull_users( c("maciekbanas", "kalimu", "marcinkowskak") ) expect_users_table( diff --git a/tests/testthat/test-05-repos-functions.R b/tests/testthat/test-pull_repos-functions.R similarity index 100% rename from tests/testthat/test-05-repos-functions.R rename to tests/testthat/test-pull_repos-functions.R diff --git a/tests/testthat/test-get_users.R b/tests/testthat/test-pull_users.R similarity index 78% rename from tests/testthat/test-get_users.R rename to tests/testthat/test-pull_users.R index 95e7b476..46c96863 100644 --- a/tests/testthat/test-get_users.R +++ b/tests/testthat/test-pull_users.R @@ -1,12 +1,12 @@ -test_that("get_users shows error when no hosts are defined", { +test_that("pull_users shows error when no hosts are defined", { test_gitstats <- create_gitstats() expect_snapshot_error( - get_users(test_gitstats, + pull_users(test_gitstats, c("maciekbanas", "kalimu")) ) }) -test_that("get_users works as expected", { +test_that("pull_users works as expected", { test_gitstats <- create_gitstats() suppressMessages({ test_gitstats$set_host( @@ -21,7 +21,7 @@ test_that("get_users works as expected", { orgs = "mbtests" ) }) - get_users(test_gitstats, + pull_users(test_gitstats, c("maciekbanas", "kalimu")) users_table <- test_gitstats$show_users() expect_users_table( diff --git a/tests/testthat/test-reset.R b/tests/testthat/test-reset.R index 894fff6a..627b4e4e 100644 --- a/tests/testthat/test-reset.R +++ b/tests/testthat/test-reset.R @@ -2,10 +2,12 @@ test_that("`reset()` resets all settings", { test_gitstats <- create_test_gitstats(hosts = 2) suppressMessages({ invisible( - setup(test_gitstats, - search_param = "phrase", - phrase = "test-phrase", - language = "Python") + set_params( + test_gitstats, + search_param = "phrase", + phrase = "test-phrase", + language = "Python" + ) ) }) expect_snapshot( @@ -13,12 +15,14 @@ test_that("`reset()` resets all settings", { ) suppressMessages({ invisible( - setup(test_gitstats, - search_param = "team", - team_name = "Testers", - language = "CSS") %>% - set_team_member("John Test") %>% - set_team_member("Bob Test") + set_params( + test_gitstats, + search_param = "team", + team_name = "Testers", + language = "CSS" + ) %>% + set_team_member("John Test") %>% + set_team_member("Bob Test") ) }) expect_snapshot( @@ -30,16 +34,18 @@ test_that("`reset_language()` resets language settings to 'All'", { test_gitstats <- create_test_gitstats(hosts = 2) suppressMessages({ invisible( - setup(test_gitstats, - search_param = "phrase", - phrase = "test-phrase", - language = "Python") + set_params( + test_gitstats, + search_param = "phrase", + phrase = "test-phrase", + language = "Python" + ) ) }) expect_snapshot( reset_language(test_gitstats) ) - priv <- environment(test_gitstats$setup)$private + priv <- environment(test_gitstats$set_params)$private expect_equal( priv$settings$search_param, "phrase" diff --git a/tests/testthat/test-setup.R b/tests/testthat/test-set_params.R similarity index 83% rename from tests/testthat/test-setup.R rename to tests/testthat/test-set_params.R index 92f81c05..20c19d21 100644 --- a/tests/testthat/test-setup.R +++ b/tests/testthat/test-set_params.R @@ -1,5 +1,5 @@ test_gitstats <- create_gitstats() -test_gitstats_priv <- environment(test_gitstats$setup)$private +test_gitstats_priv <- environment(test_gitstats$set_params)$private test_that("By default search param is set to 'orgs'", { expect_equal( @@ -10,7 +10,7 @@ test_that("By default search param is set to 'orgs'", { test_that("Setting up settings to `team` throws error when team_name is not defined", { expect_snapshot_error( - setup(test_gitstats, + set_params(test_gitstats, search_param = "team" ) ) @@ -18,7 +18,7 @@ test_that("Setting up settings to `team` throws error when team_name is not defi test_that("Setting up settings to `team` passes information to 'team' field", { suppressMessages( - setup(test_gitstats, + set_params(test_gitstats, search_param = "team", team_name = "RWD-IE" ) @@ -30,7 +30,7 @@ test_that("Setting up settings to `team` passes information to 'team' field", { }) test_that("Setting up settings to `orgs` works correctly", { - setup(test_gitstats, + set_params(test_gitstats, search_param = "org" ) expect_equal( @@ -41,7 +41,7 @@ test_that("Setting up settings to `orgs` works correctly", { test_that("Setting up settings to `phrase` throws error when phrase is not defined", { expect_error( - setup(test_gitstats, + set_params(test_gitstats, search_param = "phrase" ) ) @@ -49,7 +49,7 @@ test_that("Setting up settings to `phrase` throws error when phrase is not defin test_that("Setting up settings to `phrase` works correctly", { expect_snapshot( - setup(test_gitstats, + set_params(test_gitstats, search_param = "phrase", phrase = "covid" ) @@ -66,7 +66,7 @@ test_that("Setting up settings to `phrase` works correctly", { test_that("Error shows, when you pass not proper param", { expect_error( - setup(test_gitstats, + set_params(test_gitstats, search_param = "twilight" ) ) @@ -74,7 +74,7 @@ test_that("Error shows, when you pass not proper param", { test_that("Setting language works correctly", { expect_snapshot( - setup(test_gitstats, + set_params(test_gitstats, language = "Python" ) ) @@ -82,7 +82,7 @@ test_that("Setting language works correctly", { test_that("Setting language to 'All' resets language settings", { expect_snapshot( - setup(test_gitstats, + set_params(test_gitstats, language = "All" ) ) diff --git a/tests/testthat/test-set_team_member.R b/tests/testthat/test-set_team_member.R index 5c2c74b9..0ddc5f24 100644 --- a/tests/testthat/test-set_team_member.R +++ b/tests/testthat/test-set_team_member.R @@ -1,6 +1,6 @@ suppressMessages(test_gitstats <- create_gitstats()) -test_gitstats_priv <- environment(test_gitstats$setup)$private +test_gitstats_priv <- environment(test_gitstats$set_params)$private test_that("set_team_member() adds team member in `GitStats` object", { expect_snapshot( From 9a8be9019234244ae7b3d81123eb2872afbaac4b Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 10:56:42 +0000 Subject: [PATCH 3/7] Change names of `show_*` functions. --- NAMESPACE | 6 +-- NEWS.md | 6 +-- R/GitStats.R | 8 ++-- R/gitstats_functions.R | 18 ++++----- R/plots.R | 4 +- devel/example_workflow.R | 6 +-- man/GitStats.Rd | 40 +++++++++---------- man/{show_commits.Rd => get_commits.Rd} | 6 +-- man/{show_orgs.Rd => get_orgs.Rd} | 6 +-- man/{show_repos.Rd => get_repos.Rd} | 6 +-- .../_snaps/{get_users.md => pull_users.md} | 0 tests/testthat/test-GitStats.R | 12 +++--- .../{test-show.R => test-get-functions.R} | 12 +++--- tests/testthat/test-pull_repos-functions.R | 4 +- tests/testthat/test-pull_users.R | 2 +- 15 files changed, 68 insertions(+), 68 deletions(-) rename man/{show_commits.Rd => get_commits.Rd} (80%) rename man/{show_orgs.Rd => get_orgs.Rd} (87%) rename man/{show_repos.Rd => get_repos.Rd} (82%) rename tests/testthat/_snaps/{get_users.md => pull_users.md} (100%) rename tests/testthat/{test-show.R => test-get-functions.R} (59%) diff --git a/NAMESPACE b/NAMESPACE index 820beedf..dbeb3b93 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,9 @@ export("%>%") export(create_gitstats) +export(get_commits) +export(get_orgs) +export(get_repos) export(plot_commits) export(plot_repos) export(pull_commits) @@ -13,9 +16,6 @@ export(reset_language) export(set_host) export(set_params) export(set_team_member) -export(show_commits) -export(show_orgs) -export(show_repos) importFrom(R6,R6Class) importFrom(cli,cli_abort) importFrom(cli,cli_alert_danger) diff --git a/NEWS.md b/NEWS.md index 92263c4f..5cd46774 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ GitStats (development version) -- changed names of `get_*` to `pull_*` functions (I: #294), +- changed names of `get_*` to `pull_*` functions; `get_*` functions are now to retrieve already pulled data from GitStats object (I: #294), - changed name of `setup` to `set_params` function (I: #294), - set new name for `set_connection` function: `set_host` as it is more informative (and shorter) (I: #271), - changed name of a function: `add_team_member` to `set_team_member` (I: #271), @@ -8,9 +8,9 @@ GitStats (development version) - added `pull_users()` function to pull information on users (I: #199 PR: #238), - added possibility of scanning whole internal git platforms if no `orgs` are passed (I: #258), - added switching to REST engine in case GraphQL fails with 502 error (I: #225 PRs: #227 (for repos) #261 (for commits)) -- added `show_orgs()` function to print all organizations (I: #283), +- added `get_orgs()` function to print all organizations (I: #283), - added GraphQL engine for getting GitLab repos by organization (I: #218 PR: #233) -- removed `contributors` as basic stat when pulling `repos` by `org` and by `phrase` to improve speed of pulling repositories data. Added `get_repos_contributors()` user function and `add_contributors` parameter to `get_repos()` function to add conditionally information on contributors to repositories table (I: #235 PRs: #243 #264) +- removed `contributors` as basic stat when pulling `repos` by `org` and by `phrase` to improve speed of pulling repositories data. Added `pull_repos_contributors()` user function and `add_contributors` parameter to `pull_repos()` function to add conditionally information on contributors to repositories table (I: #235 PRs: #243 #264) - added resetting all settings to default with `reset()` function (I: #270) - added resetting language in your search preferences with `reset_language()` or setting `language` parameter to `All` in `setup()` function (I: #231 PR: #265) - OOP optimization: moved method on adding issues do repository table via REST to privates (I: #235 PR: #243) diff --git a/R/GitStats.R b/R/GitStats.R index a2f8c197..b5c5e70b 100644 --- a/R/GitStats.R +++ b/R/GitStats.R @@ -213,7 +213,7 @@ GitStats <- R6::R6Class("GitStats", }, #' @description Print organizations. - show_orgs = function() { + get_orgs = function() { purrr::map(private$hosts, function(host) { orgs <- host$.__enclos_env__$private$orgs purrr::map_vec(orgs, ~ gsub("%2f", "/", .)) @@ -221,17 +221,17 @@ GitStats <- R6::R6Class("GitStats", }, #' @description Print repositories output. - show_repos = function() { + get_repos = function() { private$repos }, #' @description Print commits output. - show_commits = function() { + get_commits = function() { private$commits }, #' @description Print users output. - show_users = function() { + get_users = function() { private$users }, diff --git a/R/gitstats_functions.R b/R/gitstats_functions.R index 2bcef453..24947ab9 100644 --- a/R/gitstats_functions.R +++ b/R/gitstats_functions.R @@ -265,33 +265,33 @@ reset_language <- function(gitstats_obj){ } #' @title Show organizations -#' @name show_orgs +#' @name get_orgs #' @description Prints organizations downloaded in `GitStats`. Especially #' helpful when user is scanning whole git platform and want to have a glimpse #' at organizations. #' @param gitstats_obj A GitStats object. #' @return A vector of organizations. #' @export -show_orgs <- function(gitstats_obj){ - return(gitstats_obj$show_orgs()) +get_orgs <- function(gitstats_obj){ + return(gitstats_obj$get_orgs()) } #' @title Show repositories -#' @name show_repos +#' @name get_repos #' @description Prints repositories table pulled by `GitStats`. #' @param gitstats_obj A GitStats object. #' @return A table of repositories. #' @export -show_repos <- function(gitstats_obj){ - return(gitstats_obj$show_repos()) +get_repos <- function(gitstats_obj){ + return(gitstats_obj$get_repos()) } #' @title Show commits -#' @name show_commits +#' @name get_commits #' @description Prints commits table pulled by `GitStats`. #' @param gitstats_obj A GitStats object. #' @return A table of commits. #' @export -show_commits <- function(gitstats_obj){ - return(gitstats_obj$show_commits()) +get_commits <- function(gitstats_obj){ + return(gitstats_obj$get_commits()) } diff --git a/R/plots.R b/R/plots.R index 530d6660..ac709ac1 100644 --- a/R/plots.R +++ b/R/plots.R @@ -14,7 +14,7 @@ #' @export plot_repos <- function(gitstats_obj, repos_n = 10) { - repos_to_plot <- data.table::copy(gitstats_obj$show_repos()) + repos_to_plot <- data.table::copy(gitstats_obj$get_repos()) if (is.null(repos_to_plot)) { cli::cli_abort("No repositories in `GitStats` object to plot.") } @@ -62,7 +62,7 @@ plot_commits <- function(gitstats_obj, time_interval = c("month", "day", "week")) { time_interval <- match.arg(time_interval) - commits_dt <- data.table::copy(gitstats_obj$show_commits()) + commits_dt <- data.table::copy(gitstats_obj$get_commits()) if (is.null(commits_dt)) { cli::cli_abort("No commits in `GitStats` object to plot.") } diff --git a/devel/example_workflow.R b/devel/example_workflow.R index 8db60881..d2c44e42 100644 --- a/devel/example_workflow.R +++ b/devel/example_workflow.R @@ -17,7 +17,7 @@ git_stats # examples for getting repos (default search parameter is 'org') pull_repos(git_stats) pull_repos_contributors(git_stats) -dplyr::glimpse(show_repos(git_stats)) +dplyr::glimpse(get_repos(git_stats)) pull_repos(git_stats, add_contributors = TRUE) @@ -49,7 +49,7 @@ set_params( # now pull repos by default by team pull_repos(git_stats) -show_repos(git_stats) +get_repos(git_stats) pull_commits(git_stats, date_from = "2020-01-01") reset_language(git_stats) @@ -81,7 +81,7 @@ plot_commits(git_stats) # get information on users git_stats %>% pull_users(c("maciekbanas", "kalimu", "marcinkowskak", "Cotau", "krystian8207")) -git_stats$show_users() +git_stats$get_users() # SHOWCASES diff --git a/man/GitStats.Rd b/man/GitStats.Rd index 43f3f0aa..660bbeb1 100644 --- a/man/GitStats.Rd +++ b/man/GitStats.Rd @@ -16,10 +16,10 @@ An R6 class object with methods to derive information from multiple Git platform \item \href{#method-pull_repos_contributors}{\code{GitStats$pull_repos_contributors()}} \item \href{#method-pull_commits}{\code{GitStats$pull_commits()}} \item \href{#method-pull_users}{\code{GitStats$pull_users()}} -\item \href{#method-show_orgs}{\code{GitStats$show_orgs()}} -\item \href{#method-show_repos}{\code{GitStats$show_repos()}} -\item \href{#method-show_commits}{\code{GitStats$show_commits()}} -\item \href{#method-show_users}{\code{GitStats$show_users()}} +\item \href{#method-get_orgs}{\code{GitStats$get_orgs()}} +\item \href{#method-get_repos}{\code{GitStats$get_repos()}} +\item \href{#method-get_commits}{\code{GitStats$get_commits()}} +\item \href{#method-get_users}{\code{GitStats$get_users()}} \item \href{#method-print}{\code{GitStats$print()}} \item \href{#method-clone}{\code{GitStats$clone()}} } @@ -178,42 +178,42 @@ A data.frame of users. } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-show_orgs}{}}} -\subsection{Method \code{show_orgs()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-get_orgs}{}}} +\subsection{Method \code{get_orgs()}}{ Print organizations. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$show_orgs()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$get_orgs()}\if{html}{\out{
}} } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-show_repos}{}}} -\subsection{Method \code{show_repos()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-get_repos}{}}} +\subsection{Method \code{get_repos()}}{ Print repositories output. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$show_repos()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$get_repos()}\if{html}{\out{
}} } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-show_commits}{}}} -\subsection{Method \code{show_commits()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-get_commits}{}}} +\subsection{Method \code{get_commits()}}{ Print commits output. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$show_commits()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$get_commits()}\if{html}{\out{
}} } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-show_users}{}}} -\subsection{Method \code{show_users()}}{ +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-get_users}{}}} +\subsection{Method \code{get_users()}}{ Print users output. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{GitStats$show_users()}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{GitStats$get_users()}\if{html}{\out{
}} } } diff --git a/man/show_commits.Rd b/man/get_commits.Rd similarity index 80% rename from man/show_commits.Rd rename to man/get_commits.Rd index f8b113e6..323072be 100644 --- a/man/show_commits.Rd +++ b/man/get_commits.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{show_commits} -\alias{show_commits} +\name{get_commits} +\alias{get_commits} \title{Show commits} \usage{ -show_commits(gitstats_obj) +get_commits(gitstats_obj) } \arguments{ \item{gitstats_obj}{A GitStats object.} diff --git a/man/show_orgs.Rd b/man/get_orgs.Rd similarity index 87% rename from man/show_orgs.Rd rename to man/get_orgs.Rd index c77f3add..4c8f06a5 100644 --- a/man/show_orgs.Rd +++ b/man/get_orgs.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{show_orgs} -\alias{show_orgs} +\name{get_orgs} +\alias{get_orgs} \title{Show organizations} \usage{ -show_orgs(gitstats_obj) +get_orgs(gitstats_obj) } \arguments{ \item{gitstats_obj}{A GitStats object.} diff --git a/man/show_repos.Rd b/man/get_repos.Rd similarity index 82% rename from man/show_repos.Rd rename to man/get_repos.Rd index fd1f4aa4..2380cb96 100644 --- a/man/show_repos.Rd +++ b/man/get_repos.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/gitstats_functions.R -\name{show_repos} -\alias{show_repos} +\name{get_repos} +\alias{get_repos} \title{Show repositories} \usage{ -show_repos(gitstats_obj) +get_repos(gitstats_obj) } \arguments{ \item{gitstats_obj}{A GitStats object.} diff --git a/tests/testthat/_snaps/get_users.md b/tests/testthat/_snaps/pull_users.md similarity index 100% rename from tests/testthat/_snaps/get_users.md rename to tests/testthat/_snaps/pull_users.md diff --git a/tests/testthat/test-GitStats.R b/tests/testthat/test-GitStats.R index f9154cb2..ce48a1e5 100644 --- a/tests/testthat/test-GitStats.R +++ b/tests/testthat/test-GitStats.R @@ -68,18 +68,18 @@ test_that("Add_repos_contributors adds repos contributors to repos table", { suppressMessages({ test_gitstats$pull_repos() }) - repos_without_contributors <- test_gitstats$show_repos() + repos_without_contributors <- test_gitstats$get_repos() expect_snapshot( test_gitstats$pull_repos_contributors() ) - repos_with_contributors <- test_gitstats$show_repos() + repos_with_contributors <- test_gitstats$get_repos() expect_repos_table_with_contributors(repos_with_contributors) expect_equal(nrow(repos_without_contributors), nrow(repos_with_contributors)) }) -test_that("show_orgs print orgs properly", { +test_that("get_orgs print orgs properly", { expect_equal( - test_gitstats$show_orgs(), + test_gitstats$get_orgs(), c("r-world-devs", "openpharma", "mbtests") ) }) @@ -92,9 +92,9 @@ suppressMessages( ) ) -test_that("show_orgs print subgroups properly", { +test_that("get_orgs print subgroups properly", { expect_equal( - test_gitstats$show_orgs(), + test_gitstats$get_orgs(), "mbtests/subgroup" ) }) diff --git a/tests/testthat/test-show.R b/tests/testthat/test-get-functions.R similarity index 59% rename from tests/testthat/test-show.R rename to tests/testthat/test-get-functions.R index 0b3734f3..0c11d416 100644 --- a/tests/testthat/test-show.R +++ b/tests/testthat/test-get-functions.R @@ -1,20 +1,20 @@ test_gitstats <- create_test_gitstats(hosts = 2) -test_that("show_orgs() shows orgs", { +test_that("get_orgs() shows orgs", { expect_equal( - show_orgs(test_gitstats), + get_orgs(test_gitstats), c("r-world-devs", "openpharma", "mbtests") ) }) -test_that("show_repos() shows repos table", { +test_that("get_repos() shows repos table", { test_gitstats$.__enclos_env__$private$repos <- test_mocker$use("gh_repos_table") - repos_table <- show_repos(test_gitstats) + repos_table <- get_repos(test_gitstats) expect_repos_table(repos_table) }) -test_that("show_commits() shows commits table", { +test_that("get_commits() shows commits table", { test_gitstats$.__enclos_env__$private$commits <- test_mocker$use("commits_table") - commits_table <- show_commits(test_gitstats) + commits_table <- get_commits(test_gitstats) expect_commits_table(commits_table) }) diff --git a/tests/testthat/test-pull_repos-functions.R b/tests/testthat/test-pull_repos-functions.R index 18693649..400a8777 100644 --- a/tests/testthat/test-pull_repos-functions.R +++ b/tests/testthat/test-pull_repos-functions.R @@ -4,7 +4,7 @@ test_that("pull_repos pulls repos in the table format", { expect_snapshot( pull_repos(test_gitstats) ) - repos_table <- test_gitstats$show_repos() + repos_table <- test_gitstats$get_repos() expect_repos_table(repos_table) }) @@ -14,6 +14,6 @@ test_that("pull_repos_contributors adds contributors column to repos table", { test_gitstats ) ) - repos_table <- test_gitstats$show_repos() + repos_table <- test_gitstats$get_repos() expect_repos_table_with_contributors(repos_table) }) diff --git a/tests/testthat/test-pull_users.R b/tests/testthat/test-pull_users.R index 46c96863..121b5371 100644 --- a/tests/testthat/test-pull_users.R +++ b/tests/testthat/test-pull_users.R @@ -23,7 +23,7 @@ test_that("pull_users works as expected", { }) pull_users(test_gitstats, c("maciekbanas", "kalimu")) - users_table <- test_gitstats$show_users() + users_table <- test_gitstats$get_users() expect_users_table( users_table ) From 86d9771b6f3c8f407710528b307508f9e78820d8 Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 11:21:35 +0000 Subject: [PATCH 4/7] Add `get_users`, update docs and set order for high-level functions tests. --- NAMESPACE | 1 + R/gitstats_functions.R | 22 ++++++++++++++----- man/get_commits.Rd | 4 ++-- man/get_orgs.Rd | 4 ++-- man/get_repos.Rd | 4 ++-- man/get_users.Rd | 17 ++++++++++++++ .../_snaps/{GitHost.md => 05-GitHost.md} | 0 .../_snaps/{GitStats.md => 06-GitStats.md} | 0 .../{test-GitHost.R => test-05-GitHost.R} | 1 + .../{test-GitStats.R => test-06-GitStats.R} | 0 tests/testthat/test-get-functions.R | 12 +++++++--- 11 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 man/get_users.Rd rename tests/testthat/_snaps/{GitHost.md => 05-GitHost.md} (100%) rename tests/testthat/_snaps/{GitStats.md => 06-GitStats.md} (100%) rename tests/testthat/{test-GitHost.R => test-05-GitHost.R} (99%) rename tests/testthat/{test-GitStats.R => test-06-GitStats.R} (100%) diff --git a/NAMESPACE b/NAMESPACE index dbeb3b93..c243437f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(create_gitstats) export(get_commits) export(get_orgs) export(get_repos) +export(get_users) export(plot_commits) export(plot_repos) export(pull_commits) diff --git a/R/gitstats_functions.R b/R/gitstats_functions.R index 24947ab9..c24d49b0 100644 --- a/R/gitstats_functions.R +++ b/R/gitstats_functions.R @@ -264,9 +264,9 @@ reset_language <- function(gitstats_obj){ return(gitstats_obj) } -#' @title Show organizations +#' @title Get organizations #' @name get_orgs -#' @description Prints organizations downloaded in `GitStats`. Especially +#' @description Retrieves organizations downloaded in `GitStats`. Especially #' helpful when user is scanning whole git platform and want to have a glimpse #' at organizations. #' @param gitstats_obj A GitStats object. @@ -276,9 +276,9 @@ get_orgs <- function(gitstats_obj){ return(gitstats_obj$get_orgs()) } -#' @title Show repositories +#' @title Get repositories #' @name get_repos -#' @description Prints repositories table pulled by `GitStats`. +#' @description Retrieves repositories table pulled by `GitStats`. #' @param gitstats_obj A GitStats object. #' @return A table of repositories. #' @export @@ -286,12 +286,22 @@ get_repos <- function(gitstats_obj){ return(gitstats_obj$get_repos()) } -#' @title Show commits +#' @title Get commits #' @name get_commits -#' @description Prints commits table pulled by `GitStats`. +#' @description Retrieves commits table pulled by `GitStats`. #' @param gitstats_obj A GitStats object. #' @return A table of commits. #' @export get_commits <- function(gitstats_obj){ return(gitstats_obj$get_commits()) } + +#' @title Get users +#' @name get_users +#' @description Retrieves users table pulled by `GitStats`. +#' @param gitstats_obj A GitStats object. +#' @return A table of users. +#' @export +get_users <- function(gitstats_obj){ + return(gitstats_obj$get_users()) +} diff --git a/man/get_commits.Rd b/man/get_commits.Rd index 323072be..e6ddb7f2 100644 --- a/man/get_commits.Rd +++ b/man/get_commits.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gitstats_functions.R \name{get_commits} \alias{get_commits} -\title{Show commits} +\title{Get commits} \usage{ get_commits(gitstats_obj) } @@ -13,5 +13,5 @@ get_commits(gitstats_obj) A table of commits. } \description{ -Prints commits table pulled by \code{GitStats}. +Retrieves commits table pulled by \code{GitStats}. } diff --git a/man/get_orgs.Rd b/man/get_orgs.Rd index 4c8f06a5..7d8361ec 100644 --- a/man/get_orgs.Rd +++ b/man/get_orgs.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gitstats_functions.R \name{get_orgs} \alias{get_orgs} -\title{Show organizations} +\title{Get organizations} \usage{ get_orgs(gitstats_obj) } @@ -13,7 +13,7 @@ get_orgs(gitstats_obj) A vector of organizations. } \description{ -Prints organizations downloaded in \code{GitStats}. Especially +Retrieves organizations downloaded in \code{GitStats}. Especially helpful when user is scanning whole git platform and want to have a glimpse at organizations. } diff --git a/man/get_repos.Rd b/man/get_repos.Rd index 2380cb96..7cbe00ac 100644 --- a/man/get_repos.Rd +++ b/man/get_repos.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/gitstats_functions.R \name{get_repos} \alias{get_repos} -\title{Show repositories} +\title{Get repositories} \usage{ get_repos(gitstats_obj) } @@ -13,5 +13,5 @@ get_repos(gitstats_obj) A table of repositories. } \description{ -Prints repositories table pulled by \code{GitStats}. +Retrieves repositories table pulled by \code{GitStats}. } diff --git a/man/get_users.Rd b/man/get_users.Rd new file mode 100644 index 00000000..4979fc2d --- /dev/null +++ b/man/get_users.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gitstats_functions.R +\name{get_users} +\alias{get_users} +\title{Get users} +\usage{ +get_users(gitstats_obj) +} +\arguments{ +\item{gitstats_obj}{A GitStats object.} +} +\value{ +A table of users. +} +\description{ +Retrieves users table pulled by \code{GitStats}. +} diff --git a/tests/testthat/_snaps/GitHost.md b/tests/testthat/_snaps/05-GitHost.md similarity index 100% rename from tests/testthat/_snaps/GitHost.md rename to tests/testthat/_snaps/05-GitHost.md diff --git a/tests/testthat/_snaps/GitStats.md b/tests/testthat/_snaps/06-GitStats.md similarity index 100% rename from tests/testthat/_snaps/GitStats.md rename to tests/testthat/_snaps/06-GitStats.md diff --git a/tests/testthat/test-GitHost.R b/tests/testthat/test-05-GitHost.R similarity index 99% rename from tests/testthat/test-GitHost.R rename to tests/testthat/test-05-GitHost.R index 022b6d01..b8d07852 100644 --- a/tests/testthat/test-GitHost.R +++ b/tests/testthat/test-05-GitHost.R @@ -11,6 +11,7 @@ test_that("GitHost gets users tables", { users = c("maciekbanas", "kalimu", "galachad") ) expect_users_table(users_table) + test_mocker$cache(users_table) }) # private methods diff --git a/tests/testthat/test-GitStats.R b/tests/testthat/test-06-GitStats.R similarity index 100% rename from tests/testthat/test-GitStats.R rename to tests/testthat/test-06-GitStats.R diff --git a/tests/testthat/test-get-functions.R b/tests/testthat/test-get-functions.R index 0c11d416..75cab6b6 100644 --- a/tests/testthat/test-get-functions.R +++ b/tests/testthat/test-get-functions.R @@ -1,20 +1,26 @@ test_gitstats <- create_test_gitstats(hosts = 2) -test_that("get_orgs() shows orgs", { +test_that("get_orgs() returns orgs", { expect_equal( get_orgs(test_gitstats), c("r-world-devs", "openpharma", "mbtests") ) }) -test_that("get_repos() shows repos table", { +test_that("get_repos() returns repos table", { test_gitstats$.__enclos_env__$private$repos <- test_mocker$use("gh_repos_table") repos_table <- get_repos(test_gitstats) expect_repos_table(repos_table) }) -test_that("get_commits() shows commits table", { +test_that("get_commits() returns commits table", { test_gitstats$.__enclos_env__$private$commits <- test_mocker$use("commits_table") commits_table <- get_commits(test_gitstats) expect_commits_table(commits_table) }) + +test_that("get_users() returns users table", { + test_gitstats$.__enclos_env__$private$users <- test_mocker$use("users_table") + users_table <- get_users(test_gitstats) + expect_users_table(users_table) +}) From 8163b020e5b7a1fef806c80e1b61366a43696033 Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 12:10:35 +0000 Subject: [PATCH 5/7] Fix output of `pull_users`. --- R/GitStats.R | 11 ++++++----- tests/testthat/test-06-GitStats.R | 3 ++- tests/testthat/test-pull_users.R | 15 +-------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/R/GitStats.R b/R/GitStats.R index b5c5e70b..88ffeb9b 100644 --- a/R/GitStats.R +++ b/R/GitStats.R @@ -20,10 +20,10 @@ GitStats <- R6::R6Class("GitStats", #' pulling. #' @return Nothing. set_params = function(search_param, - team_name, - phrase, - language, - print_out) { + team_name, + phrase, + language, + print_out) { search_param <- match.arg( search_param, c("org", "team", "phrase") @@ -209,7 +209,8 @@ GitStats <- R6::R6Class("GitStats", unique() %>% purrr::list_rbind() private$users <- users_table - return(users_table) + if (private$settings$print_out) dplyr::glimpse(users_table) + return(invisible(self)) }, #' @description Print organizations. diff --git a/tests/testthat/test-06-GitStats.R b/tests/testthat/test-06-GitStats.R index ce48a1e5..0f494347 100644 --- a/tests/testthat/test-06-GitStats.R +++ b/tests/testthat/test-06-GitStats.R @@ -47,9 +47,10 @@ test_that("check_for_host works", { test_that("GitStats get users info", { test_gitstats <- create_test_gitstats(hosts = 2) - users_result <- test_gitstats$pull_users( + test_gitstats$pull_users( c("maciekbanas", "kalimu", "marcinkowskak") ) + users_result <- get_users(test_gitstats) expect_users_table( users_result ) diff --git a/tests/testthat/test-pull_users.R b/tests/testthat/test-pull_users.R index 121b5371..68240b9d 100644 --- a/tests/testthat/test-pull_users.R +++ b/tests/testthat/test-pull_users.R @@ -7,20 +7,7 @@ test_that("pull_users shows error when no hosts are defined", { }) test_that("pull_users works as expected", { - test_gitstats <- create_gitstats() - suppressMessages({ - test_gitstats$set_host( - api_url = "https://api.github.com", - token = Sys.getenv("GITHUB_PAT"), - orgs = c("r-world-devs", "openpharma") - ) - - test_gitstats$set_host( - api_url = "https://gitlab.com/api/v4", - token = Sys.getenv("GITLAB_PAT_PUBLIC"), - orgs = "mbtests" - ) - }) + test_gitstats <- create_test_gitstats(hosts = 2) pull_users(test_gitstats, c("maciekbanas", "kalimu")) users_table <- test_gitstats$get_users() From 59a1ed1da560e334f6993b9dc3676fa39e46f514 Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 12:17:11 +0000 Subject: [PATCH 6/7] Update Readme, remove example workflow. Example not needed anymore - Readme covers the examples. --- README.Rmd | 100 +++++++++++++++---- README.md | 209 +++++++++++++++++++++++++++++++-------- devel/example_workflow.R | 151 ---------------------------- 3 files changed, 247 insertions(+), 213 deletions(-) delete mode 100644 devel/example_workflow.R diff --git a/README.Rmd b/README.Rmd index 4816f6f1..fde90109 100644 --- a/README.Rmd +++ b/README.Rmd @@ -43,15 +43,40 @@ library(GitStats) git_stats <- create_gitstats() %>% set_host( api_url = "https://api.github.com", - orgs = c("r-world-devs", "openpharma") + orgs = c("r-world-devs", "openpharma"), + token = Sys.getenv("GITHUB_PAT") ) %>% set_host( api_url = "https://gitlab.com/api/v4", - orgs = c("mbtests") + orgs = c("mbtests"), + token = Sys.getenv("GITLAB_PAT_PUBLIC") ) ``` -## Setup +By default your search preferences are set to `organizations` (`org`). + +```{r} +git_stats + +pull_repos( + git_stats +) + +pull_commits( + git_stats, + date_from = "2023-01-01", + date_until = "2023-03-31" +) +``` + +Finally you can retrieve your repos to separate object. + +```{r} +repos_dt <- get_repos(git_stats) +commits_dt <- get_commits(git_stats) +``` + +## Set You can setup your search preferences, either to `org`, `team` or `phrase`. @@ -60,39 +85,75 @@ You can setup your search preferences, either to `org`, `team` or `phrase`. If you with to setup your search parameter to team, add your team members first: ```{r} + git_stats %>% set_team_member("Kamil Wais", "kalimu") %>% set_team_member("Krystian Igras", "krystian8207") %>% set_team_member("Karolina Marcinkowska", "marcinkowskak") %>% set_team_member("Kamil Koziej", "Cotau") %>% - set_team_member("Maciej Banaś", "maciekbanas") - -setup(git_stats, - search_param = "team", - team_name = "RWD" -) - -# now pull repos and commits by default by team -get_repos(git_stats) - -pull_commits(git_stats, + set_team_member("Maciej Banaś", "maciekbanas") %>% + set_params( + search_param = "team", + team_name = "RWD" + ) %>% + pull_repos() + +pull_commits( + gitstats_obj = git_stats, date_from = "2023-01-01", date_until = "2023-03-31" ) ``` -### Keyword +### Phrase With `GitStats` you can look for the repos with a certain phrase in code blobs. ```{r} -setup(git_stats, +set_params( + gitstats_obj = git_stats, search_param = "phrase", phrase = "shiny" +) %>% + pull_repos() +``` + +### Language + +You can define a programming language in your settings. + +```{r} +set_params( + gitstats_obj = git_stats, + search_param = "org", + language = "JavaScript" +) %>% + pull_repos() +``` + +You can always get back to All languages. + +```{r} +reset_language(git_stats) +``` + +## Users + +You can retrieve data about users with GitStats. + +```{r} +pull_users( + gitstats_obj = git_stats, + users = c("maciekbanas", "kalimu", "Cotau", "marcinkowskak", "@krystian8207") ) +``` + +## Reset your settings -# now pull repos by default by phrase -get_repos(git_stats) +If you wish to get back to default settings, run: + +```{r} +reset(git_stats) ``` ### Acknowledgement @@ -101,6 +162,7 @@ Special thanks to: - Kamil Koziej @Cotau - for reviewing permanently my pull requests and suggesting more efficient solutions, - Karolina Marcinkowska @marcinkowskak - for substantial improvements on plots, +- Krystian Igraś @krystian8207 - for the major review of GitStats and, - Matt Secrest @mattsecrest - for making use of your scripts to apply search feature, -- Kamil Wais @kalimu, Krystian Igraś @krystian8207, Adam Foryś @galachad - for your guidelines at the very beginning of the project. +- Kamil Wais @kalimu, Adam Foryś @galachad - for your guidelines at the very beginning of the project. diff --git a/README.md b/README.md index c0ffa8ec..f623e50e 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,73 @@ library(GitStats) git_stats <- create_gitstats() %>% set_host( api_url = "https://api.github.com", - orgs = c("r-world-devs", "openpharma") + orgs = c("r-world-devs", "openpharma"), + token = Sys.getenv("GITHUB_PAT") ) %>% set_host( api_url = "https://gitlab.com/api/v4", - orgs = c("mbtests") + orgs = c("mbtests"), + token = Sys.getenv("GITLAB_PAT_PUBLIC") ) ``` -## Setup +By default your search preferences are set to `organizations` (`org`). + +``` r +git_stats +#> A object for 2 hosts: +#> Hosts: https://api.github.com, https://gitlab.com/api/v4 +#> Organisations: [3] r-world-devs, openpharma, mbtests +#> Search preference: org +#> Team: +#> Phrase: +#> Language: All +#> Repositories output: +#> Commits output: + +pull_repos( + git_stats +) +#> Rows: 65 +#> Columns: 12 +#> $ id "R_kgDOHNMr2w", "R_kgDOHYNOFQ", "R_kgDOHYNrJw", "R_kg… +#> $ name "shinyGizmo", "cohortBuilder", "shinyCohortBuilder", … +#> $ stars 16, 3, 5, 0, 1, 2, 0, 2, 7, 176, 4, 10, 1, 19, 0, 1, … +#> $ forks 0, 2, 0, 0, 0, 0, 0, 0, 4, 31, 1, 1, 0, 4, 1, 1, 0, 0… +#> $ created_at 2022-04-20 10:04:32, 2022-05-22 18:31:55, 2022-05-22… +#> $ last_activity_at 129.51 days, 132.51 days, 17.51 days, 412.51 days, 0… +#> $ languages "R, CSS, JavaScript", "R", "R, CSS, JavaScript, SCSS"… +#> $ issues_open 6, 22, 32, 3, 79, 0, 0, 3, 6, 16, 0, 0, 0, 4, 0, 0, 0… +#> $ issues_closed 12, 1, 4, 0, 115, 0, 0, 0, 1, 167, 0, 0, 0, 16, 0, 0,… +#> $ organization "r-world-devs", "r-world-devs", "r-world-devs", "r-wo… +#> $ repo_url "https://github.com/r-world-devs/shinyGizmo", "https:… +#> $ api_url "https://api.github.com/repositories/r-world-devs/shi… + +pull_commits( + git_stats, + date_from = "2023-01-01", + date_until = "2023-03-31" +) +#> Rows: 798 +#> Columns: 8 +#> $ id "C_kwDOHNMr29oAKGI3ZmRlYTNkNjY0NmM2MmRmMzA0N2Y0NDhkODQy… +#> $ committed_date 2023-03-01 15:05:10, 2023-03-01 14:58:22, 2023-02-28 1… +#> $ author "Krystian Igras", "Krystian Igras", "Krystian Igras", "… +#> $ additions 296, 18, 10, 29, 8, 17, 1, 11, 267, 876, 1, 6, 3, 20, 1… +#> $ deletions 153, 11, 7, 14, 4, 8, 1, 5, 146, 146, 1, 4, 3, 9, 107, … +#> $ repository "shinyGizmo", "shinyGizmo", "shinyGizmo", "shinyGizmo",… +#> $ organization "r-world-devs", "r-world-devs", "r-world-devs", "r-worl… +#> $ api_url "https://api.github.com", "https://api.github.com", "ht… +``` + +Finally you can retrieve your repos to separate object. + +``` r +repos_dt <- get_repos(git_stats) +commits_dt <- get_commits(git_stats) +``` + +## Set You can setup your search preferences, either to `org`, `team` or `phrase`. @@ -58,29 +116,18 @@ If you with to setup your search parameter to team, add your team members first: ``` r + git_stats %>% set_team_member("Kamil Wais", "kalimu") %>% set_team_member("Krystian Igras", "krystian8207") %>% set_team_member("Karolina Marcinkowska", "marcinkowskak") %>% set_team_member("Kamil Koziej", "Cotau") %>% - set_team_member("Maciej Banaś", "maciekbanas") - -setup(git_stats, - search_param = "team", - team_name = "RWD" -) -#> A object for 2 hosts: -#> Hosts: https://api.github.com, https://gitlab.com/api/v4 -#> Organisations: [3] r-world-devs, openpharma, mbtests -#> Search preference: team -#> Team: RWD (5 members) -#> Phrase: -#> Language: All -#> Repositories output: -#> Commits output: - -# now pull repos and commits by default by team -get_repos(git_stats) + set_team_member("Maciej Banaś", "maciekbanas") %>% + set_params( + search_param = "team", + team_name = "RWD" + ) %>% + pull_repos() #> Rows: 18 #> Columns: 13 #> $ id "R_kgDOIvtxsg", "R_kgDOJAtHJA", "R_kgDOHNMr2w", "R_kg… @@ -88,16 +135,17 @@ get_repos(git_stats) #> $ stars 1, 2, 16, 3, 5, 2, 10, 22, 2, 0, 0, 0, 0, 0, 0, 0, 0,… #> $ forks 0, 0, 0, 2, 0, 0, 1, 5, 1, NA, NA, NA, NA, NA, NA, NA… #> $ created_at 2023-01-09 14:02:20, 2023-02-21 16:41:59, 2022-04-20… -#> $ last_activity_at 0.52 days, 124.52 days, 121.52 days, 124.52 days, 9.… +#> $ last_activity_at 0.51 days, 132.51 days, 129.51 days, 132.51 days, 17… #> $ languages "R", "R, CSS", "R, CSS, JavaScript", "R", "R, CSS, Ja… -#> $ issues_open 78, 0, 5, 22, 32, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1,… -#> $ issues_closed 113, 0, 12, 1, 4, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,… +#> $ issues_open 79, 0, 6, 22, 32, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1,… +#> $ issues_closed 115, 0, 12, 1, 4, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,… #> $ organization "r-world-devs", "r-world-devs", "r-world-devs", "r-wo… #> $ repo_url "https://github.com/r-world-devs/GitStats", "https://… #> $ api_url "https://api.github.com/repositories/r-world-devs/Git… #> $ contributors "maciekbanas, Cotau", "krystian8207", "krystian8207, … -pull_commits(git_stats, +pull_commits( + gitstats_obj = git_stats, date_from = "2023-01-01", date_until = "2023-03-31" ) @@ -113,28 +161,18 @@ pull_commits(git_stats, #> $ api_url "https://api.github.com", "https://api.github.com", "ht… ``` -### Keyword +### Phrase With `GitStats` you can look for the repos with a certain phrase in code blobs. ``` r -setup(git_stats, +set_params( + gitstats_obj = git_stats, search_param = "phrase", phrase = "shiny" -) -#> A object for 2 hosts: -#> Hosts: https://api.github.com, https://gitlab.com/api/v4 -#> Organisations: [3] r-world-devs, openpharma, mbtests -#> Search preference: phrase -#> Team: RWD (5 members) -#> Phrase: shiny -#> Language: All -#> Repositories output: Rows number: 18 -#> Commits output: Since: 2023-01-09 14:54:35; Until: 2023-03-30 14:35:34; Rows number: 398 - -# now pull repos by default by phrase -get_repos(git_stats) +) %>% + pull_repos() #> Rows: 4 #> Columns: 12 #> $ id "495151911", "586903986", "431378047", "512764983" @@ -142,7 +180,7 @@ get_repos(git_stats) #> $ stars 5, 1, 2, 0 #> $ forks 0, 0, 0, 0 #> $ created_at 2022-05-22 19:04:12, 2023-01-09 14:02:20, 2021-11-24 … -#> $ last_activity_at 9.18 days, 0.01 days, 571.97 days, 116.97 days +#> $ last_activity_at 17.17 days, 0.00 days, 579.96 days, 124.95 days #> $ languages "R", "R", "R", "Python" #> $ issues_open 30, 30, 0, 0 #> $ issues_closed 0, 0, 0, 0 @@ -151,6 +189,90 @@ get_repos(git_stats) #> $ api_url "https://api.github.com/repos/r-world-devs/shinyCoho… ``` +### Language + +You can define a programming language in your settings. + +``` r +set_params( + gitstats_obj = git_stats, + search_param = "org", + language = "JavaScript" +) %>% + pull_repos() +#> Rows: 6 +#> Columns: 12 +#> $ id "R_kgDOHNMr2w", "R_kgDOHYNrJw", "R_kgDOJWYrCA", "MDEw… +#> $ name "shinyGizmo", "shinyCohortBuilder", "hypothesis", "fa… +#> $ stars 16, 5, 2, 4, 0, 3 +#> $ forks 0, 0, 0, 0, 0, 0 +#> $ created_at 2022-04-20 10:04:32, 2022-05-22 19:04:12, 2023-04-13 … +#> $ last_activity_at 129.51 days, 17.51 days, 57.51 days, 1018.51 days, 44… +#> $ languages "R, CSS, JavaScript", "R, CSS, JavaScript, SCSS", "R… +#> $ issues_open 6, 32, 3, 1, 0, 2 +#> $ issues_closed 12, 4, 0, 0, 0, 2 +#> $ organization "r-world-devs", "r-world-devs", "r-world-devs", "ope… +#> $ repo_url "https://github.com/r-world-devs/shinyGizmo", "https:… +#> $ api_url "https://api.github.com/repositories/r-world-devs/shi… +``` + +You can always get back to All languages. + +``` r +reset_language(git_stats) +#> A object for 2 hosts: +#> Hosts: https://api.github.com, https://gitlab.com/api/v4 +#> Organisations: [3] r-world-devs, openpharma, mbtests +#> Search preference: org +#> Team: RWD (5 members) +#> Phrase: shiny +#> Language: All +#> Repositories output: Rows number: 6 +#> Commits output: Since: 2023-01-09 14:54:35; Until: 2023-03-30 14:35:34; Rows number: 398 +``` + +## Users + +You can retrieve data about users with GitStats. + +``` r +pull_users( + gitstats_obj = git_stats, + users = c("maciekbanas", "kalimu", "Cotau", "marcinkowskak", "@krystian8207") +) +#> Rows: 7 +#> Columns: 12 +#> $ id "MDQ6VXNlcjc0MjEyOTMz", "MDQ6VXNlcjI1MjIyMzY=", "MDQ6VXN… +#> $ name "Maciej Banaś", "Kamil Wais", "", "Karolina Marcinkowska… +#> $ login "maciekbanas", "kalimu", "Cotau", "marcinkowskak", "maci… +#> $ email "", "kamil.wais@gmail.com", "", "", "", "", "" +#> $ location "", "Rzeszów", "", "Warsaw, Poland", "", "", "" +#> $ starred_repos 15, 80, 1, 0, 0, 0, 0 +#> $ commits 435, 0, 1, 0, NA, NA, NA +#> $ issues 201, 0, 2, 1, NA, NA, NA +#> $ pull_requests 98, 1, 6, 2, 1, 0, 0 +#> $ reviews 4, 0, 27, 12, 0, 0, 0 +#> $ avatar_url "https://avatars.githubusercontent.com/u/74212933?u=f85d… +#> $ web_url "", "kalimu.github.io", "", "", "https://gitlab.com/maci… +``` + +## Reset your settings + +If you wish to get back to default settings, run: + +``` r +reset(git_stats) +#> A object for 2 hosts: +#> Hosts: https://api.github.com, https://gitlab.com/api/v4 +#> Organisations: [3] r-world-devs, openpharma, mbtests +#> Search preference: org +#> Team: +#> Phrase: +#> Language: All +#> Repositories output: Rows number: 6 +#> Commits output: Since: 2023-01-09 14:54:35; Until: 2023-03-30 14:35:34; Rows number: 398 +``` + ### Acknowledgement Special thanks to: @@ -159,7 +281,8 @@ Special thanks to: suggesting more efficient solutions, - Karolina Marcinkowska @marcinkowskak - for substantial improvements on plots, +- Krystian Igraś @krystian8207 - for the major review of GitStats and, - Matt Secrest @mattsecrest - for making use of your scripts to apply search feature, -- Kamil Wais @kalimu, Krystian Igraś @krystian8207, Adam Foryś - @galachad - for your guidelines at the very beginning of the project. +- Kamil Wais @kalimu, Adam Foryś @galachad - for your guidelines at the + very beginning of the project. diff --git a/devel/example_workflow.R b/devel/example_workflow.R deleted file mode 100644 index d2c44e42..00000000 --- a/devel/example_workflow.R +++ /dev/null @@ -1,151 +0,0 @@ -#file with example workflow for basic package functionality - will be helpful later tu build vignettes -pkgload::load_all() - -# Start by creating your GitStats object and setting connections. -git_stats <- create_gitstats() %>% - set_host( - api_url = "https://api.github.com", - orgs = c("r-world-devs", "openpharma") - ) %>% - set_host( - api_url = "https://gitlab.com/api/v4", - orgs = c("mbtests", "gitlab-org") - ) - -git_stats - -# examples for getting repos (default search parameter is 'org') -pull_repos(git_stats) -pull_repos_contributors(git_stats) -dplyr::glimpse(get_repos(git_stats)) - -pull_repos(git_stats, add_contributors = TRUE) - -pull_commits(git_stats, date_from = "2022-01-01") - -# setup your language you are interested in -set_params( - git_stats, - language = "Python" -) -pull_repos(git_stats) - -# set your team members -git_stats %>% - set_team_member("Adam Foryś", "galachad") %>% - set_team_member("Kamil Wais", "kalimu") %>% - set_team_member("Krystian Igras", "krystian8207") %>% - set_team_member("Karolina Marcinkowska", "marcinkowskak") %>% - set_team_member("Kamil Koziej", "Cotau") %>% - set_team_member("Maciej Banaś", "maciekbanas") - -# You can set your search preferences -set_params( - git_stats, - search_param = "team", - team_name = "RWD", - language = "R" -) - -# now pull repos by default by team -pull_repos(git_stats) -get_repos(git_stats) -pull_commits(git_stats, date_from = "2020-01-01") - -reset_language(git_stats) - -# Change your settings to searches by phrase: -set_params( - git_stats, - search_param = "phrase", - phrase = "shiny" -) - -# Search by phrase -pull_repos(git_stats) - -# you can plot repos sorted by last activity -plot_repos(git_stats) - -# error should pop out when search param set to 'phrase': -pull_commits(git_stats, date_from = "2020-01-01") - -reset(git_stats) - -# now it should work -pull_commits(git_stats, date_from = "2020-01-01") - -# examples for plotting commits -plot_commits(git_stats) - -# get information on users -git_stats %>% - pull_users(c("maciekbanas", "kalimu", "marcinkowskak", "Cotau", "krystian8207")) -git_stats$get_users() - -# SHOWCASES - -# throws sometimes 502 Bad Gateway error (GraphQL one) -# should switch to REST if that is the case - -create_gitstats() %>% - set_host( - api_url = "https://api.github.com", - token = Sys.getenv("GITHUB_PAT"), - orgs = c("insightsengineering") - ) %>% get_repos() - -# one token does not exist - -git_stats <- create_gitstats() %>% - set_host( - api_url = "https://api.github.com", - token = Sys.getenv("DOES_NOT_EXIST"), - orgs = c("r-world-devs", "openpharma") - ) %>% - set_host( - api_url = "https://gitlab.com/api/v4", - token = Sys.getenv("GITLAB_PAT_PUBLIC"), - orgs = c("mbtests", "erasmusmc-public-health") - ) -git_stats - -# a token exists but does not grant access - -git_stats <- create_gitstats() %>% - set_host( - api_url = "https://api.github.com", - token = Sys.getenv("GITHUB_PAT"), - orgs = c("r-world-devs", "openpharma") - ) %>% - set_host( - api_url = "https://gitlab.com/api/v4", - token = Sys.getenv("GITLAB_PAT"), - orgs = c("mbtests", "erasmusmc-public-health") - ) -git_stats - -# wrong orgs - -git_stats <- create_gitstats() %>% - set_host( - api_url = "https://api.github.com", - token = Sys.getenv("GITHUB_PAT"), - orgs = c("rworlddevs", "openpharma") - ) %>% - set_host( - api_url = "https://gitlab.com/api/v4", - token = Sys.getenv("GITLAB_PAT_PUBLIC"), - orgs = c("mbtests", "public health") - ) -git_stats - -## add gitlab subgroups - -git_stats <- create_gitstats() %>% - set_host( - api_url = "https://gitlab.com/api/v4", - token = Sys.getenv("GITLAB_PAT_PUBLIC"), - orgs = "mbtests/subgroup" - ) -git_stats From 645cf6d9d2d6f3513a82149661916374353e45e5 Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Thu, 14 Sep 2023 12:33:20 +0000 Subject: [PATCH 7/7] Try fix cmd-check tests. --- tests/testthat/test-06-GitStats.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-06-GitStats.R b/tests/testthat/test-06-GitStats.R index 0f494347..98c960ed 100644 --- a/tests/testthat/test-06-GitStats.R +++ b/tests/testthat/test-06-GitStats.R @@ -89,6 +89,7 @@ suppressMessages( test_gitstats <- create_gitstats() %>% set_host( api_url = "https://gitlab.com/api/v4", + token = Sys.getenv("GITLAB_PAT_PUBLIC"), orgs = "mbtests/subgroup" ) )