@@ -282,13 +282,19 @@ get_imports <- function(path, commit_date, ...) {
282282 # Get imports from NAMESPACE
283283 namespace_path <- gsub(" DESCRIPTION" , " NAMESPACE" , desc_path )
284284 namespace_raw <- readLines(namespace_path )
285- namespace_imports <- namespace_raw [grepl(" importFrom" , namespace_raw )]
285+ # Keep only lines that start with "import(" or "importFrom("
286+ namespace_imports <- grep(
287+ " ^(import|importFrom)\\ (" ,
288+ namespace_raw ,
289+ value = TRUE
290+ )
286291
287292 if (length(namespace_imports ) > 0 ) {
288- # Get package names from `importFrom` statements
289- namespace_imports_pkgs <- gsub(
290- " importFrom\\ (([^,]+).*" ,
291- " \\ 1" ,
293+ # Extract the package name (first argument inside parentheses)
294+ namespace_imports_pkgs <- sub(
295+ # capture word or quoted string before first comma or closing paren
296+ ' ^import(?:From)?\\ (([^,\\ )]+).*' ,
297+ ' \\ 1' ,
292298 namespace_imports
293299 )
294300 # Remove quotes, which is sometimes necessary
@@ -388,8 +394,11 @@ fetchgits <- function(git_pkgs, ...) {
388394 # Check if ignore_remotes_cache was passed
389395 # If not passed, ignore_remotes_cache is FALSE
390396 args <- list (... )
391- ignore_remotes_cache <- if (! is.null(args $ ignore_remotes_cache ))
392- args $ ignore_remotes_cache else FALSE
397+ ignore_remotes_cache <- if (! is.null(args $ ignore_remotes_cache )) {
398+ args $ ignore_remotes_cache
399+ } else {
400+ FALSE
401+ }
393402
394403 if (! ignore_remotes_cache ) {
395404 cache_file <- get_cache_file()
@@ -471,8 +480,11 @@ fetchzips <- function(archive_pkgs) {
471480# ' @noRd
472481fetchpkgs <- function (git_pkgs , archive_pkgs , ... ) {
473482 args <- list (... )
474- ignore_remotes_cache <- if (! is.null(args $ ignore_remotes_cache ))
475- args $ ignore_remotes_cache else FALSE
483+ ignore_remotes_cache <- if (! is.null(args $ ignore_remotes_cache )) {
484+ args $ ignore_remotes_cache
485+ } else {
486+ FALSE
487+ }
476488
477489 # Initialize cache if git packages are present and not ignoring cache
478490 if (! is.null(git_pkgs ) && ! ignore_remotes_cache ) {
@@ -592,11 +604,15 @@ download_all_commits <- function(repo, date) {
592604 }
593605
594606 commits <- fromJSON(rawToChar(response $ content ))
595- if (! is.list(commits ) || length(commits ) == 0 ) break
607+ if (! is.list(commits ) || length(commits ) == 0 ) {
608+ break
609+ }
596610
597611 # if no commits are found, break the loop
598612 n_commits <- length(commits $ sha )
599- if (n_commits == 0 ) break
613+ if (n_commits == 0 ) {
614+ break
615+ }
600616
601617 idx <- (commit_count + 1 ): (commit_count + n_commits )
602618 all_commits $ sha [idx ] <- commits $ sha
@@ -661,8 +677,11 @@ resolve_package_commit <- function(
661677
662678 # Check if ignore_remotes_cache was passed, otherwise set to FALSE
663679 args <- list (... )
664- ignore_remotes_cache <- if (! is.null(args $ ignore_remotes_cache ))
665- args $ ignore_remotes_cache else FALSE
680+ ignore_remotes_cache <- if (! is.null(args $ ignore_remotes_cache )) {
681+ args $ ignore_remotes_cache
682+ } else {
683+ FALSE
684+ }
666685
667686 # Check if package is already in cache
668687 if (! ignore_remotes_cache ) {
0 commit comments