Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Imports:
fs,
usethis
Config/roxygen2/version: 8.0.0
Suggests:
Suggests:
gert,
gh,
testthat (>= 3.0.0)
Config/testthat/edition: 3
URL: https://mi-erasmusmc.github.io/studyGenerics/
8 changes: 0 additions & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_success)
importFrom(cli,cli_alert_warning)
importFrom(fs,path_ext_set)
importFrom(gert,git_branch)
importFrom(gert,git_branch_checkout)
importFrom(gert,git_branch_create)
importFrom(gert,git_branch_exists)
importFrom(gert,git_pull)
importFrom(gh,gh)
importFrom(gh,gh_token_exists)
importFrom(gh,gh_tree_remote)
importFrom(glue,glue)
importFrom(glue,glue_collapse)
importFrom(here,here)
Expand Down
30 changes: 30 additions & 0 deletions R/getPkgZips.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,33 @@ mockLock <- function() {
return(lockfile)
}

suppPackages <- function() {
list(
Packages = list(
devtools = list(
Package = "devtools",
Version = "2.5.2"
), # 2.5.2 exists in multiple releases, should pick from the newest (R v4.6)
dplyr = list(
Package = "dplyr",
Version = "0.6"
), # there is no 0.6 in any of the releases, should get v1.2.1 as alternate from R v4.4
tidyrr = list(
Package = "tidyr",
Version = "1.3.2"
), # tidyrr does not exist
RPostgres = list(
Package = "RPostgres",
Version = NULL
), # no version provided, should get v1.4.10 as alternate from R v4.4
renv = list(
Package = "renv",
Version = "1.0.7"
), # renv already exists in lockfile, if override_lock = TRUE, should get v1.0.7 from R v4.2
xfun = list(
Package = "xfun",
Version = NULL
)
)
) # xfun already exists in lockfile, if override_lock = TRUE, should get v0.57 from R v4.4
}
35 changes: 30 additions & 5 deletions R/versionControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@
#'
#' @returns A message with the link of the PR
#' @importFrom checkmate assertCharacter assertLogical assertTRUE checkClass
#' @importFrom gh gh gh_tree_remote gh_token_exists
#' @importFrom gert git_branch_create git_branch
#' @export
issueOpen <- function(
title,
body,
newBranch = FALSE
) {
if (!requireNamespace("gh", quietly = TRUE)) {
stop(
"Package \"gh\" must be installed to use this function.",
call. = FALSE
)
}
if (!requireNamespace("gert", quietly = TRUE)) {
stop(
"Package \"gert\" must be installed to use this function.",
call. = FALSE
)
}
checkmate::assertCharacter(
title,
len = 1,
Expand Down Expand Up @@ -84,14 +94,24 @@ issueOpen <- function(
#'
#' @returns A message with the link of the issue
#' @importFrom checkmate assertCharacter assertLogical assertTRUE checkClass
#' @importFrom gh gh gh_tree_remote gh_token_exists
#' @importFrom gert git_branch_create git_branch
#' @export
pullRequest <- function(
title,
body,
base = "develop"
) {
if (!requireNamespace("gh", quietly = TRUE)) {
stop(
"Package \"gh\" must be installed to use this function.",
call. = FALSE
)
}
if (!requireNamespace("gert", quietly = TRUE)) {
stop(
"Package \"gert\" must be installed to use this function.",
call. = FALSE
)
}
checkmate::assertCharacter(
title,
len = 1,
Expand Down Expand Up @@ -134,9 +154,14 @@ pullRequest <- function(
#' and pull latest changes
#'
#' @returns Git log messages after checking out and pulling 'develop'
#' @importFrom gert git_branch_exists git_branch_checkout git_pull
#' @export
developCheckout <- function() {
if (!requireNamespace("gert", quietly = TRUE)) {
stop(
"Package \"gert\" must be installed to use this function.",
call. = FALSE
)
}
branch <- "develop"
if (gert::git_branch_exists(branch)) {
gert::git_branch_checkout(
Expand Down
2 changes: 1 addition & 1 deletion studyGenerics.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version: 1.0
sVersion: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
36 changes: 5 additions & 31 deletions tests/testthat/test-getPkgZips.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ test_that("Message checks - lockfile only", {
# Test on lockfile + supp, override_lock = FALSE ----
test_that("Message checks - lockfile + supp, override_lock = FALSE", {

msgs <- capture_messages(pkg_summary <- getPkgZips(lockfile_path = lockfile, supplement = supp))
lockfile <- mockLock()
msgs <- capture_messages(pkg_summary <- getPkgZips(lockfile_path = lockfile, supplement = suppPackages()))

expect_true(any(grepl("PACKAGE NOT FOUND: Unable to find DarwinShinyModules v0.4.0 or a suitable alternate version under R v4.4", msgs)))
expect_true(any(grepl("PACKAGE NOT FOUND: Unable to find utils vUNSPECIFIED or a suitable alternate version under R v4.4", msgs)))
Expand All @@ -71,7 +72,7 @@ test_that("Message checks - lockfile + supp, override_lock = FALSE", {
test_that("Message checks - lockfile + supp, override_lock = TRUE", {

lockfile <- mockLock()
msgs <- capture_messages(pkg_summary <- getPkgZips(lockfile_path = lockfile, supplement = supp, override_lock = TRUE))
msgs <- capture_messages(pkg_summary <- getPkgZips(lockfile_path = lockfile, supplement = suppPackages(), override_lock = TRUE))

expect_true(any(grepl("PACKAGE NOT FOUND: Unable to find DarwinShinyModules v0.4.0 or a suitable alternate version under R v4.4", msgs)))
expect_true(any(grepl("PACKAGE NOT FOUND: Unable to find utils vUNSPECIFIED or a suitable alternate version under R v4.4", msgs)))
Expand Down Expand Up @@ -103,34 +104,8 @@ test_that("mockLock()", {

lockfile <- mockLock()
# Create a supplementary file ----
supp <- list(
Packages = list(
devtools = list(
Package = "devtools",
Version = "2.5.2"
), # 2.5.2 exists in multiple releases, should pick from the newest (R v4.6)
dplyr = list(
Package = "dplyr",
Version = "0.6"
), # there is no 0.6 in any of the releases, should get v1.2.1 as alternate from R v4.4
tidyrr = list(
Package = "tidyr",
Version = "1.3.2"
), # tidyrr does not exist
RPostgres = list(
Package = "RPostgres",
Version = NULL
), # no version provided, should get v1.4.10 as alternate from R v4.4
renv = list(
Package = "renv",
Version = "1.0.7"
), # renv already exists in lockfile, if override_lock = TRUE, should get v1.0.7 from R v4.2
xfun = list(
Package = "xfun",
Version = NULL
)
)
) # xfun already exists in lockfile, if override_lock = TRUE, should get v0.57 from R v4.4
supp <- suppPackages()

# Sanity check of counts ----
lock <- renv::lockfile_read(lockfile)
pkgs <- names(lock[["Packages"]])
Expand All @@ -151,7 +126,6 @@ test_that("mockLock()", {
expect_equal(n_reqs, 46)
# expect_equal(n_reqs_wo_overlap, 41)
expect_equal(n_all, 56) # not 58 bc of the supps overlap

})


Expand Down
6 changes: 0 additions & 6 deletions tests/testthat/test-versionControl.R

This file was deleted.

Loading