Skip to content

rename to main #307

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

Merged
merged 4 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

name: R-CMD-check
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
on:
push:
branches: [main, master]
branches:
main

name: pkgdown

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ This repo uses the [tic](https://github.com/ropenscilabs/tic) package for CI.

To create a new hook, have a look at the [official
documentation](https://pre-commit.com/#new-hooks) on creating new hooks, then have a look
at existing hooks in this repo. The actual executables are defined in [`inst/hooks/`](https://github.com/lorenzwalthert/precommit/tree/master/inst/hooks). In
at existing hooks in this repo. The actual executables are defined in [`inst/hooks/`](https://github.com/lorenzwalthert/precommit/tree/main/inst/hooks). In
the script, you can expect the passed command line arguments to be all options,
finally the files that should be processed with the hook.

For the scripts to become a hook, they need to be *registered* in
[`.pre-commit-hooks.yaml`](https://github.com/lorenzwalthert/precommit/blob/master/.pre-commit-hooks.yaml). As R is not currently a supported language of
[`.pre-commit-hooks.yaml`](https://github.com/lorenzwalthert/precommit/blob/main/.pre-commit-hooks.yaml). As R is not currently a supported language of
pre-commit (https://github.com/pre-commit/pre-commit/issues/926), most hooks use
`language: script` and then a shebang in the `entrypoint` script.

# Testing hooks

Hooks should be tested by checking both the positive outcome (hook passes) and
the negative outcome (hook fails) by adding two `run_test()` statements to
[`./tests/testthat/test-all.R`](https://github.com/lorenzwalthert/precommit/blob/master/tests/testthat/test-all.R). Look at existing examples and [the documentation
[`./tests/testthat/test-all.R`](https://github.com/lorenzwalthert/precommit/blob/main/tests/testthat/test-all.R). Look at existing examples and [the documentation
of `run_test()`](https://lorenzwalthert.github.io/precommit/reference/run_test.html). Note that this won't actually use pre-commit. It will simply
call the hook script the same way as pre-commit would, with the difference that
the test uses a path to the `Rscript` executable whereas with pre-commit, the
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ includes switching to R based hook for `readme-rmd-render`, avoiding the
used packages, roxygen snippet generation and more. In addition:

* Always sort `inst/WORDLIST` (#303).
* rename default branch to *main* (#307).


# precommit v0.1.3.9012

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


example_remote_config <- function() {
"https://github.com/raw/lorenzwalthert/precommit/master/inst/pre-commit-config-proj.yaml"
"https://github.com/raw/lorenzwalthert/precommit/main/inst/pre-commit-config-proj.yaml"
}
22 changes: 11 additions & 11 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#' @section CRAN release:
#' If `is_cran` is `TRUE`, the workflow is changed slightly:
#' - push to release branch, not master.
#' - push to release branch, not main.
#' - doesn't run [release_complete()]. This must be done manually after accepted
#' on CRAN.
#' @keywords internal
Expand All @@ -27,7 +27,7 @@ release_gh <- function(bump = "dev", is_cran = bump != "dev") {
new_dsc$write()
git_branch_set(is_cran)
if (!is_cran) {
on.exit(sys_call("git", c("checkout", "master")), add = TRUE)
on.exit(sys_call("git", c("checkout", "main")), add = TRUE)
}

# if we fail, must reset version, if we succeed, it's not stage
Expand Down Expand Up @@ -78,12 +78,12 @@ release_gh <- function(bump = "dev", is_cran = bump != "dev") {
#' @param tag The tag to push. `NULL` will derive the tag from `DESCRIPTION`.
#' @keywords internal
release_complete <- function(ask = TRUE, is_cran = ask, tag = NULL) {
if (git_branch_get() != "master") {
rlang::abort("Must be on master to complete the release.")
if (git_branch_get() != "main") {
rlang::abort("Must be on main to complete the release.")
}
if (ask) {
abort_if_not_yes("Did you merge the release branch into master?")
abort_if_not_yes("Did you pull the latest master from origin?")
abort_if_not_yes("Did you merge the release branch into main?")
abort_if_not_yes("Did you pull the latest main from origin?")
}
if (is_cran) {
if (is.null(tag)) {
Expand All @@ -94,7 +94,7 @@ release_complete <- function(ask = TRUE, is_cran = ask, tag = NULL) {
}
sys_call("git", glue::glue("push origin {tag}"))
}
precommit::autoupdate() # only updates if tag is on the master branch
precommit::autoupdate() # only updates if tag is on the main branch
desc::desc_bump_version("dev")
cli::cli_alert_success("Bumped version to dev")
sys_call("git", glue::glue('commit DESCRIPTION .pre-commit-config.yaml -m "use latest release"'),
Expand Down Expand Up @@ -184,9 +184,9 @@ git_branch_set <- function(is_cran) {
)
cli::cli_alert_success("Checked out branch {branch_name} for CRAN release process.")
} else {
if (git_branch_get() != "master") {
if (git_branch_get() != "main") {
rlang::abort(paste(
"Need to be on branch 'master' to create a release, otherwise autoudate",
"Need to be on branch 'main' to create a release, otherwise autoudate",
"won't use the new ref."
))
}
Expand All @@ -196,9 +196,9 @@ git_branch_set <- function(is_cran) {

git_assert_even_with_origin <- function() {
tmp <- tempfile()
system2("git", "diff HEAD..origin/master", stdout = tmp)
system2("git", "diff HEAD..origin/main", stdout = tmp)
if (length(readLines(tmp) > 0)) {
rlang::abort("remote master must be even with local master before release process can start.")
rlang::abort("remote main must be even with local main before release process can start.")
}
}

Expand Down
2 changes: 1 addition & 1 deletion man/release_gh.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/FAQ.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ described [here](https://pre-commit.com/#temporarily-disabling-hooks).

## How does one create a new pre-commit hook?

How to contribute new hooks is explained in [`CONTRIBUTING.md`](https://github.com/lorenzwalthert/precommit/blob/master/CONTRIBUTING.md).
How to contribute new hooks is explained in [`CONTRIBUTING.md`](https://github.com/lorenzwalthert/precommit/blob/main/CONTRIBUTING.md).

***

Expand Down