From 9bd965e3cd355871d82e853953dd5290b6bc02b8 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Fri, 24 Dec 2021 21:53:54 +0200 Subject: [PATCH] Pre-commit hook. So now it can be used as a pre-commit hook, validating and nicely formatting YAML files. Hurray! --- .gitlab-ci.yml | 2 ++ .pre-commit-config.yaml | 5 +++++ .pre-commit-hooks.yaml | 8 ++++++++ MANIFEST.in | 1 + README.rst | 15 +++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ca18c5..b712a2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,8 @@ include: - project: shore/ci-stuff file: templates/pre-commit.yml + - project: shore/ci-stuff + file: templates/pre-commit-repo.yml - project: shore/ci-stuff file: templates/python.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 797bfc6..418943e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -96,3 +96,8 @@ repos: rev: '0.47' hooks: - id: check-manifest + + - repo: https://github.com/pre-commit/pre-commit.git + rev: v2.15.0 + hooks: + - id: validate_manifest diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..0baf9c8 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,8 @@ +--- +- id: yamltool + name: YAML tool + description: Validate and pretty-print YAML files. + language: python + entry: yt + args: ["--in-place"] + types: [yaml] diff --git a/MANIFEST.in b/MANIFEST.in index 3db6801..4bfa04a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include *.rst include *.txt exclude .pre-commit-config.yaml +exclude .pre-commit-hooks.yaml exclude .gitlab-ci.yml exclude .gitignore diff --git a/README.rst b/README.rst index 7520f22..540c935 100644 --- a/README.rst +++ b/README.rst @@ -39,6 +39,21 @@ Usage Please note that specifying multiple input files will concatenate them, resulting in a single file that has multiple documents. +pre-commit hook +--------------- + +YAML tool can be used as a `pre-commit <https://pre-commit.com/>` hook by +adding the following to your :code:`.pre-commit-config.yaml` file: + +.. code:: yaml + + --- + repos: + - repo: https://git.shore.co.il/nimrod/yamltool.git + rev: 0.1.0 # Check for the latest tag or run pre-commit autoupdate. + hooks: + - id: yamltool + License ------- -- GitLab