diff --git a/R/record_versions.R b/R/record_versions.R index 9798cb3..fdeeaa9 100644 --- a/R/record_versions.R +++ b/R/record_versions.R @@ -1,16 +1,16 @@ #' @title Record the manifest of package versions. #' @export #' @description Record the manifest of versions of packages -#' and their MD5 hashes. +#' and their hashes. #' @details This function tracks a manifest containing the current version, -#' the current MD5 hash, the highest version ever released, and -#' the MD5 hash of the highest version ever released. Each time it runs, +#' the current hash, the highest version ever released, and +#' the hash of the highest version ever released. Each time it runs, #' it reads scrapes the package repository for the current releases, -#' reads the old manifest, and updates recorded highest version and MD5 +#' reads the old manifest, and updates recorded highest version and hash #' for all packages which incremented their version numbers. #' After recording these incremented versions, the current version should #' be the highest version, and the current and highest-version -#' MD5 hashes should agree. Packages +#' hashes should agree. Packages #' that fall out of alignment are recorded in a small JSON with only #' the packages with version issues. #' @return `NULL` (invisibly). Writes a package version manifest @@ -43,8 +43,7 @@ record_versions <- function( #' @export #' @keywords internal #' @description Get the current versions of packages in the repos. -#' @return A data frame of packages with their current versions and MD5 -#' hashes. +#' @return A data frame of packages with their current versions and hashes. #' @inheritParams record_versions get_current_versions <- function( repos = "https://r-releases.r-universe.dev" @@ -52,7 +51,7 @@ get_current_versions <- function( out <- utils::available.packages(repos = repos) out <- as.data.frame(out) out <- out[, c("Package", "Version", "MD5sum")] - colnames(out) <- c("package", "version_current", "md5_current") + colnames(out) <- c("package", "version_current", "hash_current") rownames(out) <- NULL out } @@ -66,11 +65,11 @@ read_versions_previous <- function(manifest) { if (is.null(out$version_highest)) { out$version_highest <- out$version_current } - if (is.null(out$md5_highest)) { - out$md5_highest <- out$md5_current + if (is.null(out$hash_highest)) { + out$hash_highest <- out$hash_current } out$version_current <- NULL - out$md5_current <- NULL + out$hash_current <- NULL out } @@ -78,7 +77,7 @@ update_version_manifest <- function(current, previous) { new <- merge(x = current, y = previous, all = TRUE) incremented <- manifest_compare_versions(manifest = new) > 0.5 new$version_highest[incremented] <- new$version_current[incremented] - new$md5_highest[incremented] <- new$md5_current[incremented] + new$hash_highest[incremented] <- new$hash_current[incremented] new } @@ -97,6 +96,6 @@ manifest_compare_versions <- function(manifest) { versions_aligned <- function(manifest) { versions_agree <- manifest$version_current == manifest$version_highest - hashes_agree <- manifest$md5_current == manifest$md5_highest + hashes_agree <- manifest$hash_current == manifest$hash_highest versions_agree & hashes_agree } diff --git a/man/get_current_versions.Rd b/man/get_current_versions.Rd index e3c58e5..2f2247c 100644 --- a/man/get_current_versions.Rd +++ b/man/get_current_versions.Rd @@ -10,8 +10,7 @@ get_current_versions(repos = "https://r-releases.r-universe.dev") \item{repos}{Character string of package repositories to track.} } \value{ -A data frame of packages with their current versions and MD5 -hashes. +A data frame of packages with their current versions and hashes. } \description{ Get the current versions of packages in the repos. diff --git a/man/record_versions.Rd b/man/record_versions.Rd index c620afe..186af74 100644 --- a/man/record_versions.Rd +++ b/man/record_versions.Rd @@ -28,18 +28,18 @@ and a manifest of version issues as JSON files. } \description{ Record the manifest of versions of packages -and their MD5 hashes. +and their hashes. } \details{ This function tracks a manifest containing the current version, -the current MD5 hash, the highest version ever released, and -the MD5 hash of the highest version ever released. Each time it runs, +the current hash, the highest version ever released, and +the hash of the highest version ever released. Each time it runs, it reads scrapes the package repository for the current releases, -reads the old manifest, and updates recorded highest version and MD5 +reads the old manifest, and updates recorded highest version and hash for all packages which incremented their version numbers. After recording these incremented versions, the current version should be the highest version, and the current and highest-version -MD5 hashes should agree. Packages +hashes should agree. Packages that fall out of alignment are recorded in a small JSON with only the packages with version issues. } diff --git a/tests/test-record_versions.R b/tests/test-record_versions.R index cad27a7..c74447e 100644 --- a/tests/test-record_versions.R +++ b/tests/test-record_versions.R @@ -11,7 +11,7 @@ contents <- data.frame( "version_unmodified" ), version_current = rep("1.0.0", 4L), - md5_current = rep("md5_1.0.0", 4L) + hash_current = rep("hash_1.0.0", 4L) ) r.releases.utils::record_versions( manifest = manifest, @@ -23,22 +23,22 @@ expected <- list( list( package = "package_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0" + hash_current = "hash_1.0.0" ), list( package = "version_decremented", version_current = "1.0.0", - md5_current = "md5_1.0.0" + hash_current = "hash_1.0.0" ), list( package = "version_incremented", version_current = "1.0.0", - md5_current = "md5_1.0.0" + hash_current = "hash_1.0.0" ), list( package = "version_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0" + hash_current = "hash_1.0.0" ) ) stopifnot(identical(written, expected)) @@ -55,30 +55,30 @@ expected <- list( list( package = "package_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0", + hash_current = "hash_1.0.0", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ), list( package = "version_decremented", version_current = "1.0.0", - md5_current = "md5_1.0.0", + hash_current = "hash_1.0.0", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ), list( package = "version_incremented", version_current = "1.0.0", - md5_current = "md5_1.0.0", + hash_current = "hash_1.0.0", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ), list( package = "version_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0", + hash_current = "hash_1.0.0", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ) ) stopifnot(identical(written, expected)) @@ -88,13 +88,13 @@ stopifnot(identical(jsonlite::read_json(issues), list())) # Update the packages in all the ways indicated above. index <- contents$package == "version_decremented" contents$version_current[index] <- "0.0.1" -contents$md5_current[index] <- "md5_0.0.1" +contents$hash_current[index] <- "hash_0.0.1" index <- contents$package == "version_incremented" contents$version_current[index] <- "2.0.0" -contents$md5_current[index] <- "md5_2.0.0" +contents$hash_current[index] <- "hash_2.0.0" index <- contents$package == "version_unmodified" contents$version_current[index] <- "1.0.0" -contents$md5_current[index] <- "md5_1.0.0-modified" +contents$hash_current[index] <- "hash_1.0.0-modified" r.releases.utils::record_versions( manifest = manifest, issues = issues, @@ -105,30 +105,30 @@ expected <- list( list( package = "package_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0", + hash_current = "hash_1.0.0", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ), list( package = "version_decremented", version_current = "0.0.1", - md5_current = "md5_0.0.1", + hash_current = "hash_0.0.1", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ), list( package = "version_incremented", version_current = "2.0.0", - md5_current = "md5_2.0.0", + hash_current = "hash_2.0.0", version_highest = "2.0.0", - md5_highest = "md5_2.0.0" + hash_highest = "hash_2.0.0" ), list( package = "version_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0-modified", + hash_current = "hash_1.0.0-modified", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ) ) stopifnot(identical(written, expected)) @@ -138,16 +138,16 @@ expected_issues <- list( list( package = "version_decremented", version_current = "0.0.1", - md5_current = "md5_0.0.1", + hash_current = "hash_0.0.1", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ), list( package = "version_unmodified", version_current = "1.0.0", - md5_current = "md5_1.0.0-modified", + hash_current = "hash_1.0.0-modified", version_highest = "1.0.0", - md5_highest = "md5_1.0.0" + hash_highest = "hash_1.0.0" ) ) stopifnot(identical(written_issues, expected_issues))