Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 942 Bytes

README.md

File metadata and controls

23 lines (18 loc) · 942 Bytes

Jsonnetfmt as a pre-commit hook

jsonnetfmt is a code-formatter that comes with Jsonnet.

Pre-Commit is a library for creating and applying Git pre-commit hooks easily.

Together, you can automatically run jsonnetfmt before any commit, automatically.

Installing

  1. Get pre-commit: pip install pre-commit
  2. Create a .pre-commit.config.yaml file in the root of your repository:
---
repos:
    - repo: https://github.com/waisbrot/pre-commit-jsonnet.git
      rev: v1.0
      hooks:
          - id: jsonnetfmt
  1. Install the hooks: pre-commit install
  2. Commit code including a .jsonnet or .libsonnet file and it will run through jsonnetfmt
  3. If the file was modified, pre-commit will abort the commit so you can check the changes. (git diff will show you changes between what you staged and what jsonnetfmt did.) Stage the modifications and commit again.