Skip to content

Commit

Permalink
add ez-pre-commit script
Browse files Browse the repository at this point in the history
  • Loading branch information
psyb0t committed Jun 14, 2024
1 parent 6185c3d commit 8adb095
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
41 changes: 41 additions & 0 deletions pre-commit.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8adb095

Please sign in to comment.