Skip to content

Commit d220ff6

Browse files
committed
build: 🛠 Add pre-commit and some basic configuration for this
1 parent 9f73b29 commit d220ff6

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

‎.pre-commit-config.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-toml
7+
- id: check-merge-conflict
8+
- id: end-of-file-fixer
9+
- repo: https://github.com/doublify/pre-commit-rust
10+
rev: v1.0
11+
hooks:
12+
# - id: fmt
13+
- id: cargo-check
14+
- id: clippy
15+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
16+
rev: v9.4.0
17+
hooks:
18+
- id: commitlint
19+
stages: [commit-msg]
20+
additional_dependencies:
21+
- "@team23/commitlint-config@1.0.0"
22+
23+
default_stages:
24+
- commit
25+
26+
default_install_hook_types:
27+
- pre-commit
28+
- commit-msg

‎commitlint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@team23/commitlint-config'],
3+
};

‎nurfile

+23
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ def "nur hello" [
99

1010
# Actual useful tasks
1111

12+
# Setup local environment and install deps
13+
def "nur install" [] {
14+
cargo fetch
15+
16+
init-pre-commit
17+
}
18+
19+
# Update local dev environment
20+
def "nur update" [] {
21+
cargo fetch
22+
}
23+
1224
# Run cargo
1325
def --wrapped "nur cargo" [...args: string] {
1426
cargo ...$args
@@ -100,3 +112,14 @@ def "nur upgrade-nu" [
100112
print $" -> (ansi cyan)nu-ansi-term(ansi reset): needs to be the same version as used in (ansi cyan)nu-cli(ansi reset)"
101113
print $" -> (ansi cyan)miette(ansi reset): needs to be the same version as used in (ansi cyan)nu-cmd-base(ansi reset)"
102114
}
115+
116+
# Utility commands
117+
118+
def init-pre-commit [] {
119+
if (which pre-commit | is-empty) {
120+
print -e $"(ansi red)You don't have pre-commit installed locally, pre-commit hooks cannot be initialized(ansi reset)"
121+
return null
122+
}
123+
124+
pre-commit install --install-hooks
125+
}

0 commit comments

Comments
 (0)