From 2da331a5e6cd149f819599091c7eeec3b5c65145 Mon Sep 17 00:00:00 2001 From: almostinf <87192879+almostinf@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:00:20 +0300 Subject: [PATCH] feature: add pre-commit hooks (#894) --- .githooks/pre-commit | 9 +++++++++ .github/CONTRIBUTING.md | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 000000000..5f8e49100 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,9 @@ +#!/bin/bash + +# Check if any of the specified files are staged for commit +if git diff --name-only --cached | grep -E 'api/'; then + echo "Format swaggo annotations (swag fmt)" + swag fmt +fi + +make lint \ No newline at end of file diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2aaf2d16f..1a467cc5e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -138,8 +138,8 @@ For full local deployment of all services, including web, graphite and metrics r docker-compose up ``` -Before pushing your changes don't forget about linter: +Before pushing, don't forget to write this command please, it will activate the pre-commit hook on the linter and auto formatting swagger documentation: ```bash -make lint +git config --local core.hooksPath .githooks/ ```