Permalink
Browse files

release(): add package version check. Fixes #209

  • Loading branch information...
1 parent 6b73867 commit 6f54ac8b53edd6927244f303f74720876e8f7fb6 @wch wch committed Dec 12, 2012
Showing with 31 additions and 20 deletions.
  1. +0 −20 R/check-cran.r
  2. +14 −0 R/cran.r
  3. +17 −0 R/release.r
View
@@ -136,26 +136,6 @@ check_cran <- function(pkgs, libpath = file.path(tempdir(), "R-lib"),
invisible(results)
}
-available_packages <- memoise(function(repos, type) {
- suppressWarnings(available.packages(contrib.url(repos, type)))
-})
-
-package_url <- function(package, repos, available = available.packages(contrib.url(repos, "source"))) {
-
- ok <- (available[, "Package"] == package)
- ok <- ok & !is.na(ok)
-
- vers <- package_version(available[ok, "Version"])
- keep <- vers == max(vers)
- keep[duplicated(keep)] <- FALSE
- ok[ok][!keep] <- FALSE
-
- name <- paste(package, "_", available[ok, "Version"], ".tar.gz", sep = "")
- url <- file.path(available[ok, "Repository"], name)
-
- list(name = name, url = url)
-}
-
parse_check_results <- function(path) {
check_path <- file.path(path, "00check.log")
View
@@ -17,3 +17,17 @@ package_url <- function(package, repos, available = available.packages(contrib.u
list(name = name, url = url)
}
+
+
+# Return the version of a package on CRAN (or other repository)
+# @param package The name of the package.
+# @param available A matrix of information about packages.
+cran_pkg_version <- function(package, available = available.packages()) {
+
+ idx <- available[, "Package"] == package
+ if(any(idx)) {
+ as.package_version(available[package, "Version"])
+ } else {
+ NULL
+ }
+}
View
@@ -36,6 +36,23 @@ release <- function(pkg = ".", check = TRUE) {
check(pkg, cran = TRUE, check_version = TRUE)
if (yesno("Was package check successful?"))
return(invisible())
+
+ } else {
+ # If we don't run the full checks, then check that the package version is
+ # sufficient for submission to CRAN.
+ cran_version <- cran_pkg_version(pkg$package)
+
+ if (is.null(cran_version)) {
+ message("Package ", pkg$package, " not found on CRAN. This is a new package.")
+
+ } else if (as.package_version(pkg$version) > cran_version) {
+ message("Local package ", pkg$package, " ", pkg$version,
+ " is greater than CRAN version ", cran_version, ".")
+
+ } else {
+ stop("Local package ", pkg$package, " ", pkg$version,
+ " must be greater than CRAN version ", cran_version, ".")
+ }
}
if (yesno("Have you checked on win-builder (with build_win)?"))

0 comments on commit 6f54ac8

Please sign in to comment.