Skip to content

Instantly share code, notes, and snippets.

@artemklevtsov
Created July 14, 2017 14:20
Show Gist options
  • Save artemklevtsov/acb6ea0eb3bda2bf8a041049f357386e to your computer and use it in GitHub Desktop.
Save artemklevtsov/acb6ea0eb3bda2bf8a041049f357386e to your computer and use it in GitHub Desktop.
Get R releases dates
library(xml2)
library(curl)
library(data.table)
library(lubridate)
r_svn_url <- "https://svn.r-project.org/R/tags/"
h <- handle_setheaders(new_handle(customrequest = "PROPFIND"), Depth="1")
req <- curl_fetch_memory(r_svn_url, handle = h)
doc <- read_xml(rawToChar(req$content))
ns <- xml_ns(doc)
prop <- xml_find_all(doc, ".//D:propstat/D:prop", ns)
dates <- xml_text(xml_find_first(prop, ".//D:creationdate", ns))
tags <- xml_text(xml_find_first(prop, ".//D:getetag", ns))
tags <- sub("^.*/tags/R-([-0-9]+).*$", "\\1", tags)
is_release <- grepl("^[0-9]+-[0-9]+(-[0-9]+|)$", tags)
tags <- tags[is_release]
dates <- dates[is_release]
tags <- gsub('-', '.', tags, fixed = TRUE)
res <- data.table(
version = tags,
date = ymd_hms(dates)
)
res[, (c("major", "minor", "patch")) := transpose(numeric_version(version))]
res[is.na(patch), patch := 0L]
res[minor > 0L, release := "minor"]
res[patch > 0L, release := "patch"]
res[minor == 0L & patch == 0L, release := "major"]
setkey(res, major, minor, patch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment