Skip to content

Commit

Permalink
- Dates are added to NEWS headers if existing headers have them, or f…
Browse files Browse the repository at this point in the history
…or a new NEWS file (#29).

Closes #29.
  • Loading branch information
krlmlr committed Jul 25, 2020
1 parent f5b6c3a commit 6164d68
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions R/update-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@ update_version_impl <- function(which) {

ui_done("Adding header to {ui_path(news_path)}")

add_to_news(paste0(
"# ", desc$get("Package"), " ", new_version, "\n"
))
header <- paste0(
"# ", desc$get("Package"), " ", new_version,
if (date_in_news_headers()) paste0(" (", Sys.Date(), ")"),
"\n"
)
add_to_news(header)

desc$write()
}

date_in_news_headers <- function() {
headers <- get_news_headers()
if (nrow(headers) == 0) {
# Add date by default
return(TRUE)
}

dates <- grep("[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]", headers$extra)
length(dates) > 0
}

get_news_headers <- function() {
news <- readLines(news_path)
rx <- "^# +(?<package>[a-zA-Z][a-zA-Z0-9.]*[a-zA-Z0-9]) +(?<version>[0-9][0-9.-]*) *(?<extra>.*)$"
Expand Down

0 comments on commit 6164d68

Please sign in to comment.