Skip to content

Instantly share code, notes, and snippets.

@topepo
Created January 31, 2022 16:27
Show Gist options
  • Save topepo/4c57cfcabcf750752d67202545e15620 to your computer and use it in GitHub Desktop.
Save topepo/4c57cfcabcf750752d67202545e15620 to your computer and use it in GitHub Desktop.
Check to see if a repo has remote dependencies
#' Check to see if a repo has remote dependencies.
#' @param repos A character vector of repos to query (e.g. `tidyverse/dplyr`).
#' @param hard_depend Should only depends and imports be included in the query.
#' Using `FALSE` will include suggests and others.
#' @details Packages listed in `Config/Needs/*` will not be returned.
#' Requires dplyr, pak, and purrr.
#' @return A tibble with columns for the repo and any github repos that are
#' listed as dependencies.
#' @examples
#' tests <- paste0("tidymodels/", c("broom", "parsnip", "recipes"))
#' check_for_remotes(tests)
check_for_remotes <- function(repos, hard_depend = FALSE) {
require(dplyr)
if (hard_depend) {
deps <- list(direct = "hard", indirect = character())
} else {
deps <- list(direct = "all", indirect = character())
}
descrs <-
purrr::map(repos, ~ pak::pkg_deps(.x, dependencies = deps)) %>%
purrr::map2_dfr(repos, ~ mutate(.x, repo = .y)) %>%
select(repo, type, github_dependency = package, remote = ref) %>%
filter(type == "github" & repo != remote) %>%
select(repo, github_dependency)
descrs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment