Skip to content

Commit

Permalink
Change package name and check hashes when recording versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Mar 6, 2024
1 parent 3cad892 commit 8c2a4a0
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 146 deletions.
14 changes: 6 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Package: r.releases.utils
Title: Utilities for An R Universe of Package Releases
Description: Utilities for an R universe of package releases.
Version: 0.0.8
Package: r.releases.internals
Title: Internal Infrastructure for An R Universe of Package Releases
Description: Internal infrastructure for an R universe of package releases.
Version: 0.0.9
License: MIT + file LICENSE
URL:
https://r-releases.github.io/r.releases.utils/,
https://github.com/r-releases/r.releases.utils
BugReports: https://github.com/r-releases/r.releases.utils/issues
URL: https://github.com/r-releases/r.releases.internals
BugReports: https://github.com/r-releases/r.releases.internals/issues
Authors@R: c(
person(
given = c("William", "Michael"),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export(try_message)
importFrom(gh,gh)
importFrom(jsonlite,parse_json)
importFrom(jsonlite,read_json)
importFrom(jsonlite,stream_in)
importFrom(jsonlite,write_json)
importFrom(nanonext,ncurl)
importFrom(nanonext,parse_url)
importFrom(nanonext,status_code)
importFrom(pkgsearch,cran_package)
importFrom(utils,available.packages)
importFrom(utils,compareVersion)
importFrom(utils,contrib.url)
importFrom(vctrs,vec_rbind)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# r.releases.internals 0.0.9

* Change the package name to `r.releases.internals`.
* Get RemoteSha hashes for checking versions (@jeroen, https://github.com/r-universe-org/help/issues/377).

# r.releases.utils 0.0.8

* Use R-releases and not `r-releases` to refer to the project.
Expand Down
11 changes: 6 additions & 5 deletions R/package.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#' r.releases.utils: Utilities for an R universe of package releases.
#' @description Utilities for an R universe of package releases..
#' @name r.releases.utils-package
#' r.releases.internals: Internal infrastructure for an R universe
#' of package releases.
#' @description Utilities for an R universe of package releases.
#' @name r.releases.internals-package
#' @family help
#' @importFrom gh gh
#' @importFrom jsonlite parse_json read_json write_json
#' @importFrom jsonlite parse_json read_json stream_in write_json
#' @importFrom nanonext ncurl parse_url status_code
#' @importFrom pkgsearch cran_package
#' @importFrom utils available.packages compareVersion
#' @importFrom utils available.packages compareVersion contrib.url
#' @importFrom vctrs vec_rbind
NULL
43 changes: 23 additions & 20 deletions R/record_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@
#' @param manifest Character of length 1, file path to the JSON manifest.
#' @param issues Character of length 1, file path to a JSON file
#' which records packages with version issues.
#' @param repos Character string of package repositories to track.
#' @param repo Character string of package repositories to track.
#' @param current A data frame of current versions and hashes of packages
#' in `repos`. This argument is exposed for testing only.
#' @param check_hash Logical of length 1, check hashes when judging package
#' version compliance. This allows [record_versions()] to flag packages
#' that create new releases but keep the same version number.
#' in `repo`. This argument is exposed for testing only.
record_versions <- function(
manifest = "versions.json",
issues = "version_issues.json",
repos = "https://r-releases.r-universe.dev",
current = r.releases.utils::get_current_versions(repos = repos),
check_hash = TRUE
repo = "https://r-releases.r-universe.dev",
current = r.releases.internals::get_current_versions(repo = repo)
) {
if (!file.exists(manifest)) {
jsonlite::write_json(x = current, path = manifest, pretty = TRUE)
Expand All @@ -32,7 +28,7 @@ record_versions <- function(
previous <- read_versions_previous(manifest = manifest)
new <- update_version_manifest(current = current, previous = previous)
jsonlite::write_json(x = new, path = manifest, pretty = TRUE)
aligned <- versions_aligned(manifest = new, check_hash = check_hash)
aligned <- versions_aligned(manifest = new)
new_issues <- new[!aligned,, drop = FALSE] # nolint
jsonlite::write_json(x = new_issues, path = issues, pretty = TRUE)
invisible()
Expand All @@ -41,15 +37,25 @@ record_versions <- function(
#' @title Get the current versions of packages
#' @export
#' @keywords internal
#' @description Get the current versions of packages in the repos.
#' @description Get the current versions of packages in the repo.
#' @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"
repo = "https://r-releases.r-universe.dev"
) {
out <- utils::available.packages(repos = repos)
out <- out[, c("Package", "Version", "MD5sum")]
out <- as.data.frame(out)
listing <- paste(
contrib.url(repos = repo, type = "source"),
"PACKAGES.json?fields=RemoteSha",
sep = "/"
)
out <- jsonlite::stream_in(
con = url(listing),
verbose = TRUE,
simplifyVector = TRUE,
simplifyDataFrame = TRUE,
simplifyMatrix = TRUE
)
out <- out[, c("Package", "Version", "RemoteSha")]
colnames(out) <- c("package", "version_current", "hash_current")
rownames(out) <- NULL
out
Expand Down Expand Up @@ -91,10 +97,7 @@ manifest_compare_versions <- function(manifest) {
)
}

versions_aligned <- function(manifest, check_hash) {
aligned <- manifest$version_current == manifest$version_highest
if (check_hash) {
aligned <- aligned & (manifest$hash_current == manifest$hash_highest)
}
aligned
versions_aligned <- function(manifest) {
(manifest$version_current == manifest$version_highest) &
(manifest$hash_current == manifest$hash_highest)
}
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
RemoteSha
GitLab
JSON
json
Expand Down
6 changes: 3 additions & 3 deletions man/get_current_versions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/r.releases.internals-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions man/r.releases.utils-package.Rd

This file was deleted.

13 changes: 4 additions & 9 deletions man/record_versions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Loading

0 comments on commit 8c2a4a0

Please sign in to comment.