Skip to content

Commit

Permalink
Pass all authentication and build arguments to dependencies
Browse files Browse the repository at this point in the history
We now pass all authentication arguments and build arguments to remotes
and dependencies. This means you can supply the authentication
in in the top level `install_()` call and have that same authentication
be used in downstream Remotes.

This also should propagate upgrade to dependencies appropriately, so
setting `upgrade = FALSE` should disable upgrading for all dependencies,
even grandchildren.

Fixes r-lib#53
Fixes r-lib#86
Fixes r-lib#87
  • Loading branch information
jimhester committed Aug 29, 2018
1 parent c1d9e0f commit ef92888
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 24 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Expand Up @@ -5,6 +5,9 @@

# Development

* `install_()` functions now pass arguments, including authentication
information and upgrade down to dependencies (#53, #86, #87).

* `install_()` functions now return the name of the package(s) which were
installed (#55).

Expand Down
18 changes: 7 additions & 11 deletions R/deps.R
Expand Up @@ -111,7 +111,7 @@ local_package_deps <- function(pkgdir = ".", dependencies = NA) {

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

pkg <- load_pkg_description(pkgdir)
repos <- c(repos, parse_additional_repositories(pkg))
Expand All @@ -129,7 +129,7 @@ dev_package_deps <- function(pkgdir = ".", dependencies = NA,

combine_deps(
package_deps(deps, repos = repos, type = type),
remote_deps(pkg))
remote_deps(pkg, ...))
}

combine_deps <- function(cran_deps, remote_deps) {
Expand Down Expand Up @@ -280,11 +280,7 @@ update.package_deps <- function(object, ..., quiet = FALSE, upgrade = TRUE) {

install_packages <- function(packages, repos = getOption("repos"),
type = getOption("pkgType"), ...,
dependencies = FALSE, quiet = NULL,
# These are options to `install()` used when
# installing remotes, but can get passed to us by
# `...` so we just ignore them here
build, build_opts) {
dependencies = FALSE, quiet = NULL) {

if (is.null(quiet))
quiet <- !identical(type, "source")
Expand Down Expand Up @@ -381,7 +377,7 @@ fix_repositories <- function(repos) {
repos
}

parse_one_remote <- function(x) {
parse_one_remote <- function(x, ...) {
pieces <- strsplit(x, "::", fixed = TRUE)[[1]]

if (length(pieces) == 1) {
Expand All @@ -397,7 +393,7 @@ parse_one_remote <- function(x) {
fun <- get(paste0(tolower(type), "_remote"),
envir = asNamespace("remotes"), mode = "function", inherits = FALSE)

res <- fun(repo)
res <- fun(repo, ...)
}, error = function(e) stop("Unknown remote type: ", type, "\n ", conditionMessage(e), call. = FALSE)
)
res
Expand All @@ -412,13 +408,13 @@ split_remotes <- function(x) {
}


remote_deps <- function(pkg) {
remote_deps <- function(pkg, ...) {
if (!has_dev_remotes(pkg)) {
return(NULL)
}

dev_packages <- split_remotes(pkg[["remotes"]])
remote <- lapply(dev_packages, parse_one_remote)
remote <- lapply(dev_packages, parse_one_remote, ...)

package <- vapply(remote, remote_package_name, character(1), USE.NAMES = FALSE)
installed <- vapply(package, local_sha, character(1), USE.NAMES = FALSE)
Expand Down
4 changes: 2 additions & 2 deletions R/install-bitbucket.R
Expand Up @@ -38,10 +38,10 @@ install_bitbucket <- function(repo, ref = "master", subdir = NULL,
remotes <- lapply(repo, bitbucket_remote, ref = ref,
subdir = subdir, auth_user = auth_user, password = password, host = host)

install_remotes(remotes, ...)
install_remotes(remotes, auth_user = auth_user, password = password, host = host, ...)
}

bitbucket_remote <- function(repo, ref = NULL, subdir = NULL,
bitbucket_remote <- function(repo, ref = "master", subdir = NULL,
auth_user = NULL, password = NULL, sha = NULL,
host = NULL) {

Expand Down
4 changes: 2 additions & 2 deletions R/install-github.R
Expand Up @@ -47,10 +47,10 @@ install_github <- function(repo,
remotes <- lapply(repo, github_remote, ref = ref,
subdir = subdir, auth_token = auth_token, host = host)

install_remotes(remotes, ...)
install_remotes(remotes, auth_token = auth_token, host = host, ...)
}

github_remote <- function(repo, ref = NULL, subdir = NULL,
github_remote <- function(repo, ref = "master", subdir = NULL,
auth_token = github_pat(), sha = NULL,
host = "api.github.com") {

Expand Down
2 changes: 1 addition & 1 deletion R/install-gitlab.R
Expand Up @@ -23,7 +23,7 @@ install_gitlab <- function(repo,

remotes <- lapply(repo, gitlab_remote, auth_token = auth_token, host = host)

install_remotes(remotes, ...)
install_remotes(remotes, auth_token = auth_token, host = host, ...)
}

gitlab_remote <- function(repo,
Expand Down
2 changes: 1 addition & 1 deletion R/install-svn.R
Expand Up @@ -27,7 +27,7 @@ install_svn <- function(url, subdir = NULL, args = character(0),
remotes <- lapply(url, svn_remote, svn_subdir = subdir,
revision = revision, args = args)

install_remotes(remotes, ...)
install_remotes(remotes, args = args, ...)
}

svn_remote <- function(url, svn_subdir = NULL, revision = NULL,
Expand Down
13 changes: 10 additions & 3 deletions R/install.R
Expand Up @@ -99,6 +99,8 @@ safe_build_package <- function(pkgdir, build_opts, dest_path, quiet, use_pkgbuil
#' @param threads Number of threads to start, passed to
#' \code{\link[utils]{install.packages}} as \code{Ncpus}.
#' @param ... additional arguments passed to \code{\link[utils]{install.packages}}.
#' @param build If \code{TRUE} build the pacakge before installing.
#' @param build_opts Options to pass to `R CMD build`.
#' @export
#' @examples
#' \dontrun{install_deps(".")}
Expand All @@ -109,13 +111,16 @@ install_deps <- function(pkgdir = ".", dependencies = NA,
type = getOption("pkgType"),
...,
upgrade = TRUE,
quiet = FALSE) {
quiet = FALSE,
build = TRUE,
build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes")) {

packages <- dev_package_deps(
pkgdir,
repos = repos,
dependencies = dependencies,
type = type
type = type,
...
)

dep_deps <- if (isTRUE(dependencies)) NA else dependencies
Expand All @@ -126,6 +131,8 @@ install_deps <- function(pkgdir = ".", dependencies = NA,
...,
Ncpus = threads,
quiet = quiet,
upgrade = upgrade
upgrade = upgrade,
build = build,
build_opts = build_opts
)
}
8 changes: 7 additions & 1 deletion man/install_deps.Rd

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

6 changes: 3 additions & 3 deletions 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 ef92888

Please sign in to comment.