mirror of https://git.sr.ht/~hrbrmstr/vershist
boB Rudis
5 years ago
10 changed files with 117 additions and 5 deletions
@ -0,0 +1,61 @@ |
|||
#' Retrieve etcd Version Release History |
|||
#' |
|||
#' Reads <https://github.com/etcd-io/etcd/releases> to build a data frame of |
|||
#' etcd version release numbers and dates with semantic version |
|||
#' strings parsed and separate fields added. The data frame is also arranged in |
|||
#' order from lowest version to latest version and the `vers` column is an |
|||
#' ordered factor. |
|||
#' |
|||
#' @md |
|||
#' @note This function requires a valid GitHub API key stored in `GITHUB_PAT` |
|||
#' @export |
|||
etcd_version_history <- function() { |
|||
|
|||
page <- gh::gh("/repos/etcd-io/etcd/tags") |
|||
|
|||
purrr::map_df( |
|||
page, ~{ |
|||
list( |
|||
vers = .x$name, |
|||
rls_date = gh::gh(.x$commit$url)$commit$author$date # kinda dangerous |
|||
) |
|||
}) -> xdf |
|||
|
|||
sgh_next <- purrr::safely(gh::gh_next) # to stop on gh_next() error |
|||
|
|||
while(TRUE) { |
|||
page <- sgh_next(page) |
|||
if (is.null(page$result)) break; |
|||
page <- page$result |
|||
dplyr::bind_rows( |
|||
xdf, |
|||
purrr::map_df( |
|||
page, ~{ |
|||
list( |
|||
vers = .x$name, |
|||
rls_date = gh::gh(.x$commit$url)$commit$author$date # kinda dangerous |
|||
) |
|||
}) |
|||
) -> xdf |
|||
} |
|||
|
|||
suppressWarnings( |
|||
suppressMessages( |
|||
dplyr::mutate(xdf, vers = stri_replace_first_fixed(vers, "v", "")) %>% |
|||
dplyr::mutate(rls_date = as.Date(stri_sub(rls_date, 1, 10))) %>% |
|||
dplyr::mutate(rls_year = lubridate::year(rls_date)) %>% |
|||
tidyr::separate(vers, c("major", "minor", "patch", "build"), remove=FALSE) %>% |
|||
dplyr::mutate(prerelease = ifelse( |
|||
stri_detect_regex(build, "[[:alpha:]]"), |
|||
stri_extract_first_regex(build, "[[:alpha:]][[:alnum:]]+"), |
|||
"" |
|||
)) %>% |
|||
dplyr::mutate(build = stri_replace_first_regex(build, "[[:alpha:]][[:alnum:]]+", "")) %>% |
|||
dplyr::mutate_at(.vars=c("major", "minor", "patch", "build"), .funs=c(as.integer)) %>% |
|||
dplyr::arrange(major, minor, patch) %>% |
|||
dplyr::mutate(vers = factor(vers, levels=vers)) %>% |
|||
dplyr::select(vers, rls_date, rls_year, major, minor, patch, prerelease, build) |
|||
) |
|||
) |
|||
|
|||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,18 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/etcd.R |
|||
\name{etcd_version_history} |
|||
\alias{etcd_version_history} |
|||
\title{Retrieve etcd Version Release History} |
|||
\usage{ |
|||
etcd_version_history() |
|||
} |
|||
\description{ |
|||
Reads \url{https://github.com/etcd-io/etcd/releases} to build a data frame of |
|||
etcd version release numbers and dates with semantic version |
|||
strings parsed and separate fields added. The data frame is also arranged in |
|||
order from lowest version to latest version and the \code{vers} column is an |
|||
ordered factor. |
|||
} |
|||
\note{ |
|||
This function requires a valid GitHub API key stored in \code{GITHUB_PAT} |
|||
} |
Loading…
Reference in new issue