diff --git a/R/GitHost.R b/R/GitHost.R index 4717d5d..9d7015e 100644 --- a/R/GitHost.R +++ b/R/GitHost.R @@ -720,16 +720,29 @@ GitHost <- R6::R6Class( information = "Pulling repositories" ) } - repos_response <- private$get_repos_response_with_code( - code = code, - in_files = in_files, - in_path = in_path, - output = output, - verbose = verbose, - progress = progress - ) + rest_engine <- private$engines$rest + if (is.null(in_files)) { + repos_response <- rest_engine$get_repos_by_code( + code = code, + in_path = in_path, + output = output, + verbose = verbose, + progress = progress + ) + } else { + repos_response <- purrr::map(in_files, function(filename) { + rest_engine$get_repos_by_code( + code = code, + filename = filename, + in_path = in_path, + output = output, + verbose = verbose, + progress = progress + ) + }) %>% + purrr::list_flatten() + } if (output != "raw") { - rest_engine <- private$engines$rest repos_table <- repos_response %>% rest_engine$tailor_repos_response( output = output @@ -792,7 +805,6 @@ GitHost <- R6::R6Class( purrr::list_flatten() } if (output != "raw") { - rest_engine <- private$engines$rest repos_table <- repos_response %>% rest_engine$tailor_repos_response( output = output diff --git a/tests/testthat/test-01-get_repos-GitHub.R b/tests/testthat/test-01-get_repos-GitHub.R index 4e1856a..6111ee3 100644 --- a/tests/testthat/test-01-get_repos-GitHub.R +++ b/tests/testthat/test-01-get_repos-GitHub.R @@ -324,6 +324,7 @@ test_that("`get_repos_with_code_from_orgs()` pulls raw response", { ) repos_with_code_from_orgs_raw <- github_testhost_priv$get_repos_with_code_from_orgs( code = "shiny", + in_files = c("DESCRIPTION", "NAMESPACE"), output = "raw", verbose = FALSE ) @@ -331,6 +332,22 @@ test_that("`get_repos_with_code_from_orgs()` pulls raw response", { expect_gt(length(repos_with_code_from_orgs_raw), 0) }) +test_that("`get_repos_with_code_from_host()` pulls raw response", { + mockery::stub( + github_testhost_priv$get_repos_with_code_from_host, + "rest_engine$get_repos_by_code", + test_mocker$use("gh_repos_by_code_raw") + ) + repos_with_code_from_host_raw <- github_testhost_priv$get_repos_with_code_from_host( + code = "shiny", + in_files = c("DESCRIPTION", "NAMESPACE"), + output = "raw", + verbose = FALSE + ) + expect_type(repos_with_code_from_host_raw, "list") + expect_gt(length(repos_with_code_from_host_raw), 0) +}) + test_that("get_repos_with_code() works", { mockery::stub( github_testhost_priv$get_repos_with_code,