From 8adb0952a7283ceda4afe375aa1fb58b70e6cc61 Mon Sep 17 00:00:00 2001 From: Ciprian Mandache Date: Fri, 14 Jun 2024 03:29:54 +0300 Subject: [PATCH] add ez-pre-commit script --- README.md | 8 ++++++++ pre-commit.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 pre-commit.sh diff --git a/README.md b/README.md index 6434273..7b8953d 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,11 @@ We love contributions like hackers love caffeine. Found a bug? Have a brilliant ## License **ezpyai** is unleashed under the WTFPL (Do What The Fuck You Want To Public License). Copy it, change it, or repurpose it to start your own digital riot. + +## Development notes + +This project uses [ez-pre-commit](https://github.com/psyb0t/ez-pre-commit) so you need to install `ez-pre-commit` on your device and then run + +```bash +ez-pre-commit install +``` diff --git a/pre-commit.sh b/pre-commit.sh new file mode 100755 index 0000000..db0165b --- /dev/null +++ b/pre-commit.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Log the start of the script +echo "Running pre-commit script..." + +# Determine the latest git tag +latest_tag=$(git describe --tags --abbrev=0) +if [ -z "$latest_tag" ]; then + echo "No tags found." + exit 0 +fi + +echo "Latest git tag is: $latest_tag" + +# Log checking the pyproject.toml +echo "Checking for version mismatch in pyproject.toml..." + +# Define the location of pyproject.toml +PYPROJECT_TOML="./pyproject.toml" + +# Check if the pyproject.toml exists +if [ ! -f "$PYPROJECT_TOML" ]; then + echo "[ez-pre-commit] Missing pyproject.toml file. Cannot check version." + exit 1 +fi + +# Extract the version from pyproject.toml +pyproject_version=$(awk -F' = ' '/^version = / {gsub(/"/, "", $2); print $2}' $PYPROJECT_TOML) + +# Log the version found +echo "Version in pyproject.toml is: $pyproject_version" + +# Compare versions +if [ "$latest_tag" != "$pyproject_version" ]; then + echo "[ez-pre-commit] Version mismatch! Tag: $latest_tag does not match pyproject.toml: $pyproject_version" + exit 1 +else + echo "Versions match. All good!" +fi + +exit 0