data-raw/gh_tools.R

# from https://github.com/randy3k/rl/blob/master/R/tag.R
#' Check CRAN Release
#' @inheritParams setup_package
#' @export
tag_release <- function(pkg_name = NULL) {
  if (is.null(pkg_name)) {
    proj_path <- usethis::proj_get()
  }
  pkg_path <- proj_path
  release_file <- fs::path(proj_path, "CRAN-RELEASE")
  if (!fs::file_exists(release_file)) {
    rlang::inform("CRAN-RELEASE file not found")
    return(base::invisible())
  }
  line <- readr::read_lines(release_file)[2]
  match <- regexec("commit ([a-z0-9]+)", line)
  sha <- regmatches(line, match)[[1]][2]
  if (is.na(sha)) {
    cat("Cannot parse CRAN-RELEASE\n")
    return(base::invisible())
  }
  pkg_version <- ""
  semver <- stringr::str_extract(
    paste0("v", pkg_version), "v[0-9]+\\.[0-9]+\\.[0-9]+"
  )[[1]]
  # if (devtools:::yesno(glue::glue("tag {sha} as {semver}"))) {
  #   return(base::invisible())
  # }
  tag_sha <- gert::git_tag_create(
    semver,
    message = semver, ref = sha, repo = pkg_path
  )
  file.remove(release_file)
  invisible(tag_sha)
}

# I'm testing spell check stuff
# from https://github.com/r-lib/gert/blob/master/README.md
git_clone_test <- function() {
  path <- file.path(tempdir(), "gert")
  repo <- gert::git_clone("https://github.com/r-lib/gert", path)
  print(repo)
}
luciorq/luciolib documentation built on Dec. 18, 2020, 11:43 a.m.