From 715e73d3e16eac4e9063bab814878e35c7b6aee1 Mon Sep 17 00:00:00 2001 From: sidmohanty11 Date: Tue, 25 Jan 2022 09:57:09 +0530 Subject: [PATCH 1/2] feat: adding pre commit hooks --- .pre-commit-config.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..0305c59e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: + - repo: https://github.com/jorisroovers/gitlint + rev: v0.17.0 + hooks: + - id: gitlint + args: [--ignore, body-is-missing, --contrib=CT1, --msg-filename] + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.5.1 + hooks: + - id: prettier + stages: [commit] From b86585c279e3e87c374da64757a87d817d089f24 Mon Sep 17 00:00:00 2001 From: sidmohanty11 Date: Tue, 25 Jan 2022 11:38:35 +0530 Subject: [PATCH 2/2] feat: make file to enable git hooks --- .gitconfig | 1 + .githooks/commit-msg | 20 ++++++++++++++++++++ .githooks/pre-commit | 20 ++++++++++++++++++++ Makefile | 5 +++++ 4 files changed, 46 insertions(+) create mode 100644 .gitconfig create mode 100755 .githooks/commit-msg create mode 100755 .githooks/pre-commit create mode 100644 Makefile diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 00000000..1f430eea --- /dev/null +++ b/.gitconfig @@ -0,0 +1 @@ +git config -f .gitconfig core.hooksPath .githooks \ No newline at end of file diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100755 index 00000000..e5695cbc --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# File generated by pre-commit: https://pre-commit.com +# ID: 138fd403232d2ddd5efb44317e38bf03 + +# start templated +INSTALL_PYTHON=/home/linuxbrew/.linuxbrew/opt/pre-commit/libexec/bin/python3 +ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=commit-msg) +# end templated + +HERE="$(cd "$(dirname "$0")" && pwd)" +ARGS+=(--hook-dir "$HERE" -- "$@") + +if [ -x "$INSTALL_PYTHON" ]; then + exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}" +elif command -v pre-commit > /dev/null; then + exec pre-commit "${ARGS[@]}" +else + echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2 + exit 1 +fi diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..1fb71bef --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# File generated by pre-commit: https://pre-commit.com +# ID: 138fd403232d2ddd5efb44317e38bf03 + +# start templated +INSTALL_PYTHON=/home/linuxbrew/.linuxbrew/opt/pre-commit/libexec/bin/python3 +ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit) +# end templated + +HERE="$(cd "$(dirname "$0")" && pwd)" +ARGS+=(--hook-dir "$HERE" -- "$@") + +if [ -x "$INSTALL_PYTHON" ]; then + exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}" +elif command -v pre-commit > /dev/null; then + exec pre-commit "${ARGS[@]}" +else + echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2 + exit 1 +fi diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..126803b1 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +enable-git-hooks: + git config core.hooksPath .githooks + chmod +x .githooks/pre-commit + chmod +x .githooks/commit-msg + $(warning REMEMBER, YOU MUST HAVE REVIEWED THE CUSTOM HOOKS!) \ No newline at end of file