Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

change the commit hook strategy #147

Merged
merged 1 commit into from
Feb 5, 2024
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
8 changes: 0 additions & 8 deletions .pre-commit-hooks.yaml

This file was deleted.

32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,23 @@ cargo install --git https://github.com/astrale-sharp/typstfmt.git

## Setting up a pre-commit hook

You can set up a git [hook](https://pre-commit.com).

Every `git commit`, will then format automatically every .typ file before
committing.

run:
Optionally, you can setup a git hook to format your files at each commit:

```sh
echo "\
repos:
- repo: https://github.com/astrale-sharp/typstfmt
rev: 1c414de
hooks:
- id: typstfmt
" > .pre-commit-config.yaml
```
echo "set -e

to add a configured `.pre-commit-config.yaml` file.
for f in \$(git ls-files --full-name -- '*.typ') ; do
typstfmt --check \$f --verbose
done" > .git/hooks/pre-commit

You should then run:

```sh
pre-commit install
pre-commit autoupdate
chmod +x .git/hooks/pre-commit
```

And your set up is done!
Now if you try to commit unformatted files, they will be caught and the commit will fail, telling you which file should be fixed.

> Notes:
> - You should probably avoid doing this at the moment, as typstfmt is not quite stable yet
> - Be careful if you have another commit hook setup, as the command above will replace it entirely!

# Contributing

Expand Down
Loading