mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-10 22:06:58 +08:00
add pre-commit to increase version
This commit is contained in:
parent
3f42ee5262
commit
29751d1809
3 changed files with 39 additions and 1 deletions
|
@ -51,3 +51,11 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
args: [--config=.flake8]
|
args: [--config=.flake8]
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: increase-version
|
||||||
|
name: Increase version if branch contains "develop"
|
||||||
|
entry: ./scripts/pre-commit/increase_version.sh
|
||||||
|
language: script
|
||||||
|
pass_filenames: false
|
||||||
|
stages: [commit]
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.0.0-develop10
|
4.0.0-develop11
|
||||||
|
|
30
scripts/pre-commit/increase_version.sh
Executable file
30
scripts/pre-commit/increase_version.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if the VERSION file is staged for modification
|
||||||
|
if git diff --cached --name-only | grep -q "VERSION"; then
|
||||||
|
echo "The VERSION file is already modified. Skipping version update."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read the current version from the VERSION file
|
||||||
|
current_version=$(cat VERSION)
|
||||||
|
echo "Current version: $current_version"
|
||||||
|
# Check if "develop" is not present in the version string
|
||||||
|
if [[ $current_version != *"develop"* ]]; then
|
||||||
|
echo "The word 'develop' is not present in the version string."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the version number after "develop"
|
||||||
|
version_number=$(echo "$current_version" | grep -oP '(?<=develop)\d+')
|
||||||
|
|
||||||
|
# Increment the version number
|
||||||
|
new_version_number=$((version_number + 1))
|
||||||
|
|
||||||
|
# Replace the old version number with the new one
|
||||||
|
new_version=$(echo "$current_version" | sed "s/develop$version_number/develop$new_version_number/")
|
||||||
|
|
||||||
|
# Update the VERSION file
|
||||||
|
echo "$new_version" > VERSION
|
||||||
|
|
||||||
|
echo "Version updated to: $new_version"
|
Loading…
Add table
Reference in a new issue