Skip to content

Commit ba14434

Browse files
Copilotmaehr
andauthored
Migrate git hooks from Husky to Prek and refresh gitattributes (#68)
* Initial plan * chore: migrate husky to prek Co-authored-by: maehr <14755525+maehr@users.noreply.github.com> * docs: clarify prek usage details Co-authored-by: maehr <14755525+maehr@users.noreply.github.com> * chore: refresh gitattributes and link checks Co-authored-by: maehr <14755525+maehr@users.noreply.github.com> * docs: remove husky migration note Co-authored-by: maehr <14755525+maehr@users.noreply.github.com> * chore: update .gitattributes to enhance file type handling and normalization --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: maehr <14755525+maehr@users.noreply.github.com>
1 parent 65412fb commit ba14434

File tree

9 files changed

+673
-200
lines changed

9 files changed

+673
-200
lines changed

.gitattributes

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
1+
# Basic .gitattributes for a python repo.
2+
3+
# Source files
4+
# ============
5+
*.pxd text diff=python
6+
*.py text diff=python
7+
*.py3 text diff=python
8+
*.pyw text diff=python
9+
*.pyx text diff=python
10+
*.pyz text diff=python
11+
*.pyi text diff=python
12+
13+
# Binary files
14+
# ============
15+
*.db binary
16+
*.p binary
17+
*.pkl binary
18+
*.pickle binary
19+
*.pyc binary export-ignore
20+
*.pyo binary export-ignore
21+
*.pyd binary
22+
23+
# Jupyter notebook
24+
*.ipynb text eol=lf
25+
26+
# Note: .db, .p, and .pkl files are associated
27+
# with the python modules ``pickle``, ``dbm.*``,
28+
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
29+
# (among others).
30+
31+
# Basic .gitattributes for a R repo.
32+
33+
# Source files
34+
# ============
35+
*.Rdata binary
36+
*.RData binary
37+
*.rda binary
38+
*.rdb binary
39+
*.rds binary
40+
*.Rd text
41+
*.Rdx binary
42+
*.Rmd text
43+
*.R text
44+
*.Rproj text
45+
*.[Rr]md linguist-detectable
46+
147
# Common settings that generally should always be used with your language specific settings
2-
# generated by https://www.richie-bendall.ml/gitattributes-generator/
348

449
# Auto detect text files and perform LF normalization
550
* text=auto
@@ -26,7 +71,7 @@
2671
*.adoc text
2772
*.textile text
2873
*.mustache text
29-
*.csv text
74+
*.csv text eol=crlf
3075
*.tab text
3176
*.tsv text
3277
*.txt text
@@ -51,6 +96,7 @@
5196
# Scripts
5297
*.bash text eol=lf
5398
*.fish text eol=lf
99+
*.ksh text eol=lf
54100
*.sh text eol=lf
55101
*.zsh text eol=lf
56102
# These are explicitly windows files and should use crlf
@@ -67,10 +113,24 @@
67113

68114
# Archives
69115
*.7z binary
116+
*.bz binary
117+
*.bz2 binary
118+
*.bzip2 binary
70119
*.gz binary
120+
*.lz binary
121+
*.lzma binary
122+
*.rar binary
71123
*.tar binary
124+
*.taz binary
125+
*.tbz binary
126+
*.tbz2 binary
72127
*.tgz binary
128+
*.tlz binary
129+
*.txz binary
130+
*.xz binary
131+
*.Z binary
73132
*.zip binary
133+
*.zst binary
74134

75135
# Text files where line endings should be preserved
76136
*.patch -text
@@ -86,52 +146,6 @@
86146
# Apply override to all files in the directory
87147
*.md linguist-detectable
88148

89-
# Basic .gitattributes for a python repo.
90-
91-
# Source files
92-
# ============
93-
*.pxd text diff=python
94-
*.py text diff=python
95-
*.py3 text diff=python
96-
*.pyw text diff=python
97-
*.pyx text diff=python
98-
*.pyz text diff=python
99-
*.pyi text diff=python
100-
101-
# Binary files
102-
# ============
103-
*.db binary
104-
*.p binary
105-
*.pkl binary
106-
*.pickle binary
107-
*.pyc binary export-ignore
108-
*.pyo binary export-ignore
109-
*.pyd binary
110-
111-
# Jupyter notebook
112-
*.ipynb text eol=lf
113-
114-
# Note: .db, .p, and .pkl files are associated
115-
# with the python modules ``pickle``, ``dbm.*``,
116-
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
117-
# (among others).
118-
119-
# Basic .gitattributes for a R repo.
120-
121-
# Source files
122-
# ============
123-
*.Rdata binary
124-
*.RData binary
125-
*.rda binary
126-
*.rdb binary
127-
*.rds binary
128-
*.Rd text
129-
*.Rdx binary
130-
*.Rmd text
131-
*.R text
132-
*.Rproj text
133-
*.[Rr]md linguist-detectable
134-
135149
## GITATTRIBUTES FOR WEB PROJECTS
136150
#
137151
# These settings are for any web project.
@@ -160,6 +174,8 @@
160174
*.inc text
161175
*.ini text
162176
*.js text
177+
*.mjs text
178+
*.cjs text
163179
*.json text
164180
*.jsx text
165181
*.less text
@@ -238,7 +254,7 @@ TODO text
238254
*.conf text
239255
*.config text
240256
.editorconfig text
241-
.env text
257+
*.env text
242258
.gitattributes text
243259
.gitconfig text
244260
.htaccess text
@@ -254,6 +270,8 @@ yarn.lock text -diff
254270
browserslist text
255271
Makefile text
256272
makefile text
273+
# Fixes syntax highlighting on GitHub to allow comments
274+
tsconfig.json linguist-language=JSON-with-Comments
257275

258276
# Heroku
259277
Procfile text
@@ -333,9 +351,15 @@ Procfile text
333351
# Executables
334352
*.exe binary
335353
*.pyc binary
354+
# Prevents massive diffs caused by vendored, minified files
355+
**/.yarn/releases/** binary
356+
**/.yarn/plugins/** binary
336357

337358
# RC files (like .babelrc or .eslintrc)
338359
*.*rc text
339360

340361
# Ignore files (like .npmignore or .gitignore)
341362
*.*ignore text
363+
364+
# Prevents massive diffs from built files
365+
dist/** binary

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.lycheerc.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
# https://lychee.cli.rs/configuration/
33

44
# Exclude template placeholders from link checking
5-
exclude = ["USERNAME", "REPO_NAME", "ZENODO_RECORD", "GITHUB_REPO_ID", "FULLNAME", "\\[INSERT CONTACT METHOD\\]"]
5+
exclude = [
6+
"USERNAME",
7+
"REPO_NAME",
8+
"ZENODO_RECORD",
9+
"GITHUB_REPO_ID",
10+
"FULLNAME",
11+
"\\[INSERT CONTACT METHOD\\]",
12+
"https://www.gnu.org/licenses/",
13+
"https://www.gnu.org/licenses/agpl-3.0.html",
14+
"https://www.makeareadme.com/",
15+
]
616

717
# Timeout for requests (seconds)
818
timeout = 10
@@ -23,4 +33,4 @@ cache = true
2333
max_cache_age = "7d"
2434

2535
# Accept status codes: 100-103 (informational), 200-299 (success), 429 (rate limit), 503 (unavailable) as non-blocking
26-
accept = ["100..=103", "200..=299", "429", "503"]
36+
accept = ["100..=103", "200..=299", "429", "503", "521", "522", "524"]

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: prettier-check
5+
name: Prettier check
6+
entry: npm run check
7+
language: system
8+
stages: [pre-commit]

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Place new files accordingly.
7070

7171
1. `npm install <package>`
7272
2. Commit `package.json` and `package-lock.json`
73-
3. If needed: `npm run prepare` to reinit Husky hooks
73+
3. If needed: `npm run prepare` to install Prek git hooks
7474

7575
### Python (uv)
7676

@@ -150,7 +150,7 @@ Place new files accordingly.
150150
| `lintr::lint_dir(".")` | Lint R code |
151151
| `npm run commit` | Conventional Commits wizard |
152152
| `npm run changelog` | Generate changelog from commits |
153-
| `npm run prepare` | Setup Husky git hooks |
153+
| `npm run prepare` | Setup Prek git hooks |
154154
| `uv sync` | Sync Python dependencies |
155155
| `renv::restore()` | Restore R environment |
156156
| `quarto render` | **Production render** (avoid in agent sessions) |

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in
1414
3. Ensure all code is properly formatted and linted:
1515
- Run `npm run format` to format general files with Prettier
1616
- Run `npm run check` to verify formatting
17+
- Install Prek hooks with `npm run prepare`
18+
- Run `prek run --all-files` to run all hooks locally (or `npx @j178/prek run --all-files` if Prek isn't installed globally)
1719
- Run `uv run ruff format` to format Python code
1820
- Run `uv run ruff check` to lint Python code
1921
- Run `uv run ty check` to type check Python code (if applicable)

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Conventional data publication as static supplementary files offers limited repro
5252
- Python type checking with [ty](https://github.com/astral-sh/ty)
5353
- Python dependency management with [uv](https://github.com/astral-sh/uv)
5454
- R dependency management with [renv](https://rstudio.github.io/renv/)
55-
- Commit messages following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) enforced via [husky](https://github.com/typicode/husky)
55+
- Commit messages following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) enforced via [prek](https://prek.j178.dev/)
5656
- Versioning following [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
5757
- Workflow based on [fork and pull](https://gist.github.com/Chaser324/ce0505fbed06b947d962) with [GitHub branch protection](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule)
5858
- Issue tracking via [issue templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository)
@@ -109,6 +109,27 @@ We recommend using **[GitHub Codespaces](https://github.com/features/codespaces)
109109

110110
## Getting Started
111111

112+
### Prek Git Hooks
113+
114+
This template uses [Prek](https://prek.j178.dev/) for managing Git hooks with a pre-commit-compatible configuration. To install hooks locally:
115+
116+
```bash
117+
npm install
118+
npm run prepare
119+
```
120+
121+
To run all hooks on demand:
122+
123+
```bash
124+
prek run --all-files
125+
```
126+
127+
If Prek is not installed globally, you can run:
128+
129+
```bash
130+
npx @j178/prek run --all-files
131+
```
132+
112133
### For Most Users: Reproducible Setup with GitHub Codespaces
113134

114135
1. **[Use this template](https://github.com/new?template_name=open-research-data-template&template_owner=maehr)** for your project in a new repository on your GitHub account.

0 commit comments

Comments
 (0)