diff --git a/NAMESPACE b/NAMESPACE index d35e3789..e4a5b3ae 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,7 +13,9 @@ export(reset_language) export(set_host) export(set_team_member) export(setup) +export(show_commits) export(show_orgs) +export(show_repos) importFrom(R6,R6Class) importFrom(cli,cli_abort) importFrom(cli,cli_alert_danger) diff --git a/R/gitstats_functions.R b/R/gitstats_functions.R index b4263583..8447dcc2 100644 --- a/R/gitstats_functions.R +++ b/R/gitstats_functions.R @@ -275,3 +275,23 @@ reset_language <- function(gitstats_obj){ show_orgs <- function(gitstats_obj){ return(gitstats_obj$show_orgs()) } + +#' @title Show repositories +#' @name show_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()) +} + +#' @title Show commits +#' @name show_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()) +} diff --git a/devel/example_workflow.R b/devel/example_workflow.R index bf0fcca4..a6be4e11 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') get_repos(git_stats) get_repos_contributors(git_stats) -dplyr::glimpse(git_stats$show_repos()) +dplyr::glimpse(show_repos(git_stats)) get_repos(git_stats, add_contributors = TRUE) diff --git a/man/show_commits.Rd b/man/show_commits.Rd new file mode 100644 index 00000000..f8b113e6 --- /dev/null +++ b/man/show_commits.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gitstats_functions.R +\name{show_commits} +\alias{show_commits} +\title{Show commits} +\usage{ +show_commits(gitstats_obj) +} +\arguments{ +\item{gitstats_obj}{A GitStats object.} +} +\value{ +A table of commits. +} +\description{ +Prints commits table pulled by \code{GitStats}. +} diff --git a/man/show_repos.Rd b/man/show_repos.Rd new file mode 100644 index 00000000..fd1f4aa4 --- /dev/null +++ b/man/show_repos.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gitstats_functions.R +\name{show_repos} +\alias{show_repos} +\title{Show repositories} +\usage{ +show_repos(gitstats_obj) +} +\arguments{ +\item{gitstats_obj}{A GitStats object.} +} +\value{ +A table of repositories. +} +\description{ +Prints repositories table pulled by \code{GitStats}. +} diff --git a/tests/testthat/test-show.R b/tests/testthat/test-show.R index e922f4c6..0b3734f3 100644 --- a/tests/testthat/test-show.R +++ b/tests/testthat/test-show.R @@ -1,7 +1,20 @@ +test_gitstats <- create_test_gitstats(hosts = 2) + test_that("show_orgs() shows orgs", { - test_gitstats <- create_test_gitstats(hosts = 2) expect_equal( show_orgs(test_gitstats), c("r-world-devs", "openpharma", "mbtests") ) }) + +test_that("show_repos() shows repos table", { + test_gitstats$.__enclos_env__$private$repos <- test_mocker$use("gh_repos_table") + repos_table <- show_repos(test_gitstats) + expect_repos_table(repos_table) +}) + +test_that("show_commits() shows commits table", { + test_gitstats$.__enclos_env__$private$commits <- test_mocker$use("commits_table") + commits_table <- show_commits(test_gitstats) + expect_commits_table(commits_table) +})