Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release {precommit} 0.4.1 #551

Merged
merged 11 commits into from
Mar 29, 2024
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ repos:
# Only required when https://pre-commit.ci is used for config validation
- id: check-pre-commit-ci-config
- repo: https://github.com/lorenzwalthert/gitignore-tidy
rev: 475bf5d96927a1887ce2863ff3075b1d7240bc51
rev: 0.1.2
hooks:
- id: tidy-gitignore
- repo: local
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: precommit
Title: Pre-Commit Hooks
Version: 0.4.0.9000
Version: 0.4.1
Author: Lorenz Walthert
Maintainer: Lorenz Walthert <lorenz.walthert@icloud.com>
Description: Useful git hooks for R building on top of the multi-language
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# precommit 0.4.1

This release ensures unit tests can handle the error messages from {styler}
correctly that were modified slightly. Apart from hook dependency updates, this
release adds no user-facing changes.

Thanks [&#x0040;joshpersi](https://github.com/joshpersi) for contributing to this
release.


# precommit 0.4.0


Expand Down
2 changes: 1 addition & 1 deletion R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ set_config_source <- function(config_source,

target <- fs::path_ext_set(tmp, fs::path_ext(config_source))
utils::download.file(config_source, target, quiet = TRUE)
rlang::with_handlers(
rlang::try_fetch(
yaml::read_yaml(target, fileEncoding = "UTF-8"),
error = function(e) {
rlang::abort(paste0(
Expand Down
8 changes: 7 additions & 1 deletion R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,14 @@ release_prechecks <- function(bump, is_cran) {
dsc <- desc::description$new()
suppressMessages(dsc$bump_version(bump))
new_version <- paste0("v", dsc$get_version())
if (is_cran) {
release_branch <- paste0("rc-", new_version)
if (!(release_branch %in% names(git2r::branches()))) {
rlang::abort(paste0("need to be on branch ", release_branch))
}
}
abort_if_not_yes("Your target release has version {new_version}, correct?")
abort_if_not_yes("Did you prepare NEWS.md for this version ({new_version})?")
abort_if_not_yes("Did you commit NEWS.md for this version ({new_version})?")
dsc
}

Expand Down
4 changes: 2 additions & 2 deletions R/roxygen2.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ diff_requires_run_roxygenize <- function(root = ".") {
#' @keywords internal
#' @export
roxygen_assert_additional_dependencies <- function() {
out <- rlang::with_handlers(
out <- rlang::try_fetch(
# roxygen2 will load: https://github.com/r-lib/roxygen2/issues/771
pkgload::load_all(quiet = TRUE),
error = function(e) {
Expand Down Expand Up @@ -80,7 +80,7 @@ roxygen_assert_additional_dependencies <- function() {
#' @importFrom R.cache saveCache
# fails if accessed with R.cache::saveCache()!
roxygenize_with_cache <- function(key, dirs) {
out <- rlang::with_handlers(
out <- rlang::try_fetch(
roxygen2::roxygenise(),
error = function(e) e
)
Expand Down
6 changes: 3 additions & 3 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ autoupdate <- function(root = here::here()) {

ensure_renv_precommit_compat <- function(package_version_renv = utils::packageVersion("renv"),
root = here::here()) {
is_precommit <- suppressWarnings(rlang::with_handlers(
is_precommit <- suppressWarnings(rlang::try_fetch(
unname(read.dcf("DESCRIPTION")[, "Package"]) == "precommit",
error = function(e) FALSE
))
Expand All @@ -189,7 +189,7 @@ ensure_renv_precommit_compat <- function(package_version_renv = utils::packageVe
}

rev <- rev_read(path_config)
should_fail <- rlang::with_handlers(
should_fail <- rlang::try_fetch(
{
rev <- rev_as_pkg_version(rev)
maximal_rev <- package_version("0.1.3.9014")
Expand Down Expand Up @@ -279,7 +279,7 @@ snippet_generate <- function(snippet = "",
"supported for {.url pre-commit.ci}. See ",
'{.code vignette("ci", package = "precommit")} for details and solutions.'
))
remote_deps <- rlang::with_handlers(
remote_deps <- rlang::try_fetch(
desc::desc_get_field("Remotes"),
error = function(e) character()
)
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ is_conda_installation <- function() {
}

is_package <- function(root = here::here()) {
rlang::with_handlers(
rlang::try_fetch(
rprojroot::find_package_root_file(path = root),
error = function(e) NULL
) %>%
Expand Down Expand Up @@ -129,7 +129,7 @@ has_git <- function() {
is_git_repo <- function(root = here::here()) {
withr::local_dir(root)
if (has_git()) {
rlang::with_handlers(
rlang::try_fetch(
{
output <- call_and_capture(
"git",
Expand Down
9 changes: 4 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
This is a submission due to changes in roxygen2 7.3.0 and fixes also some issues
related to R devel changes.
This is a submission due to changes in styler's error messages.

## Test environments

- ubuntu 18.04 (on GitHub Actions): R 4.2
- Windows (on GitHub Actions): R 4.2
- macOS (on GitHub Actions): R 4.2
- ubuntu 18.04 (on GitHub Actions): R 4.3
- Windows (on GitHub Actions): R 4.3
- macOS (on GitHub Actions): R 4.3
- win-builder: R devel

## R CMD check results
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ stdout
sterr
stopifnot
styler
styler's
sublicenses
Sublicensing
Sys
Expand Down
2 changes: 1 addition & 1 deletion inst/pre-commit-config-pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.0
rev: v0.4.1
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand Down
2 changes: 1 addition & 1 deletion inst/pre-commit-config-proj.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.0
rev: v0.4.1
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-hook-roxygenize.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test_that("fails gratefully when not installed package is required according to
suppressWarnings(
roxygenize_with_cache(list(getwd()), dirs = dirs_R.cache("roxygenize"))
),
"The package .*required"
"The package.*required"
)
})

Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/test-hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ run_test("style-files",

run_test("style-files",
suffix = "-fail-parse.R", cmd_args = c("--cache-root=styler"),
std_err = "unexpected"
std_err = ""
)

# success with cmd args
Expand Down Expand Up @@ -110,16 +110,17 @@ run_test("style-files",
file_name = "style-files",
suffix = "-ignore-fail.R",
cmd_args = "--cache-root=styler",
std_err = "Invalid stylerignore sequences"
std_err = ""
)


# fail with cmd args
run_test("style-files",
file_name = "style-files-cmd",
suffix = "-success.R",
std_err = "scope must be one",
cmd_args = c("--scope=space", "--cache-root=styler")
cmd_args = c("--scope=space", "--cache-root=styler"),
std_err = "",
expect_success = FALSE
)

run_test("style-files",
Expand Down Expand Up @@ -485,7 +486,7 @@ run_test("roxygenize",
run_test("roxygenize",
file_name = c("man/flie.Rd" = "flie-true.Rd"),
suffix = "",
std_err = "Writing NAMESPACE",
std_err = "",
artifacts = c(
"DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"),
"R/roxygenize.R" = test_path("in/roxygenize.R")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test_that("GitHub Action CI setup works", {
root = getwd(),
open = FALSE, verbose = FALSE
)
expect_error(use_ci("stuff"), "must be one of")
expect_error(use_ci("stuff", root = getwd()), "must be one of")
use_ci("gha", root = getwd())
expect_true(file_exists(".github/workflows/pre-commit.yaml"))
})
Expand Down
Loading