Skip to content

Commit

Permalink
Be explicit about setNames.
Browse files Browse the repository at this point in the history
Closes #734. Fixes #772.
  • Loading branch information
hadley committed Apr 28, 2015
1 parent 48b2eec commit 9969462
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Expand Up @@ -26,7 +26,8 @@ Imports:
rstudioapi (>= 0.2.0),
jsonlite,
roxygen2 (>= 4.1.0),
rversions
rversions,
stats
Suggests:
testthat (>= 0.7),
BiocInstaller,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
@@ -1,5 +1,8 @@
# devtools 1.7.1.9000

* Explicitly refer to `stats::setNames()` to avoid problems (#734, #772) when
using devtools inside another package.

* New `dr_devtools()` runs some common diagnostics. It is run automatically
by `release()` to ensure that you have the latest version of devtools and R
before submitting to CRAN (#592).
Expand Down
2 changes: 1 addition & 1 deletion R/install-github.r
Expand Up @@ -212,7 +212,7 @@ parse_git_repo <- function(path) {
username_rx, repo_rx, subdir_rx, ref_or_pull_or_release_rx)

param_names <- c("username", "repo", "subdir", "ref", "pull", "release", "invalid")
replace <- setNames(sprintf("\\%d", seq_along(param_names)), param_names)
replace <- stats::setNames(sprintf("\\%d", seq_along(param_names)), param_names)
params <- lapply(replace, function(r) gsub(github_rx, r, path, perl = TRUE))
if (params$invalid != "")
stop(sprintf("Invalid git repo: %s", path))
Expand Down
2 changes: 1 addition & 1 deletion R/topic-index.r
Expand Up @@ -45,7 +45,7 @@ find_topic <- function(topic) {
for (pkg in pkgs) {
path <- getNamespaceInfo(pkg, "path")
rd <- find_pkg_topic(path, topic)
if (!is.null(rd)) return(setNames(file.path(path, "man", rd), path))
if (!is.null(rd)) return(stats::setNames(file.path(path, "man", rd), path))
}

NULL
Expand Down
2 changes: 1 addition & 1 deletion R/utils.r
Expand Up @@ -2,7 +2,7 @@
# whether each exists and is a directory.
dir.exists <- function(x) {
res <- file.exists(x) & file.info(x)$isdir
setNames(res, x)
stats::setNames(res, x)
}

compact <- function(x) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-github.r
Expand Up @@ -61,7 +61,7 @@ mock_github_GET <- function(path) {
}

test_that("GitHub references are resolved correctly", {
default_params <- as.list(setNames(nm=c("repo", "username")))
default_params <- as.list(stats::setNames(nm=c("repo", "username")))
with_mock("github_GET", mock_github_GET, {
expect_equal(github_resolve_ref(NULL, list())$ref, "master")
expect_equal(github_resolve_ref("some-ref", list())$ref, "some-ref")
Expand Down

0 comments on commit 9969462

Please sign in to comment.