From 763bb2f844e1bff4b25c1f237b10da62cc85048e Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sat, 27 May 2023 16:26:58 -0500 Subject: [PATCH] chore: add back version setter as post-commit hook --- .pre-commit-config.yaml | 19 ++++++++++++------- scripts/bump-dev.sh | 7 ++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87f1065..0ca1eaa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,9 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks +default_install_hook_types: + - pre-commit + - post-commit + repos: - repo: https://github.com/psf/black rev: 23.3.0 @@ -11,10 +15,11 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix, --show-fixes] - # - repo: local - # hooks: - # - id: set-version - # language: script - # name: sets __version__ in viv.py - # entry: ./scripts/bump-dev.sh - # files: viv.py$ + - repo: local + hooks: + - id: set-version + language: script + name: sets __version__ in viv.py + entry: ./scripts/bump-dev.sh + stages: [post-commit] + always_run: true diff --git a/scripts/bump-dev.sh b/scripts/bump-dev.sh index 84ac30c..27273bf 100755 --- a/scripts/bump-dev.sh +++ b/scripts/bump-dev.sh @@ -1,5 +1,6 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash TAG=$(git describe --tags --always --dirty=-dev) VERSION="${TAG#v}" -sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/g" src/viv/viv.py -git add src/viv/viv.py +if [[ "$(git diff --name-only HEAD HEAD~1)" == *"./src/viv/viv.py"* ]]; then + sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/g" src/viv/viv.py +fi