dotgift/pre-commit.sh
2023-07-31 16:07:29 -07:00

9 lines
353 B
Bash

#!/bin/bash
PROJECT_ROOT=$(git rev-parse --show-toplevel)
VERSION=$(grep 'version =' $PROJECT_ROOT/pyproject.toml | head -1 | cut -d '"' -f 2)
INIT_FILE="$PROJECT_ROOT/dotgift/dotgift/__init__.py"
# Portable workaround for macOS/Linux sed differences
sed -i.bak "s/__version__ = .*/__version__ = \"$VERSION\"/" $INIT_FILE && \
rm "$INIT_FILE.bak"