Repository navigation
Preserve renv package sources and derive Bioconductor identities - #127
Conversation
andrew
left a comment
There was a problem hiding this comment.
Thanks for this, the mapping is right and the test coverage through public Parse is exactly what the issue asked for. One behavioural gap to close before merge.
internal/cran/cran.go:310 — Posit Package Manager repository names fall through to NoPURL. renv stamps packages installed via Posit Package Manager with "Repository": "RSPM" (older) or "PPM" / "P3M" (newer), while the lockfile's top-level R.Repositories list typically names the entry CRAN (pointing at the PPM URL), not RSPM. Example from phuse-org/OSTCDA's renv.lock: R.Repositories is [{Name: CRAN, URL: packagemanager.rstudio.com/...}, {Name: AtorusPackages, ...}] and 6 packages carry "Repository": "RSPM". With this change those hit the default branch of applyRenvRepository and lose their pkg:cran/... identity, which regresses against main for a very common lockfile shape. PPM serves CRAN packages and renv's own restore path treats these names as CRAN, so extend the first case to name == "CRAN" || name == "RSPM" || name == "PPM" || name == "P3M" and add an "RSPM" package to TestRenvLockSources expecting pkg:cran/... with Source{registry, "RSPM"}.
internal/cran/cran.go:256-261 and 298-303 — doc comments narrate the switch. Trim each to the one sentence the code doesn't already say: on applyRenvSource keep only "Entries without a recorded source keep the CRAN identity older lockfiles implied"; on applyRenvRepository keep only "A repository whose URL is unknown has no package identity." The rest restates the case list.
|
Thanks, both fixed
|
andrew
left a comment
There was a problem hiding this comment.
Thanks, both landed as asked — RSPM/PPM/P3M now keep their CRAN identity with test coverage for each, and the doc comments are trimmed.
Fixes #123
Problem
The
renv.lockparser read onlyPackage,VersionandHash. It droppedSourceandRepository, so every locked package got a CRAN identity. A package recorded as Bioconductor came out aspkg:cran/BiocGenerics@0.58.1with an empty source. Consumers could not tell it apart from a CRAN package with the same name. GitHub, local and custom repository packages also picked up a CRAN identity they were never installed from.Changes
The parser now reads
Source,Repository, theRemote*fields and the lockfile's top-levelR.Repositorieslist. It records the source on each dependency and uses it to choose the package identity.RepositoryfromCRANpkg:cran/...registry: CRANBioconductor, or a repository such asBioCsoftpkg:bioconductor/...registry: <repository>Repositoryfrom another repository listed inR.Repositories, or a repository URLpkg:cran/...?repository_url=...registry: <repository>Repositoryfrom a repository with no known URLNoPURL)registry: <repository>GitHubNoPURL)github: owner/repoGitLab/BitbucketNoPURL)git: gitlab::owner/repogitNoPURL)git: <RemoteUrl>URLNoPURL)url: <RemoteUrl>LocalNoPURL)path: <RemoteUrl>NoPURL)pkg:cran/...Git sources keep
RemoteShainRef, orRemoteRefwhen no commit is recorded.RemoteSubdirgoes inRel.Lockfiles that record no source keep their CRAN identity, so older files parse as before. Version, integrity and
Direct: falseare unchanged.The README documents the mapping. The
Relfield comment now says "package path" since renv uses it as well as Chef.Consumer impact
Packages from GitHub, local paths, URLs, unknown repositories or unrecognised sources now have an empty PURL with
NoPURLset. They no longer get a CRAN identity. Brief currently skips dependencies with an empty PURL. That needs handling in git-pkgs/brief#214 before Brief addsrenv.lockto discovery.Tests
TestRenvLockSourcestest goes through the publicParse. It covers mixed CRAN and Bioconductor entries, missing source fields, custom, URL and unknown repositories, every remote type and an unrecognised source. It also checks version, integrity andDirect.TestRenvLockstill passes.go build ./...,go vet ./...,go test -race ./...andgolangci-lint runall pass.