From b05bd25c63690e1b61d978888c298c7b19aacbe4 Mon Sep 17 00:00:00 2001 From: hadley Date: Wed, 2 Aug 2017 17:49:06 -0500 Subject: [PATCH] Add CRAN-RELEASE reminder file Fixes #1198 --- NEWS.md | 3 +++ R/release.r | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8cfec8404..5415568b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # devtools 1.13.3.9000 +* If you use git `release()` now generates a file called `CRAN-RELEASE` + that reminds you to tag the commit that you submitted to CRAN (#1198). + * `release()` once again looks for additional release questions in the correct environment (#1434). diff --git a/R/release.r b/R/release.r index 014b1a5bd..681f340f7 100644 --- a/R/release.r +++ b/R/release.r @@ -133,9 +133,8 @@ release <- function(pkg = ".", check = TRUE, args = NULL, spelling = "en_US") { submit_cran(pkg, args = args) - if (uses_git(pkg$path)) { - message("Don't forget to tag the release when the package is accepted!") - } + flag_release(pkg) + invisible(TRUE) } @@ -322,3 +321,22 @@ upload_cran <- function(pkg, built_path) { } as.object_size <- function(x) structure(x, class = "object_size") + +flag_release <- function(pkg = ".") { + pkg <- as.package(pkg) + if (!uses_git(pkg$path)) { + return(invisible()) + } + + message("Don't forget to tag this release once accepted by CRAN") + + date <- Sys.Date() + commit <- git2r::commits(git2r::init(pkg$path), n = 1)[[1]] + sha <- substr(commit@sha, 1, 10) + + msg <- paste0( + "This package was submitted to CRAN on ", date, ".\n", + "Once it is accepted, delete this file and tag the release (commit ", sha, ")." + ) + writeLines(msg, file.path(pkg$path, "CRAN-RELEASE")) +}