Skip to content

Commit

Permalink
πŸ“ docs: Remove wrong docs link for this hook, add Usage section
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Jan 18, 2025
1 parent 1207d81 commit a32b631
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# typos-pre-commit-mirror

Support `pre-commit <= 3.2.0`.<br>
Mirror of the `typos` pre-commit hook for `pre-commit`. Supports `pre-commit` versions 2.9.2 and later.

For example `pre-commit` configs, please see the [pre-commit.md](https://github.com/crate-ci/typos/blob/master/docs/pre-commit.md)
## Usage

Add this to your `.pre-commit-config.yaml`:

```yaml
- repo: https://github.com/PFCCLab/typos-pre-commit-mirror.git
rev: v1.29.4
hooks:
- id: typos
args: [--force-exclude]
```
9 changes: 9 additions & 0 deletions mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def main():
# Load pyproject.toml
with open(Path(__file__).parent / "pyproject.toml", "rb") as f:
pyproject = tomli.load(f)
# Load README.md
with open(Path(__file__).parent / "README.md", "r") as f:
readme = f.read()

# θŽ·ε–ε½“ε‰η‰ˆζœ¬ηš„ typos
deps = pyproject["project"]["dependencies"]
Expand All @@ -48,8 +51,14 @@ def main():
# Update pyproject.toml
pyproject["project"]["version"] = str(version)
pyproject["project"]["dependencies"] = [f"typos=={version}"]
# Update README.md
readme = readme.replace(str(current_version), str(version))

# Write pyproject.toml and README.md
with open(Path(__file__).parent / "pyproject.toml", "wb") as f:
tomli_w.dump(pyproject, f)
with open(Path(__file__).parent / "README.md", "w") as f:
f.write(readme)

# Commit and tag
subprocess.run(["git", "add", "pyproject.toml"])
Expand Down

0 comments on commit a32b631

Please sign in to comment.