From 6f93063c5af036f83499b35a2b649588a9835dee Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Tue, 24 Oct 2023 13:22:52 -0700 Subject: [PATCH 1/5] exclude lockfile packages from hydration --- R/utils-renv.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/utils-renv.R b/R/utils-renv.R index a9c23c3bf..54ba727dd 100644 --- a/R/utils-renv.R +++ b/R/utils-renv.R @@ -250,6 +250,12 @@ callr_manage_deps <- function(path, repos, snapshot, lockfile_exists) { deps <- unique(renv::dependencies(path = path, root = path, dev = TRUE)$Package) pkgs <- setdiff(deps, installed) needs_hydration <- length(pkgs) > 0 + if (packageVersion("renv") >= "1.0.0") { + # We only need to hydrate the packages that do not exist in the lockfile + # and that are not installed + lock <- renv::lockfile_read(renv_lock) + pkgs <- setdiff(pkgs, names(lock$Packages)) + } } else { # If there is not a lockfile, we need to run a fully hydration pkgs <- NULL From 0abae4e0863352b958b8b85c6e96ec25662ae280 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Tue, 24 Oct 2023 13:33:46 -0700 Subject: [PATCH 2/5] bump to patch version --- DESCRIPTION | 2 +- NEWS.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index efc67ba4d..9e8e5cdac 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sandpaper Title: Create and Curate Carpentries Lessons -Version: 0.14.0 +Version: 0.14.1 Authors@R: c( person(given = "Zhian N.", family = "Kamvar", diff --git a/NEWS.md b/NEWS.md index 1f37a4e59..51ab48e10 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# sandpaper 0.14.1 (2023-10-25) + +## BUG FIX + +* `manage_deps()` can now provision a GitHub package from the lockfile if it was + not previously installed on the system (reported: @pratikunterwegs, + carpentries/actions#32; fixed: @zkamvar, #533) + # sandpaper 0.14.0 (2023-10-02) ## NEW FEATURES From a122a3a0db20be40c96a8394447c48b189e05c83 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Tue, 7 Nov 2023 07:53:40 -0800 Subject: [PATCH 3/5] Revert "bump to patch version" This reverts commit 0abae4e0863352b958b8b85c6e96ec25662ae280. --- DESCRIPTION | 2 +- NEWS.md | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e8e5cdac..efc67ba4d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sandpaper Title: Create and Curate Carpentries Lessons -Version: 0.14.1 +Version: 0.14.0 Authors@R: c( person(given = "Zhian N.", family = "Kamvar", diff --git a/NEWS.md b/NEWS.md index 51ab48e10..1f37a4e59 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,11 +1,3 @@ -# sandpaper 0.14.1 (2023-10-25) - -## BUG FIX - -* `manage_deps()` can now provision a GitHub package from the lockfile if it was - not previously installed on the system (reported: @pratikunterwegs, - carpentries/actions#32; fixed: @zkamvar, #533) - # sandpaper 0.14.0 (2023-10-02) ## NEW FEATURES From 99d420c9706e81514bad76f9a2dd2348e59c0420 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Thu, 9 Nov 2023 08:53:11 -0800 Subject: [PATCH 4/5] do not transform mailto links This will fix #538 --- R/utils-xml.R | 9 ++++++--- tests/testthat/_snaps/utils-xml.md | 6 ++++-- tests/testthat/test-utils-xml.R | 5 +++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/R/utils-xml.R b/R/utils-xml.R index 4073771fe..51270e4ba 100644 --- a/R/utils-xml.R +++ b/R/utils-xml.R @@ -144,9 +144,12 @@ use_instructor <- function(nodes = NULL) { if (length(nodes) == 0) return(nodes) copy <- xml2::read_html(as.character(nodes)) # find all local links and transform non-html and nested links --------- - lnk <- xml2::xml_find_all(copy, - ".//a[@href][not(contains(@href, '://')) and not(starts-with(@href, '#'))]" - ) + no_external <- "not(contains(@href, '://'))" + no_anchors <- "not(starts-with(@href, '#'))" + no_mail <- "not(starts-with(@href, 'mailto:'))" + predicate <- paste(c(no_external, no_anchors, no_mail), collapse = " and ") + XPath <- sprintf(".//a[@href][%s]", predicate) + lnk <- xml2::xml_find_all(copy, XPath) lnk_hrefs <- xml2::xml_attr(lnk, "href") lnk_paths <- xml2::url_parse(lnk_hrefs)$path # links without HTML extension diff --git a/tests/testthat/_snaps/utils-xml.md b/tests/testthat/_snaps/utils-xml.md index b6fbe9db0..3e8fb8830 100644 --- a/tests/testthat/_snaps/utils-xml.md +++ b/tests/testthat/_snaps/utils-xml.md @@ -3,7 +3,7 @@ Code xml2::xml_find_all(html_test, ".//a[@href]") Output - {xml_nodeset (10)} + {xml_nodeset (11)} [1] a [2] b [3] c @@ -14,13 +14,14 @@ [8] h [9] i [10] j + [11] k --- Code xml2::xml_find_all(res, ".//a[@href]") Output - {xml_nodeset (10)} + {xml_nodeset (11)} [1] a [2] b [3] c @@ -31,4 +32,5 @@ [8] h [9] i [10] j + [11] k diff --git a/tests/testthat/test-utils-xml.R b/tests/testthat/test-utils-xml.R index b4d9379ef..f8e2d64fe 100644 --- a/tests/testthat/test-utils-xml.R +++ b/tests/testthat/test-utils-xml.R @@ -12,13 +12,14 @@ test_that("paths in instructor view that are nested or not HTML get diverted", { "[g](files/confirmation.html)", # asset "[h](#what-the)", "[i](other-page.html#section)", - "[j](other-page)" + "[j](other-page)", + "[k](mailto:workbench@example.com?subject='no')" ))) res <- xml2::read_html(use_instructor(html_test)) # refs are transformed according to our rules refs <- xml2::xml_text(xml2::xml_find_all(res, ".//@href")) expect_equal(startsWith(refs, "../"), - c(FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE)) + c(FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE)) expect_snapshot(xml2::xml_find_all(html_test, ".//a[@href]")) expect_snapshot(xml2::xml_find_all(res, ".//a[@href]")) }) From 6858998066bbd9252cb9d9a7da16158f28f19cb2 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Thu, 9 Nov 2023 11:06:51 -0800 Subject: [PATCH 5/5] bump version to 0.14.1; add news --- DESCRIPTION | 2 +- NEWS.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index efc67ba4d..9e8e5cdac 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sandpaper Title: Create and Curate Carpentries Lessons -Version: 0.14.0 +Version: 0.14.1 Authors@R: c( person(given = "Zhian N.", family = "Kamvar", diff --git a/NEWS.md b/NEWS.md index 1f37a4e59..a568d5941 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# sandpaper 0.14.1 (2023-11-09) + +## BUG FIX + +* `mailto:` links are no longer prepended with the URL (reported: @apirogov, + #538; fixed: @zkamvar, #539) + # sandpaper 0.14.0 (2023-10-02) ## NEW FEATURES