https://github.com/alexym1/captain
Running 'git' Pre-Commit Hooks
https://github.com/alexym1/captain
precommit precommit-hooks r
Last synced: 2 months ago
JSON representation
Running 'git' Pre-Commit Hooks
- Host: GitHub
- URL: https://github.com/alexym1/captain
- Owner: alexym1
- License: other
- Created: 2024-11-01T19:00:29.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-09-30T17:34:10.000Z (3 months ago)
- Last Synced: 2025-10-22T04:43:48.887Z (2 months ago)
- Topics: precommit, precommit-hooks, r
- Language: R
- Homepage: https://alexym1.github.io/captain/
- Size: 2.82 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS.txt
Awesome Lists containing this project
README
---
output: github_document
always_allow_html: true
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://cran.r-project.org/package=captain)
[](https://cran.r-project.org/package=captain)

[](https://github.com/alexym1/captain/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/alexym1/captain?branch=master)
> Running R pre-commit hooks
## Overview
Pre-commit hooks are scripts that run automatically before a commit is finalized in Git. They’re used to catch issues early by enforcing checks like code formatting, linting, or running tests before changes are committed.
`captain` (hook) is a package that allows you to run git pre-commit hooks in a R environment.
## Installation
The `captain` package can be installed from CRAN as follows:
```{r eval = FALSE}
install.packages("captain")
```
The latest version can be installed from GitHub as follows:
```{r eval = FALSE}
# install.packages("pak")
pak::pak("alexym1/captain")
```
## Usage
### Initialize pre-commit framework
```{r eval = FALSE}
captain::install_precommit()
```
### Run hooks
```{r eval = FALSE}
captain::run_precommit()
```
### Add hooks
Editing the `.pre-commit-config` file using `captain::edit_precommit_config()`:
```{bash eval = FALSE}
repos:
- repo: local
hooks:
- id: renv
name: Synchronize project from renv.lock
description: Synchronize the project from the renv.lock
entry: Rscript inst/pre-commit/hooks/synchronize_project.R
language: system
pass_filenames: false
```
## Code of conduct
Please note that this project is released with a [Contributor Code of Conduct](https://alexym1.github.io/captain/CONTRIBUTING.html). By participating in this project you agree to abide by its terms.
## Acknowledgments
This logo was created by [@obstacle.graphic](https://linktr.ee/obstacle.graphic).
