-
Notifications
You must be signed in to change notification settings - Fork 155
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
include all required fields for hashing in lockfile #2059
Open
kevinushey
wants to merge
18
commits into
main
Choose a base branch
from
feature/complete-lockfile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
76bc40d
start recording extra fields in lockfile
kevinushey debaf54
add a test
kevinushey 681145b
reorganize
kevinushey f64e49e
include more fields
kevinushey fcfb00f
drop Remote fields for cran-like records
kevinushey eb3e6df
tweaks
kevinushey 526106b
update NEWS; provide option as fallback
kevinushey 70eb28b
add snapshot test for old lockfile
kevinushey 1960ee8
Merge branch 'main' into feature/complete-lockfile
kevinushey f2753f9
test different versions of lockfiles
kevinushey 83eac3f
compute hash records on demand instead of storing in lockfile
kevinushey 96b22e3
fixes for windows
kevinushey 6d444b6
try alternate test for windows
kevinushey a3ae93b
try once more
kevinushey 1a558d5
one more attempt?
kevinushey 8fb4fa6
it works on my machine (tm)
kevinushey e054467
Merge branch 'main' into feature/complete-lockfile
kevinushey fe37752
also explicitly test file
kevinushey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,54 +741,38 @@ renv_snapshot_description_impl <- function(dcf, path = NULL) { | |
dcf <- dcf[fields] | ||
} | ||
|
||
# drop fields that normally only appear in binary packages, | ||
# or fields which might differ from user to user, or might | ||
# differ depending on the mirror used for publication | ||
ignore <- c("Archs", "Built", "Date/Publication", "File", "MD5sum", "Packaged") | ||
dcf[ignore] <- NULL | ||
|
||
# drop remote fields for cranlike remotes | ||
if (renv_record_cranlike(dcf)) { | ||
sha <- dcf[["RemoteSha"]] | ||
if (is.null(sha) || nchar(sha) < 40L) { | ||
remotes <- grep("^Remote", names(dcf), perl = TRUE, value = TRUE) | ||
dcf[remotes] <- NULL | ||
} | ||
} | ||
|
||
# drop the old Github remote fields | ||
github <- grepl("^Github", names(dcf), perl = TRUE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aside: When |
||
dcf <- dcf[!github] | ||
|
||
# generate a hash if we can | ||
dcf[["Hash"]] <- if (the$auto_snapshot_hash) { | ||
if (is.null(path)) | ||
renv_hash_description_impl(dcf) | ||
else | ||
renv_hash_description(path) | ||
} | ||
|
||
# generate a Requirements field -- primarily for use by 'pak' | ||
fields <- c("Depends", "Imports", "LinkingTo") | ||
deps <- bind(map(dcf[fields], renv_description_parse_field)) | ||
all <- unique(csort(unlist(deps$Package))) | ||
dcf[["Requirements"]] <- all | ||
|
||
# get remotes fields | ||
remotes <- renv_snapshot_description_impl_remotes(dcf) | ||
|
||
# only keep relevant fields | ||
extra <- c("Repository", "OS_type") | ||
all <- c(required, extra, remotes, "Requirements", "Hash") | ||
keep <- renv_vector_intersect(all, names(dcf)) | ||
|
||
|
||
# reorganize fields a bit | ||
dcf <- dcf[c(required, setdiff(names(dcf), required))] | ||
|
||
# return as list | ||
as.list(dcf[keep]) | ||
|
||
} | ||
|
||
renv_snapshot_description_impl_remotes <- function(dcf) { | ||
|
||
# if this seems to be a cran-like record, only keep remotes | ||
# when RemoteSha appears to be a hash (e.g. for r-universe) | ||
# note that RemoteSha may be a package version when installed | ||
# by e.g. pak | ||
if (renv_record_cranlike(dcf)) { | ||
sha <- dcf[["RemoteSha"]] | ||
if (is.null(sha) || nchar(sha) < 40) | ||
return(character()) | ||
} | ||
|
||
# grab the relevant remotes | ||
git <- grep("^git", names(dcf), value = TRUE) | ||
remotes <- grep("^Remote(?!s)", names(dcf), perl = TRUE, value = TRUE) | ||
|
||
# don't include 'RemoteRef' if it's a non-informative remote | ||
if (identical(dcf[["RemoteRef"]], "HEAD")) | ||
remotes <- setdiff(remotes, "RemoteRef") | ||
|
||
c(git, remotes) | ||
as.list(dcf) | ||
|
||
} | ||
|
||
|
@@ -840,7 +824,7 @@ renv_snapshot_description_source <- function(dcf) { | |
|
||
# check for a custom declared remote type | ||
if (!renv_record_cranlike(dcf)) { | ||
type <- dcf[["RemoteType"]] | ||
type <- dcf[["RemoteType"]] %||% "standard" | ||
return(list(Source = alias(type))) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title, Authors, Maintainer, and Description are not necessary for hashing, as they do not communicate anything about package dependencies.
What about SystemRequirements and NeedsCompilation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW if we change the fields that get included in the hash, then we'll invalidate any old hash values. We could still do this, but we'd probably want to do something to either notify users or allow them to choose.
Ultimately though, we want to include fields which would help to uniquely identify a package from its DESCRIPTION file, hence why those (and not just the package dependency fields) are included.