r-lib / pkgdepends

R Package Dependency Resolution
https://r-lib.github.io/pkgdepends/
Other
102 stars 30 forks source link

Cannot parse multiple git:: Remotes #318

Closed lgaborini closed 1 year ago

lgaborini commented 1 year ago

{pkgdepends} cannot parse DESCRIPTIONs with more than one git remote like these:

Package: pkgdepends-reprex
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R: 
    person("First", "Last", , "first.last@example.com", role = c("aut", "cre"),
           comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
    license
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Remotes:
    git::git@github.com:cran/falsy.git
    git::git@github.com:cran2/falsy.git

Reprex for the DESCRIPTION (for some reason I've had to add local:: to the package path, as opposed to other reprexes seen here)

temp_desc <- desc::desc("!new")
temp_desc$set_remotes(c(
   "git::git@github.com:cran/falsy.git",
   "git::git@github.com:cran2/falsy.git"
))
temp_desc_path <- tempfile()
temp_desc$write(temp_desc_path)

x <- pkgdepends::new_pkg_deps(paste0("local::", temp_desc_path), config = list(library = tempfile()))
x$solve()
x$get_solution()
#> <pkg_solution>
#> + result: FAILED
#> + refs:
#>   - local::C:\Users\LORENZ~1\AppData\Local\Temp\RtmpQJQC7I\file809c3a3e607a
#> + constraints (2):
#>   - `local::C:\Users\LORENZ~1\AppData\Local\Temp\RtmpQJQC7I\file809c3a3e607a` resolution failed
#>   - select NA exactly once
#> x failures:
#> * local::C:\Users\LORENZ~1\AppData\Local\Temp\RtmpQJQC7I\file809c3a3e607a: ! pkgdepends resolution error for
#> local::C:\Users\LORENZ~1\AppData\Local\Temp\RtmpQJQC7I\file809c3a3e607a.
#> Caused by error: 
#> ! the condition has length > 1

Created on 2023-05-23 with reprex v2.0.2

I think it boils down to the Remotes: section. No issues while parsing one single Remote entry.

My goal is to pull from multiple private Azure repos via HTTPS (git::https://dev.azure.com/user/project/_git/pkg1).

Minimal reprex:

pkgdepends::parse_pkg_ref(
   "git::git@github.com:cran/falsy.git"
)
#> $package
#> [1] "falsy"
#> 
#> $protocol
#> [1] ""
#> 
#> $host
#> [1] "git@github.com:cran"
#> 
#> $path
#> [1] "/"
#> 
#> $repo
#> [1] "falsy"
#> 
#> $commitish
#> [1] "HEAD"
#> 
#> $ref
#> [1] "git::git@github.com:cran/falsy.git"
#> 
#> $type
#> [1] "git"
#> 
#> $dotgit
#> [1] ".git"
#> 
#> $url
#> [1] "://git@github.com:cran/falsy.git"
#> 
#> $params
#> character(0)
#> 
#> attr(,"class")
#> [1] "remote_ref_git" "remote_ref"     "list"
# outside GitHub, custom package name
pkgdepends::parse_pkg_ref(
   "Package1=git::https://dev.azure.com/user/project/_git/pkg1"
)
#> $package
#> [1] "Package1"
#> 
#> $protocol
#> [1] "https"
#> 
#> $host
#> [1] "dev.azure.com"
#> 
#> $path
#> [1] "/user/project/_git/"
#> 
#> $repo
#> [1] "pkg1"
#> 
#> $commitish
#> [1] "HEAD"
#> 
#> $ref
#> [1] "Package1=git::https://dev.azure.com/user/project/_git/pkg1"
#> 
#> $type
#> [1] "git"
#> 
#> $dotgit
#> [1] ""
#> 
#> $url
#> [1] "https://dev.azure.com/user/project/_git/pkg1"
#> 
#> $params
#> character(0)
#> 
#> attr(,"class")
#> [1] "remote_ref_git" "remote_ref"     "list"

pkgdepends::parse_pkg_refs(c(
   "git::git@github.com:cran/falsy.git",
   "git::git@github.com:cran/falsy2.git"
))
#> Error in if (grepl("[.]git$", pds$repo)) ".git" else "": the condition has length > 1

pkgdepends::parse_pkg_refs(c(
   "git::git@github.com:cran/falsy.git",
   "git::git@github.com:cran/falsy2.git",
   "Package1=git::https://dev.azure.com/user/project/_git/pkg1"
))
#> Error in if (grepl("[.]git$", pds$repo)) ".git" else "": the condition has length > 1

Created on 2023-05-23 with reprex v2.0.2

I'm already using the latest pkgdepends 0.5.0.9000 (github::r-lib/pkgdepends@72fa8f2). Thanks!

lgaborini commented 1 year ago

Amazing 🥂