From f0a1d195eb790aa2584ecbcce6d93614420f5beb Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 8 Apr 2021 10:05:24 +0200 Subject: [PATCH 1/5] added tests for location "docs" --- tests/skeleton_git2r.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/skeleton_git2r.R b/tests/skeleton_git2r.R index 6a73b111..4b3d0b0d 100644 --- a/tests/skeleton_git2r.R +++ b/tests/skeleton_git2r.R @@ -1,7 +1,5 @@ -testSkeletonGit2r <- function() { - wd <- tempdir() - +testSkeletonGit2r <- function(wd) { # options(error=traceback) # make a package to test with @@ -268,7 +266,13 @@ testRepoActions <- function(repodir){ } } +wd <- tempdir() if (requireNamespace("git2r", quietly=TRUE)) { - repodir <- testSkeletonGit2r() + options("dratBranch" = "gh-pages") + repodir <- testSkeletonGit2r(wd) testRepoActions(repodir) + unlink(file.path(wd,"drat"), recursive = TRUE) } +options("dratBranch" = "docs") +repodir <- testSkeletonGit2r(wd) +testRepoActions(repodir) From 3b3f6024b7ef0106a2db4bd9fec2573c7a6ff702 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 8 Apr 2021 10:06:30 +0200 Subject: [PATCH 2/5] added verbose error message if DESCRIPTION cannot be found in compressed file See #114 --- R/insertPackage.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/R/insertPackage.R b/R/insertPackage.R index f0c0800b..1defdb6f 100644 --- a/R/insertPackage.R +++ b/R/insertPackage.R @@ -255,17 +255,24 @@ getPackageInfo <- function(file) { td <- tempdir() if (grepl(".zip$", file)) { - unzip(file, exdir = td) + unzip(file, exdir = td) # Windows } else if (grepl(".tgz$", file)) { - untar(file, exdir = td) + untar(file, exdir = td) # macOS } else { + # Source ##stop("Not sure we can handle ", file, call.=FALSE) fields <- c("Source" = TRUE, "Rmajor" = NA, "osxFolder" = "") return(fields) } - + + # Working with data from compressed file only from here on pkgname <- gsub("^([a-zA-Z0-9.]*)_.*", "\\1", basename(file)) path <- file.path(td, pkgname, "DESCRIPTION") + if(!file.exists(path)){ + stop("DESCRIPTION file cannot be opened in '",file,"'. It is expected ", + "to be located in the base directory of compressed file.", + call. = FALSE) + } builtstring <- read.dcf(path, 'Built') unlink(file.path(td, pkgname), recursive = TRUE) From 72f7a13c50264567082e2b5899369916e0e5f056 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 8 Apr 2021 10:08:01 +0200 Subject: [PATCH 3/5] updated man pages with roxygen2 To solve some documentation mismatches detected during R CMD check the man pages were updated. The issue was fixed --- DESCRIPTION | 2 +- man/addRepo.Rd | 1 + man/archivePackages.Rd | 16 +++++++++----- man/initRepo.Rd | 7 +++++-- man/insertPackage.Rd | 12 ++++++++--- man/pruneRepo.Rd | 47 +++++++++++++++++++++++++++++++----------- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6c47e004..364397e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,4 +21,4 @@ License: GPL (>= 2) URL: https://github.com/eddelbuettel/drat, https://dirk.eddelbuettel.com/code/drat.html BugReports: https://github.com/eddelbuettel/drat/issues Encoding: UTF-8 -RoxygenNote: 6.0.1 +RoxygenNote: 7.1.1 diff --git a/man/addRepo.Rd b/man/addRepo.Rd index 358240ee..ebf33da5 100644 --- a/man/addRepo.Rd +++ b/man/addRepo.Rd @@ -41,6 +41,7 @@ This function retrieves the current set of repositories (see non-GitHub repositories an alternative URL can be specified as \sQuote{alturl} (and assigned to \sQuote{account} as well). + An aliased function \code{add} is also available, but not exported via \code{NAMESPACE} to not clobber a possibly unrelated function; use it via \code{drat:::add()}. diff --git a/man/archivePackages.Rd b/man/archivePackages.Rd index 318049c9..dcbce4fd 100644 --- a/man/archivePackages.Rd +++ b/man/archivePackages.Rd @@ -2,17 +2,23 @@ % Please edit documentation in R/archivePackages.R \name{archivePackages} \alias{archivePackages} -\alias{archivePackages} \alias{archivePackagesForAllRversions} \title{Move older copies of packages to an archive} \usage{ -archivePackages(repopath = getOption("dratRepo", "~/git/drat"), +archivePackages( + repopath = getOption("dratRepo", "~/git/drat"), type = c("source", "binary", "mac.binary", "mac.binary.el-capitan", - "mac.binary.mavericks", "win.binary", "both"), pkg, version = getRversion()) + "mac.binary.mavericks", "win.binary", "both"), + pkg, + version = getRversion() +) -archivePackagesForAllRversions(repopath = getOption("dratRepo", "~/git/drat"), +archivePackagesForAllRversions( + repopath = getOption("dratRepo", "~/git/drat"), type = c("source", "binary", "mac.binary", "mac.binary.el-capitan", - "mac.binary.mavericks", "win.binary", "both"), pkg) + "mac.binary.mavericks", "win.binary", "both"), + pkg +) } \arguments{ \item{repopath}{Character variable with the path to the repo; diff --git a/man/initRepo.Rd b/man/initRepo.Rd index 38f0ea0d..7e3dd1ba 100644 --- a/man/initRepo.Rd +++ b/man/initRepo.Rd @@ -4,8 +4,11 @@ \alias{initRepo} \title{Intialize a git repo for drat} \usage{ -initRepo(name = "drat", basepath = getOption("dratDirectory", "~/git"), - location = getOption("dratBranch", "gh-pages")) +initRepo( + name = "drat", + basepath = getOption("dratDirectory", "~/git"), + location = getOption("dratBranch", "gh-pages") +) } \arguments{ \item{name}{A character variable with the name the new repository, diff --git a/man/insertPackage.Rd b/man/insertPackage.Rd index 439d01e2..97a78bbd 100644 --- a/man/insertPackage.Rd +++ b/man/insertPackage.Rd @@ -7,9 +7,15 @@ \alias{insert} \title{Insert a package source or binary file into a drat repository} \usage{ -insertPackage(file, repodir = getOption("dratRepo", "~/git/drat"), - commit = FALSE, pullfirst = FALSE, action = c("none", "archive", - "prune"), location = getOption("dratBranch", "gh-pages"), ...) +insertPackage( + file, + repodir = getOption("dratRepo", "~/git/drat"), + commit = FALSE, + pullfirst = FALSE, + action = c("none", "archive", "prune"), + location = getOption("dratBranch", "gh-pages"), + ... +) insertPackages(file, ...) diff --git a/man/pruneRepo.Rd b/man/pruneRepo.Rd index 966d19e4..dbfb7d61 100644 --- a/man/pruneRepo.Rd +++ b/man/pruneRepo.Rd @@ -3,26 +3,44 @@ \name{pruneRepo} \alias{pruneRepo} \alias{getRepoInfo} -\alias{pruneRepo} \alias{pruneRepoForAllRversions} \alias{updateRepo} \title{Prune repository from older copies of packages} \usage{ -getRepoInfo(repopath = getOption("dratRepo", "~/git/drat"), +getRepoInfo( + repopath = getOption("dratRepo", "~/git/drat"), type = c("source", "binary", "mac.binary", "mac.binary.el-capitan", - "mac.binary.mavericks", "win.binary", "both"), pkg, version = getRversion()) + "mac.binary.mavericks", "win.binary", "both"), + pkg, + version = getRversion(), + location = getOption("dratBranch", "gh-pages") +) -pruneRepo(repopath = getOption("dratRepo", "~/git/drat"), type = c("source", - "mac.binary", "mac.binary.el-capitan", "mac.binary.mavericks", "win.binary", - "both"), pkg, version = getRversion(), remove = FALSE) +pruneRepo( + repopath = getOption("dratRepo", "~/git/drat"), + type = c("source", "mac.binary", "mac.binary.el-capitan", "mac.binary.mavericks", + "win.binary", "both"), + pkg, + version = getRversion(), + remove = FALSE, + location = getOption("dratBranch", "gh-pages") +) -pruneRepoForAllRversions(repopath = getOption("dratRepo", "~/git/drat"), - type = c("source", "mac.binary", "mac.binary.el-capitan", - "mac.binary.mavericks", "win.binary", "both"), pkg, remove = FALSE) +pruneRepoForAllRversions( + repopath = getOption("dratRepo", "~/git/drat"), + type = c("source", "mac.binary", "mac.binary.el-capitan", "mac.binary.mavericks", + "win.binary", "both"), + pkg, + remove = FALSE +) -updateRepo(repopath = getOption("dratRepo", "~/git/drat"), - type = c("source", "mac.binary", "mac.binary.el-capitan", - "mac.binary.mavericks", "win.binary", "both"), version = NA, ...) +updateRepo( + repopath = getOption("dratRepo", "~/git/drat"), + type = c("source", "mac.binary", "mac.binary.el-capitan", "mac.binary.mavericks", + "win.binary", "both"), + version = NA, + ... +) } \arguments{ \item{repopath}{Character variable with the path to the repo; @@ -44,6 +62,11 @@ default), pruning is performed on all packages.} available R versions will be used. If \code{version = NULL}, this defaults to \code{getRversion()}.} +\item{location}{An optional character variable with the GitHub Pages location: +either \dQuote{gh-pages} indicating a branch of that name, or +\dQuote{docs/} directory in the main branch. The default value can +be overridden via the \dQuote{dratBranch} option.} + \item{remove}{Character or logical variable indicating whether files should be removed. Nothing happens if \sQuote{FALSE}. If different from (logical) \sQuote{FALSE} and equal to character From ba62b14da6b372c56f135f8cacd9eef3edc4bbdc Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 8 Apr 2021 10:08:33 +0200 Subject: [PATCH 4/5] version bump --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 364397e3..f6771871 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: drat Type: Package Title: 'Drat' R Archive Template -Version: 0.1.8.1 -Date: 2021-03-13 +Version: 0.1.8.2 +Date: 2021-04-08 Author: Dirk Eddelbuettel with contributions by Carl Boettiger, Neal Fultz, Sebastian Gibb, Colin Gillespie, Jan Górecki, Matt Jones, Thomas Leeper, Steven Pav, Jan Schulz, Christoph Stepper, Felix G.M. Ernst and Patrick From af229c31c2cdd8259b18c5546bf02f0c7b242821 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Thu, 8 Apr 2021 10:16:07 +0200 Subject: [PATCH 5/5] restructured test start for repo init and repo actions --- tests/skeleton_git2r.R | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/skeleton_git2r.R b/tests/skeleton_git2r.R index 4b3d0b0d..c5115bce 100644 --- a/tests/skeleton_git2r.R +++ b/tests/skeleton_git2r.R @@ -266,13 +266,16 @@ testRepoActions <- function(repodir){ } } +runTest <- function(wd, location = "gh-pages"){ + options("dratBranch" = location) + repodir <- testSkeletonGit2r(wd) + testRepoActions(repodir) + unlink(file.path(wd,"foo"), recursive = TRUE) + unlink(file.path(wd,"drat"), recursive = TRUE) +} + wd <- tempdir() if (requireNamespace("git2r", quietly=TRUE)) { - options("dratBranch" = "gh-pages") - repodir <- testSkeletonGit2r(wd) - testRepoActions(repodir) - unlink(file.path(wd,"drat"), recursive = TRUE) + runTest(wd, "gh-pages") } -options("dratBranch" = "docs") -repodir <- testSkeletonGit2r(wd) -testRepoActions(repodir) +runTest(wd, "docs") \ No newline at end of file