-
Notifications
You must be signed in to change notification settings - Fork 235
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
Record commit at package installation #3390
Merged
infotroph
merged 14 commits into
PecanProject:develop
from
infotroph:memoize-commit-at-build-time
Nov 2, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ce05505
add record of Git commit at package build time
infotroph 8fb2061
more compact indicator of modified tree
infotroph 6e771f9
include hash in version report (including nicer print nethod)
infotroph 1d202ce
update tests for new column
infotroph fb7ec70
avoid unintended data
infotroph 8248461
speedups
infotroph 059a93d
set env inside R call
infotroph f78fd1f
more printing tweaks
infotroph 26515c9
one less letter
infotroph 769e9e3
tests
infotroph 5984931
changelog
infotroph 5a3faca
document that version is read from env at install not build
infotroph 83af3ed
only display hash for dev versions
infotroph edd24b0
Merge branch 'develop' into memoize-commit-at-build-time
infotroph 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method(print,pecan_version_report) | ||
export(pecan_version) |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -1,30 +1,34 @@ | ||
|
||
# Read and format a list of pecan versions | ||
|
||
pecan_version_history <- utils::read.csv( | ||
"pecan_version_history.csv", | ||
colClasses = "character", | ||
check.names = FALSE) | ||
# The local() wrapper is to avoid adding objects to the package data: | ||
# Any extra vars defined at the top level of this file would be loaded | ||
# into the global environment by `data("pecan_version_history")` | ||
|
||
# We'd like to parse strictly to catch invalid versions (probably typos). | ||
# But we _need_ to allow NAs... and in R < 4.4, package_version did not | ||
# accept NAs unless strict=FALSE. | ||
strict <- TRUE | ||
na_version <- try( | ||
package_version(NA_character_, strict = strict), | ||
silent = TRUE) | ||
if (inherits(na_version, "try-error")) { | ||
strict <- FALSE | ||
} | ||
pecan_version_history <- local({ | ||
pvh <- utils::read.csv( | ||
"pecan_version_history.csv", | ||
colClasses = "character", | ||
check.names = FALSE) | ||
|
||
for (col in colnames(pecan_version_history)) { | ||
if (col != "package") { | ||
pecan_version_history[[col]] <- package_version( | ||
pecan_version_history[[col]], | ||
strict = strict) | ||
# We'd like to parse strictly to catch invalid versions (probably typos). | ||
# But we _need_ to allow NAs... and in R < 4.4, package_version did not | ||
# accept NAs unless strict=FALSE. | ||
strict <- TRUE | ||
na_version <- try( | ||
package_version(NA_character_, strict = strict), | ||
silent = TRUE) | ||
if (inherits(na_version, "try-error")) { | ||
strict <- FALSE | ||
} | ||
} | ||
|
||
# Now remove local vars | ||
# Yes, this really is needed: _all_ objects left defined at end of script | ||
# will be added to the package data list! | ||
rm(strict, na_version, col) | ||
for (col in colnames(pvh)) { | ||
if (col != "package") { | ||
pvh[[col]] <- package_version( | ||
pvh[[col]], | ||
strict = strict) | ||
} | ||
} | ||
|
||
pvh | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Set at package install time, used by pecan.all::pecan_version() | ||
# to identify development versions of packages | ||
.build_hash <- Sys.getenv("PECAN_GIT_REV", "unknown") |
Oops, something went wrong.
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.
Conceptually it would be preferable to set this at build time, so that someone could download a prebuilt package binary and still have it provide this information, but the getenv is not evaluated until the package is byte-compiled (which happens during installation).
(Scripts in
data/
are evaluated at build rather than install, so I considered treating this information as an exported "dataset" rather than an internal variable. I decided against it because that would mean the hash was exported and hence visible to confuse users, but I'd be open to revisiting the idea if other folks think it'd be useful)