From 91c64b3598fc8145bd20484193c68fa9c90bce04 Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Thu, 11 Apr 2019 01:21:18 +1200 Subject: [PATCH] Ignore whitespace after Additional_repositories Fixes #251 --- NEWS.md | 3 +++ R/deps.R | 3 ++- inst/install-github.R | 3 ++- install-github.R | 3 ++- tests/testthat/test-deps.R | 11 +++++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index aa94fbb0..2325f716 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,9 @@ * remotes now understands the "standard" remote type, as produced by packages installed from CRAN using `pak` (#309) +* Fix parsing of Additional_Repositories which have a leading newline + (@tmelliott, #251). + * Fix return type of `install_remote()` when there is a circular dependency (#225) * `remote_package_name.github_remote()` now works properly on Windows (#248) diff --git a/R/deps.R b/R/deps.R index cd57c86e..5cd49b2f 100644 --- a/R/deps.R +++ b/R/deps.R @@ -451,7 +451,8 @@ has_additional_repositories <- function(pkg) { parse_additional_repositories <- function(pkg) { if (has_additional_repositories(pkg)) { - strsplit(pkg[["additional_repositories"]], "[,[:space:]]+")[[1]] + + strsplit(trim_ws(pkg[["additional_repositories"]]), "[,[:space:]]+")[[1]] } } diff --git a/inst/install-github.R b/inst/install-github.R index 8b88151f..b8cfeca5 100644 --- a/inst/install-github.R +++ b/inst/install-github.R @@ -727,7 +727,8 @@ has_additional_repositories <- function(pkg) { parse_additional_repositories <- function(pkg) { if (has_additional_repositories(pkg)) { - strsplit(pkg[["additional_repositories"]], "[,[:space:]]+")[[1]] + + strsplit(trim_ws(pkg[["additional_repositories"]]), "[,[:space:]]+")[[1]] } } diff --git a/install-github.R b/install-github.R index 8b88151f..b8cfeca5 100644 --- a/install-github.R +++ b/install-github.R @@ -727,7 +727,8 @@ has_additional_repositories <- function(pkg) { parse_additional_repositories <- function(pkg) { if (has_additional_repositories(pkg)) { - strsplit(pkg[["additional_repositories"]], "[,[:space:]]+")[[1]] + + strsplit(trim_ws(pkg[["additional_repositories"]]), "[,[:space:]]+")[[1]] } } diff --git a/tests/testthat/test-deps.R b/tests/testthat/test-deps.R index 9fadda44..f547f329 100644 --- a/tests/testthat/test-deps.R +++ b/tests/testthat/test-deps.R @@ -178,6 +178,17 @@ test_that("Additional_repositories field", { parse_additional_repositories(pkg), c("http://packages.ropensci.org", "http://foo.bar.com") ) + + pkg <- list( + additional_repositories = + "\n http://packages.ropensci.org, \nhttp://foo.bar.com" + ) + + expect_equal( + parse_additional_repositories(pkg), + c("http://packages.ropensci.org", "http://foo.bar.com") + ) + }) test_that("update.package_deps", {