Просмотр исходного кода

Keep check_version from failing if no internet connection

tags/v0.2.0
Garrick Aden-Buie 8 лет назад
Родитель
Сommit
3b01cf267a
1 измененных файлов: 10 добавлений и 7 удалений
  1. +10
    -7
      R/regex_gadget.R

+ 10
- 7
R/regex_gadget.R Просмотреть файл

ok_to_check <- getOption("regexplain.no.check.version", TRUE) ok_to_check <- getOption("regexplain.no.check.version", TRUE)
if (!ok_to_check) return(NULL) if (!ok_to_check) return(NULL)
if (!requireNamespace('jsonlite', quietly = TRUE)) return(NULL) if (!requireNamespace('jsonlite', quietly = TRUE)) return(NULL)
gh_tags <- jsonlite::fromJSON(
paste0("https://api.github.com/repos/", gh_user, "/", gh_repo, "/git/refs/tags"),
simplifyDataFrame = TRUE
)
gh_tags$tag <- sub("refs/tags/", "", gh_tags$ref, fixed = TRUE)
gh_tags$version <- sub("^v\\.?", "", gh_tags$tag)
if (any(gh_tags$version > this_version)) {
gh_tags <- NULL
try({
gh_tags <- jsonlite::fromJSON(
paste0("https://api.github.com/repos/", gh_user, "/", gh_repo, "/git/refs/tags"),
simplifyDataFrame = TRUE
)
gh_tags$tag <- sub("refs/tags/", "", gh_tags$ref, fixed = TRUE)
gh_tags$version <- sub("^v\\.?", "", gh_tags$tag)
})
if (!is.null(gh_tags) && any(gh_tags$version > this_version)) {
max_version <- max(gh_tags$version) max_version <- max(gh_tags$version)
max_tag <- gh_tags$tag[gh_tags$version == max_version] max_tag <- gh_tags$tag[gh_tags$version == max_version]
options(regexplain.no.check.version = FALSE) options(regexplain.no.check.version = FALSE)

Загрузка…
Отмена
Сохранить