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

Commit

Permalink
change the commit hook strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgolfouse committed Jan 29, 2024
1 parent 7dddcf3 commit 2f77821
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
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

0 comments on commit 2f77821

Please sign in to comment.