From 0fb3fb902426a1c8dbceada629c2afae297784df Mon Sep 17 00:00:00 2001 From: John Muschelli Date: Tue, 14 Dec 2021 02:27:01 +0000 Subject: [PATCH 1/6] allowing git to passthrough for a git external remote as compared to git2r --- DESCRIPTION | 2 +- R/deps.R | 14 +++++-- R/install-git.R | 84 +++++++++++++++++++++++--------------- R/install.R | 7 +++- man/github_remote.Rd | 3 +- man/install_deps.Rd | 5 +++ man/install_github.Rd | 3 +- man/install_gitlab.Rd | 3 +- man/package_deps.Rd | 7 +++- tests/testthat/test-deps.R | 13 ++++++ 10 files changed, 97 insertions(+), 44 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d5579e1c..288fee38 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,7 +42,7 @@ Suggests: Depends: R (>= 3.0.0) VignetteBuilder: knitr -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 SystemRequirements: Subversion for install_svn, git for install_git Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/R/deps.R b/R/deps.R index 5a5e2ed8..490ea6a3 100644 --- a/R/deps.R +++ b/R/deps.R @@ -117,12 +117,17 @@ local_package_deps <- function(pkgdir = ".", dependencies = NA) { #' `dev_package_deps` lists the status of the dependencies #' of a local package. #' +#' @param git Whether to use the `git2r` package, or an external +#' git client via system. Default is `git2r` if it is installed, +#' otherwise an external git installation. +#' #' @export #' @rdname package_deps dev_package_deps <- function(pkgdir = ".", dependencies = NA, repos = getOption("repos"), - type = getOption("pkgType")) { + type = getOption("pkgType"), + git = c("auto", "git2r", "external")) { pkg <- load_pkg_description(pkgdir) repos <- c(repos, parse_additional_repositories(pkg)) @@ -140,7 +145,8 @@ 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")) + git <- match.arg(git) + res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes", git = git)) res <- do.call(rbind, c(list(res), lapply(get_extra_deps(pkg, dependencies), extra_deps, pkg = pkg), stringsAsFactors = FALSE)) @@ -581,12 +587,12 @@ package_deps_new <- function(package = character(), installed = character(), res } -extra_deps <- function(pkg, field) { +extra_deps <- function(pkg, field, ...) { if (!has_extra_deps(pkg, field)) { return(package_deps_new()) } dev_packages <- split_extra_deps(pkg[[field]]) - extra <- lapply(dev_packages, parse_one_extra) + extra <- lapply(dev_packages, parse_one_extra, ...) package <- vapply(extra, function(x) remote_package_name(x), character(1), USE.NAMES = FALSE) installed <- vapply(package, function(x) local_sha(x), character(1), USE.NAMES = FALSE) diff --git a/R/install-git.R b/R/install-git.R index 10170b0b..5ba6682d 100644 --- a/R/install-git.R +++ b/R/install-git.R @@ -47,23 +47,24 @@ install_git <- function(url, subdir = NULL, ref = NULL, branch = NULL, } remotes <- lapply(url, git_remote, - subdir = subdir, ref = ref, - credentials = credentials, git = match.arg(git) + subdir = subdir, ref = ref, + credentials = credentials, git = match.arg(git) ) install_remotes(remotes, - credentials = credentials, - dependencies = dependencies, - upgrade = upgrade, - force = force, - quiet = quiet, - build = build, - build_opts = build_opts, - build_manual = build_manual, - build_vignettes = build_vignettes, - repos = repos, - type = type, - ... + credentials = credentials, + dependencies = dependencies, + upgrade = upgrade, + force = force, + quiet = quiet, + build = build, + build_opts = build_opts, + build_manual = build_manual, + build_vignettes = build_vignettes, + repos = repos, + type = type, + git = match.arg(git), + ... ) } @@ -79,8 +80,8 @@ git_remote <- function(url, subdir = NULL, ref = NULL, credentials = git_credent stop("`credentials` can only be used with `git = \"git2r\"`", call. = FALSE) } - url_parts = re_match( url, - "(?[^/]*://)?(?[^/]+)(?[^@]*)(@(?.*))?") + url_parts = re_match( url, + "(?[^/]*://)?(?[^/]+)(?[^@]*)(@(?.*))?") ref <- ref %||% (if (url_parts$ref == "") NULL else url_parts$ref) @@ -92,19 +93,19 @@ git_remote <- function(url, subdir = NULL, ref = NULL, credentials = git_credent git_remote_git2r <- function(url, subdir = NULL, ref = NULL, credentials = git_credentials()) { remote("git2r", - url = url, - subdir = subdir, - ref = ref, - credentials = credentials + url = url, + subdir = subdir, + ref = ref, + credentials = credentials ) } git_remote_xgit <- function(url, subdir = NULL, ref = NULL, credentials = git_credentials()) { remote("xgit", - url = url, - subdir = subdir, - ref = ref + url = url, + subdir = subdir, + ref = ref ) } @@ -169,7 +170,7 @@ remote_package_name.git2r_remote <- function(remote, ...) { download_args$basic_auth <- list( user = Sys.getenv(remote$credentials$username), password = Sys.getenv(remote$credentials$username) - ) + ) } else if (inherits(remote$credentials, "cred_token")) { if (Sys.getenv(remote$credentials$token) == "") { stop(paste0("Environment variable `", remote$credentials$token, "` is unset."), .call = FALSE) @@ -199,22 +200,37 @@ remote_package_name.git2r_remote <- function(remote, ...) { res <- try( silent = TRUE, system_check(git_path(), - args = c( - "archive", "-o", tmp, "--remote", remote$url, - if (is.null(remote$ref)) "HEAD" else remote$ref, - description_path - ), - quiet = TRUE + args = c( + "archive", "-o", tmp, "--remote", remote$url, + if (is.null(remote$ref)) "HEAD" else remote$ref, + description_path + ), + quiet = TRUE ) ) if (inherits(res, "try-error")) { - return(NA_character_) + res <- try( + silent = TRUE, + { + bundle <- remote_download(remote, quiet = TRUE) + bundle_description_path <- file.path(bundle, description_path) + if (file.exists(bundle_description_path)) { + description_path_dir <- file.path(tempdir(), dirname(description_path)) + dir.create(description_path_dir, recursive = TRUE, + showWarnings = FALSE) + file.copy(bundle_description_path, + file.path(tempdir(), description_path)) + } + }) + if (inherits(res, "try-error")) { + return(NA_character_) + } + } else { + # git archive returns a tar file, so extract it to tempdir and read the DCF + utils::untar(tmp, files = description_path, exdir = tempdir()) } - # git archive returns a tar file, so extract it to tempdir and read the DCF - utils::untar(tmp, files = description_path, exdir = tempdir()) - read_dcf(file.path(tempdir(), description_path))$Package } } diff --git a/R/install.R b/R/install.R index 3f72009b..ed1f9fad 100644 --- a/R/install.R +++ b/R/install.R @@ -175,6 +175,9 @@ r_error_matches <- function(msg, str) { #' @param build_opts Options to pass to `R CMD build`, only used when `build` is `TRUE`. #' @param build_manual If `FALSE`, don't build PDF manual ('--no-manual'). #' @param build_vignettes If `FALSE`, don't build package vignettes ('--no-build-vignettes'). +#' @param git Whether to use the `git2r` package, or an external +#' git client via system. Default is `git2r` if it is installed, +#' otherwise an external git installation. #' @export #' @examples #' \dontrun{install_deps(".")} @@ -187,12 +190,14 @@ install_deps <- function(pkgdir = ".", dependencies = NA, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"), build_manual = FALSE, build_vignettes = FALSE, + git = c("auto", "git2r", "external"), ...) { packages <- dev_package_deps( pkgdir, repos = repos, dependencies = dependencies, - type = type + type = type, + git = git ) dep_deps <- if (isTRUE(dependencies)) NA else dependencies diff --git a/man/github_remote.Rd b/man/github_remote.Rd index 901d1b61..078ab888 100644 --- a/man/github_remote.Rd +++ b/man/github_remote.Rd @@ -30,7 +30,8 @@ for more details.} \item{subdir}{Subdirectory within repo that contains the R package.} \item{auth_token}{To install from a private repo, generate a personal -access token (PAT) in "https://github.com/settings/tokens" and +access token (PAT) with at least repo scope in +\url{https://github.com/settings/tokens} and supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the \code{GITHUB_PAT} environment variable.} diff --git a/man/install_deps.Rd b/man/install_deps.Rd index fc15df86..e87cec36 100644 --- a/man/install_deps.Rd +++ b/man/install_deps.Rd @@ -15,6 +15,7 @@ install_deps( build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"), build_manual = FALSE, build_vignettes = FALSE, + git = c("auto", "git2r", "external"), ... ) } @@ -60,6 +61,10 @@ to "always". \code{TRUE} and \code{FALSE} are also accepted and correspond to \item{build_vignettes}{If \code{FALSE}, don't build package vignettes ('--no-build-vignettes').} +\item{git}{Whether to use the \code{git2r} package, or an external +git client via system. Default is \code{git2r} if it is installed, +otherwise an external git installation.} + \item{...}{additional arguments passed to \code{\link[utils:install.packages]{utils::install.packages()}}.} } \description{ diff --git a/man/install_github.Rd b/man/install_github.Rd index e3ebc7d3..3608f19b 100644 --- a/man/install_github.Rd +++ b/man/install_github.Rd @@ -39,7 +39,8 @@ for more details.} \item{subdir}{Subdirectory within repo that contains the R package.} \item{auth_token}{To install from a private repo, generate a personal -access token (PAT) in "https://github.com/settings/tokens" and +access token (PAT) with at least repo scope in +\url{https://github.com/settings/tokens} and supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the \code{GITHUB_PAT} environment variable.} diff --git a/man/install_gitlab.Rd b/man/install_gitlab.Rd index 2f463f9e..f3b99ed5 100644 --- a/man/install_gitlab.Rd +++ b/man/install_gitlab.Rd @@ -29,7 +29,8 @@ install_gitlab( \item{subdir}{Subdirectory within repo that contains the R package.} \item{auth_token}{To install from a private repo, generate a personal access -token (PAT) in \url{https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html} and +token (PAT) with at least read_api scope in +\url{https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html} and supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the GITLAB_PAT environment variable.} diff --git a/man/package_deps.Rd b/man/package_deps.Rd index a79f4585..6476409b 100644 --- a/man/package_deps.Rd +++ b/man/package_deps.Rd @@ -20,7 +20,8 @@ dev_package_deps( pkgdir = ".", dependencies = NA, repos = getOption("repos"), - type = getOption("pkgType") + type = getOption("pkgType"), + git = c("auto", "git2r", "external") ) \method{update}{package_deps}( @@ -65,6 +66,10 @@ common ones include: \item{pkgdir}{Path to a package directory, or to a package tarball.} +\item{git}{Whether to use the \code{git2r} package, or an external +git client via system. Default is \code{git2r} if it is installed, +otherwise an external git installation.} + \item{object}{A \code{package_deps} object.} \item{upgrade}{Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default" diff --git a/tests/testthat/test-deps.R b/tests/testthat/test-deps.R index 62d09554..85404302 100644 --- a/tests/testthat/test-deps.R +++ b/tests/testthat/test-deps.R @@ -359,6 +359,19 @@ test_that("remotes are parsed with explicit host", { }) +test_that("git remotes for git2r and xgit", { + + expect_equal( + parse_one_extra("git::git@github.com:hadley/testthat", git = "external"), + git_remote("git@github.com:hadley/testthat", git = "external")) + + + expect_equal( + parse_one_extra("git::git@github.com:hadley/testthat", git = "git2r"), + git_remote("git@github.com:hadley/testthat", git = "git2r")) + +}) + test_that("type = 'both' works well", { skip_on_cran() From 0a04f42ce7d56364a3e026eeec4dc781b26029ca Mon Sep 17 00:00:00 2001 From: John Muschelli Date: Tue, 14 Dec 2021 02:56:58 +0000 Subject: [PATCH 2/6] meaningless RoxygenNote --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 288fee38..d5579e1c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,7 +42,7 @@ Suggests: Depends: R (>= 3.0.0) VignetteBuilder: knitr -RoxygenNote: 7.1.2 +RoxygenNote: 7.1.1 SystemRequirements: Subversion for install_svn, git for install_git Encoding: UTF-8 Roxygen: list(markdown = TRUE) From cbc7a2b3908a0777586251c243afe5f94091b98a Mon Sep 17 00:00:00 2001 From: John Muschelli Date: Wed, 2 Feb 2022 03:55:25 +0000 Subject: [PATCH 3/6] updated install_github --- inst/install-github.R | 105 ++++++++++++++++++++++++++---------------- install-github.R | 105 ++++++++++++++++++++++++++---------------- 2 files changed, 132 insertions(+), 78 deletions(-) diff --git a/inst/install-github.R b/inst/install-github.R index a9b12049..92b07c89 100644 --- a/inst/install-github.R +++ b/inst/install-github.R @@ -654,12 +654,17 @@ function(...) { #' `dev_package_deps` lists the status of the dependencies #' of a local package. #' + #' @param git Whether to use the `git2r` package, or an external + #' git client via system. Default is `git2r` if it is installed, + #' otherwise an external git installation. + #' #' @export #' @rdname package_deps dev_package_deps <- function(pkgdir = ".", dependencies = NA, repos = getOption("repos"), - type = getOption("pkgType")) { + type = getOption("pkgType"), + git = c("auto", "git2r", "external")) { pkg <- load_pkg_description(pkgdir) repos <- c(repos, parse_additional_repositories(pkg)) @@ -677,7 +682,8 @@ function(...) { cran_deps <- package_deps(deps, repos = repos, type = type) - res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes")) + git <- match.arg(git) + res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes", git = git)) res <- do.call(rbind, c(list(res), lapply(get_extra_deps(pkg, dependencies), extra_deps, pkg = pkg), stringsAsFactors = FALSE)) @@ -1118,12 +1124,12 @@ function(...) { res } - extra_deps <- function(pkg, field) { + extra_deps <- function(pkg, field, ...) { if (!has_extra_deps(pkg, field)) { return(package_deps_new()) } dev_packages <- split_extra_deps(pkg[[field]]) - extra <- lapply(dev_packages, parse_one_extra) + extra <- lapply(dev_packages, parse_one_extra, ...) package <- vapply(extra, function(x) remote_package_name(x), character(1), USE.NAMES = FALSE) installed <- vapply(package, function(x) local_sha(x), character(1), USE.NAMES = FALSE) @@ -3463,23 +3469,24 @@ function(...) { } remotes <- lapply(url, git_remote, - subdir = subdir, ref = ref, - credentials = credentials, git = match.arg(git) + subdir = subdir, ref = ref, + credentials = credentials, git = match.arg(git) ) install_remotes(remotes, - credentials = credentials, - dependencies = dependencies, - upgrade = upgrade, - force = force, - quiet = quiet, - build = build, - build_opts = build_opts, - build_manual = build_manual, - build_vignettes = build_vignettes, - repos = repos, - type = type, - ... + credentials = credentials, + dependencies = dependencies, + upgrade = upgrade, + force = force, + quiet = quiet, + build = build, + build_opts = build_opts, + build_manual = build_manual, + build_vignettes = build_vignettes, + repos = repos, + type = type, + git = match.arg(git), + ... ) } @@ -3495,8 +3502,8 @@ function(...) { stop("`credentials` can only be used with `git = \"git2r\"`", call. = FALSE) } - url_parts = re_match( url, - "(?[^/]*://)?(?[^/]+)(?[^@]*)(@(?.*))?") + url_parts = re_match( url, + "(?[^/]*://)?(?[^/]+)(?[^@]*)(@(?.*))?") ref <- ref %||% (if (url_parts$ref == "") NULL else url_parts$ref) @@ -3508,19 +3515,19 @@ function(...) { git_remote_git2r <- function(url, subdir = NULL, ref = NULL, credentials = git_credentials()) { remote("git2r", - url = url, - subdir = subdir, - ref = ref, - credentials = credentials + url = url, + subdir = subdir, + ref = ref, + credentials = credentials ) } git_remote_xgit <- function(url, subdir = NULL, ref = NULL, credentials = git_credentials()) { remote("xgit", - url = url, - subdir = subdir, - ref = ref + url = url, + subdir = subdir, + ref = ref ) } @@ -3585,7 +3592,7 @@ function(...) { download_args$basic_auth <- list( user = Sys.getenv(remote$credentials$username), password = Sys.getenv(remote$credentials$username) - ) + ) } else if (inherits(remote$credentials, "cred_token")) { if (Sys.getenv(remote$credentials$token) == "") { stop(paste0("Environment variable `", remote$credentials$token, "` is unset."), .call = FALSE) @@ -3615,22 +3622,37 @@ function(...) { res <- try( silent = TRUE, system_check(git_path(), - args = c( - "archive", "-o", tmp, "--remote", remote$url, - if (is.null(remote$ref)) "HEAD" else remote$ref, - description_path - ), - quiet = TRUE + args = c( + "archive", "-o", tmp, "--remote", remote$url, + if (is.null(remote$ref)) "HEAD" else remote$ref, + description_path + ), + quiet = TRUE ) ) if (inherits(res, "try-error")) { - return(NA_character_) + res <- try( + silent = TRUE, + { + bundle <- remote_download(remote, quiet = TRUE) + bundle_description_path <- file.path(bundle, description_path) + if (file.exists(bundle_description_path)) { + description_path_dir <- file.path(tempdir(), dirname(description_path)) + dir.create(description_path_dir, recursive = TRUE, + showWarnings = FALSE) + file.copy(bundle_description_path, + file.path(tempdir(), description_path)) + } + }) + if (inherits(res, "try-error")) { + return(NA_character_) + } + } else { + # git archive returns a tar file, so extract it to tempdir and read the DCF + utils::untar(tmp, files = description_path, exdir = tempdir()) } - # git archive returns a tar file, so extract it to tempdir and read the DCF - utils::untar(tmp, files = description_path, exdir = tempdir()) - read_dcf(file.path(tempdir(), description_path))$Package } } @@ -5324,6 +5346,9 @@ function(...) { #' @param build_opts Options to pass to `R CMD build`, only used when `build` is `TRUE`. #' @param build_manual If `FALSE`, don't build PDF manual ('--no-manual'). #' @param build_vignettes If `FALSE`, don't build package vignettes ('--no-build-vignettes'). + #' @param git Whether to use the `git2r` package, or an external + #' git client via system. Default is `git2r` if it is installed, + #' otherwise an external git installation. #' @export #' @examples #' \dontrun{install_deps(".")} @@ -5336,12 +5361,14 @@ function(...) { build = TRUE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"), build_manual = FALSE, build_vignettes = FALSE, + git = c("auto", "git2r", "external"), ...) { packages <- dev_package_deps( pkgdir, repos = repos, dependencies = dependencies, - type = type + type = type, + git = git ) dep_deps <- if (isTRUE(dependencies)) NA else dependencies diff --git a/install-github.R b/install-github.R index a9b12049..92b07c89 100644 --- a/install-github.R +++ b/install-github.R @@ -654,12 +654,17 @@ function(...) { #' `dev_package_deps` lists the status of the dependencies #' of a local package. #' + #' @param git Whether to use the `git2r` package, or an external + #' git client via system. Default is `git2r` if it is installed, + #' otherwise an external git installation. + #' #' @export #' @rdname package_deps dev_package_deps <- function(pkgdir = ".", dependencies = NA, repos = getOption("repos"), - type = getOption("pkgType")) { + type = getOption("pkgType"), + git = c("auto", "git2r", "external")) { pkg <- load_pkg_description(pkgdir) repos <- c(repos, parse_additional_repositories(pkg)) @@ -677,7 +682,8 @@ function(...) { cran_deps <- package_deps(deps, repos = repos, type = type) - res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes")) + git <- match.arg(git) + res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes", git = git)) res <- do.call(rbind, c(list(res), lapply(get_extra_deps(pkg, dependencies), extra_deps, pkg = pkg), stringsAsFactors = FALSE)) @@ -1118,12 +1124,12 @@ function(...) { res } - extra_deps <- function(pkg, field) { + extra_deps <- function(pkg, field, ...) { if (!has_extra_deps(pkg, field)) { return(package_deps_new()) } dev_packages <- split_extra_deps(pkg[[field]]) - extra <- lapply(dev_packages, parse_one_extra) + extra <- lapply(dev_packages, parse_one_extra, ...) package <- vapply(extra, function(x) remote_package_name(x), character(1), USE.NAMES = FALSE) installed <- vapply(package, function(x) local_sha(x), character(1), USE.NAMES = FALSE) @@ -3463,23 +3469,24 @@ function(...) { } remotes <- lapply(url, git_remote, - subdir = subdir, ref = ref, - credentials = credentials, git = match.arg(git) + subdir = subdir, ref = ref, + credentials = credentials, git = match.arg(git) ) install_remotes(remotes, - credentials = credentials, - dependencies = dependencies, - upgrade = upgrade, - force = force, - quiet = quiet, - build = build, - build_opts = build_opts, - build_manual = build_manual, - build_vignettes = build_vignettes, - repos = repos, - type = type, - ... + credentials = credentials, + dependencies = dependencies, + upgrade = upgrade, + force = force, + quiet = quiet, + build = build, + build_opts = build_opts, + build_manual = build_manual, + build_vignettes = build_vignettes, + repos = repos, + type = type, + git = match.arg(git), + ... ) } @@ -3495,8 +3502,8 @@ function(...) { stop("`credentials` can only be used with `git = \"git2r\"`", call. = FALSE) } - url_parts = re_match( url, - "(?[^/]*://)?(?[^/]+)(?[^@]*)(@(?.*))?") + url_parts = re_match( url, + "(?[^/]*://)?(?[^/]+)(?[^@]*)(@(?.*))?") ref <- ref %||% (if (url_parts$ref == "") NULL else url_parts$ref) @@ -3508,19 +3515,19 @@ function(...) { git_remote_git2r <- function(url, subdir = NULL, ref = NULL, credentials = git_credentials()) { remote("git2r", - url = url, - subdir = subdir, - ref = ref, - credentials = credentials + url = url, + subdir = subdir, + ref = ref, + credentials = credentials ) } git_remote_xgit <- function(url, subdir = NULL, ref = NULL, credentials = git_credentials()) { remote("xgit", - url = url, - subdir = subdir, - ref = ref + url = url, + subdir = subdir, + ref = ref ) } @@ -3585,7 +3592,7 @@ function(...) { download_args$basic_auth <- list( user = Sys.getenv(remote$credentials$username), password = Sys.getenv(remote$credentials$username) - ) + ) } else if (inherits(remote$credentials, "cred_token")) { if (Sys.getenv(remote$credentials$token) == "") { stop(paste0("Environment variable `", remote$credentials$token, "` is unset."), .call = FALSE) @@ -3615,22 +3622,37 @@ function(...) { res <- try( silent = TRUE, system_check(git_path(), - args = c( - "archive", "-o", tmp, "--remote", remote$url, - if (is.null(remote$ref)) "HEAD" else remote$ref, - description_path - ), - quiet = TRUE + args = c( + "archive", "-o", tmp, "--remote", remote$url, + if (is.null(remote$ref)) "HEAD" else remote$ref, + description_path + ), + quiet = TRUE ) ) if (inherits(res, "try-error")) { - return(NA_character_) + res <- try( + silent = TRUE, + { + bundle <- remote_download(remote, quiet = TRUE) + bundle_description_path <- file.path(bundle, description_path) + if (file.exists(bundle_description_path)) { + description_path_dir <- file.path(tempdir(), dirname(description_path)) + dir.create(description_path_dir, recursive = TRUE, + showWarnings = FALSE) + file.copy(bundle_description_path, + file.path(tempdir(), description_path)) + } + }) + if (inherits(res, "try-error")) { + return(NA_character_) + } + } else { + # git archive returns a tar file, so extract it to tempdir and read the DCF + utils::untar(tmp, files = description_path, exdir = tempdir()) } - # git archive returns a tar file, so extract it to tempdir and read the DCF - utils::untar(tmp, files = description_path, exdir = tempdir()) - read_dcf(file.path(tempdir(), description_path))$Package } } @@ -5324,6 +5346,9 @@ function(...) { #' @param build_opts Options to pass to `R CMD build`, only used when `build` is `TRUE`. #' @param build_manual If `FALSE`, don't build PDF manual ('--no-manual'). #' @param build_vignettes If `FALSE`, don't build package vignettes ('--no-build-vignettes'). + #' @param git Whether to use the `git2r` package, or an external + #' git client via system. Default is `git2r` if it is installed, + #' otherwise an external git installation. #' @export #' @examples #' \dontrun{install_deps(".")} @@ -5336,12 +5361,14 @@ function(...) { build = TRUE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"), build_manual = FALSE, build_vignettes = FALSE, + git = c("auto", "git2r", "external"), ...) { packages <- dev_package_deps( pkgdir, repos = repos, dependencies = dependencies, - type = type + type = type, + git = git ) dep_deps <- if (isTRUE(dependencies)) NA else dependencies From fe5f1044d0957fc9200506007326ed2730dee4c0 Mon Sep 17 00:00:00 2001 From: John Muschelli Date: Wed, 9 Feb 2022 22:08:33 +0000 Subject: [PATCH 4/6] missed one passthrough --- R/deps.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/deps.R b/R/deps.R index 490ea6a3..6ba44917 100644 --- a/R/deps.R +++ b/R/deps.R @@ -148,7 +148,9 @@ dev_package_deps <- function(pkgdir = ".", dependencies = NA, git <- match.arg(git) res <- combine_remote_deps(cran_deps, extra_deps(pkg, "remotes", git = git)) - res <- do.call(rbind, c(list(res), lapply(get_extra_deps(pkg, dependencies), extra_deps, pkg = pkg), stringsAsFactors = FALSE)) + res <- do.call(rbind, c(list(res), lapply(get_extra_deps(pkg, dependencies), + extra_deps, pkg = pkg, git = git), + stringsAsFactors = FALSE)) res[is.na(res$package) | !duplicated(res$package, fromLast = TRUE), ] } From 3c4561d4956ac9ae63985f0a67160c5666c3906a Mon Sep 17 00:00:00 2001 From: John Muschelli Date: Wed, 9 Feb 2022 22:35:28 +0000 Subject: [PATCH 5/6] fixing copy bug for same description file for multiple bundles --- R/install-git.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/install-git.R b/R/install-git.R index 5ba6682d..16907b88 100644 --- a/R/install-git.R +++ b/R/install-git.R @@ -220,7 +220,8 @@ remote_package_name.git2r_remote <- function(remote, ...) { dir.create(description_path_dir, recursive = TRUE, showWarnings = FALSE) file.copy(bundle_description_path, - file.path(tempdir(), description_path)) + file.path(tempdir(), description_path), + overwrite = TRUE) } }) if (inherits(res, "try-error")) { From 9f7880054aceebdee98b991b1b643da2e1a06fc6 Mon Sep 17 00:00:00 2001 From: John Muschelli Date: Wed, 9 Feb 2022 23:02:10 +0000 Subject: [PATCH 6/6] another passthrough - this works now --- R/install.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/install.R b/R/install.R index ed1f9fad..ee1f06a4 100644 --- a/R/install.R +++ b/R/install.R @@ -213,6 +213,7 @@ install_deps <- function(pkgdir = ".", dependencies = NA, build_vignettes = build_vignettes, type = type, repos = repos, + git = git, ... ) }