Skip to content

Commit

Permalink
Revert "Revert dev_package_deps new arguments"
Browse files Browse the repository at this point in the history
This reverts commit bee893b.
  • Loading branch information
gaborcsardi committed Mar 21, 2024
1 parent 27299c0 commit ac483e7
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 21 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
credential store, if `GITHUB_PAT` and `GITHUB_TOKEN` are not set.
* The `Remotes` field in `DESCRIPTION` now accepts explicit package names:
`<pkgname>=<type>::<username>/<repo>` (#719, @heavywatal).
* `dev_package_deps()` noq has a `remote_precedence` parameter which allows
the user to choose whether remote sources should have a priority over
CRAN sources (#732, @maksymiuks).
* `dev_package_deps()` now works for packages with `Enhances` dependencies
(#711, @maksymiuks).
* `dev_package_deps()` now has an `additional_repositories` parameter
which allows the user to choose whether `Additional_repositories` should
be extracted from the `DESCRIPTION` file and appended to repos
(#782, @maksymiuks).
* `install_dev()` now ignores a trailing slash (#692, @krlmlr).
* System requirements now support Ubuntu 22.04.
* `local_package_deps()` now errors for non-existent directories
Expand Down
23 changes: 17 additions & 6 deletions R/deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#' "always" and "never" respectively.
#' @param repos A character vector giving repositories to use.
#' @param type Type of package to `update`.
#'
#' @param remote_precedence A logical flag specifying whether remote sources should take precedence over
#' CRAN when both were found.
#' @param additional_repositories A logical flag specifying whether `Additional_repositories` should
#' be extracted from the DESCRIPTION and appended to `repos`.
#' @param object A `package_deps` object.
#' @param ... Additional arguments passed to `install_packages`.
#' @inheritParams install_github
Expand Down Expand Up @@ -122,10 +125,12 @@ local_package_deps <- function(pkgdir = ".", dependencies = NA) {

dev_package_deps <- function(pkgdir = ".", dependencies = NA,
repos = getOption("repos"),
type = getOption("pkgType")) {
type = getOption("pkgType"),
remote_precedence = TRUE,
additional_repositories = TRUE) {

pkg <- load_pkg_description(pkgdir)
repos <- c(repos, parse_additional_repositories(pkg))
repos <- c(repos, if (additional_repositories) parse_additional_repositories(pkg))

deps <- local_package_deps(pkgdir = pkgdir, dependencies = dependencies)

Expand All @@ -140,14 +145,14 @@ dev_package_deps <- function(pkgdir = ".", dependencies = NA,

cran_deps <- package_deps(deps, repos = repos, type = type)

res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes"))
res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes"), remote_precedence)

res <- do.call(rbind, c(list(res), lapply(get_extra_deps(pkg, dependencies), extra_deps, pkg = pkg), stringsAsFactors = FALSE))

res[is.na(res$package) | !duplicated(res$package, fromLast = TRUE), ]
}

combine_remote_deps <- function(cran_deps, remote_deps) {
combine_remote_deps <- function(cran_deps, remote_deps, remote_precedence) {
# If there are no dependencies there will be no remote dependencies either,
# so just return them (and don't force the remote_deps promise)
if (nrow(cran_deps) == 0) {
Expand All @@ -158,7 +163,13 @@ combine_remote_deps <- function(cran_deps, remote_deps) {
remote_deps <- remote_deps[is.na(remote_deps$package) | remote_deps$package %in% cran_deps$package, ]

# If there are remote deps remove the equivalent CRAN deps
cran_deps <- cran_deps[!(cran_deps$package %in% remote_deps$package), ]
if (remote_precedence) {
cran_deps <- cran_deps[!(cran_deps$package %in% remote_deps$package), ]
# Otherwise remove remotes already covered by CRAN
} else {
remote_deps <- remote_deps[!(remote_deps$package %in% cran_deps$package), ]
}


rbind(remote_deps, cran_deps)
}
Expand Down
23 changes: 17 additions & 6 deletions inst/install-github.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions install-github.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/install_bitbucket.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/package_deps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac483e7

Please sign in to comment.