Skip to content

shonk-software/ktfmt-pre-commit-hook

 
 

Repository files navigation

ktfmt-pre-commit-hook

A pre-commit hook to run ktfmt.

Requirements

This commit hook requires Python >=3.8.

ktfmt requires Java 11. The java in your PATH must be version >=11.

Usage Instructions

Add the following lines to your .pre-commit-config.yaml.

- repo: https://github.com/shonk-software/ktfmt-pre-commit-hook
  rev: 0.8.0
  hooks:
  - id: ktfmt
    stages: [commit]

We use it with the following options:

- repo: https://github.com/corewar-teamprojekt/ktfmt-pre-commit-hook
  rev: 0.8.0
  hooks:
  - id: ktfmt
    args: [--dry-run, --kotlinlang-style]

With --dry-run the hook doesn't automatically format the files on commit.
With --kotlinlang-style the hook uses 4-space indentation instead of 2-space indentation.

See the ktfmt documentation for supported command line arguments.

Please report any bugs in the issue tracker.

Development Instructions

Environment Setup

Run source setup.sh to setup the development environment. This may be slow the first time that this is run as the virtual environment is created and dependencies are installed.

Testing

Run:

poetry install
poetry run pytest tests

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A pre-commit hook for ktfmt.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 85.3%
  • Shell 14.7%