Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trim trailing ws in versioned deps #366

Merged
merged 3 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

# remotes (development version)

* Fix bug in internal `parse_deps()` where test of valid comparison operators
failed due to trailing whitespaces in DESCRIPTION fields (@LiNk-NY, #366)

* `update.package_dependencies()` now uses the pkg_type for the cran remote
rather than a global type attribute, fixing errors when this global attribute
is lost (#291, #304).
Expand Down
4 changes: 2 additions & 2 deletions R/package-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ parse_deps <- function(string) {
have_version <- grepl("\\(.*\\)", versions_str)
versions_str[!have_version] <- NA

compare <- sub(".*\\(\\s*(\\S+)\\s+.*\\s*\\)", "\\1", versions_str)
versions <- sub(".*\\(\\s*\\S+\\s+(\\S*)\\s*\\)", "\\1", versions_str)
compare <- sub(".*\\(\\s*(\\S+)\\s+.*\\s*\\).*", "\\1", versions_str)
versions <- sub(".*\\(\\s*\\S+\\s+(\\S*)\\s*\\).*", "\\1", versions_str)

# Check that non-NA comparison operators are valid
compare_nna <- compare[!is.na(compare)]
Expand Down
4 changes: 2 additions & 2 deletions inst/install-github.R
Original file line number Diff line number Diff line change
Expand Up @@ -3838,8 +3838,8 @@ parse_deps <- function(string) {
have_version <- grepl("\\(.*\\)", versions_str)
versions_str[!have_version] <- NA

compare <- sub(".*\\(\\s*(\\S+)\\s+.*\\s*\\)", "\\1", versions_str)
versions <- sub(".*\\(\\s*\\S+\\s+(\\S*)\\s*\\)", "\\1", versions_str)
compare <- sub(".*\\(\\s*(\\S+)\\s+.*\\s*\\).*", "\\1", versions_str)
versions <- sub(".*\\(\\s*\\S+\\s+(\\S*)\\s*\\).*", "\\1", versions_str)

# Check that non-NA comparison operators are valid
compare_nna <- compare[!is.na(compare)]
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-package-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ test_that("parse_deps", {
)
)

expect_equal(
parse_deps("package (>= 1.0.1) , package2 (< 0.0.1 ) "),
structure(
list(
name = c("package", "package2"),
compare = c(">=", "<"),
version = c("1.0.1", "0.0.1")),
row.names = 1:2,
class = "data.frame"
)
)
})


Expand Down