Created
August 1, 2022 09:20
-
-
Save ppabcd/b8a47eb5727df67b5b7cc7a974d6e4cc to your computer and use it in GitHub Desktop.
Prepare commit without PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
COMMIT_MESSAGE_FILE=$1 | |
VERSION_FILE="${PWD}/.version" | |
TEXT_VERSION="v0.1.0" | |
if [ -f "$VERSION_FILE" ]; then | |
# Read file | |
VERSION=$(cat "$VERSION_FILE") | |
# delete v from text | |
VERSION=${VERSION#v} | |
TEXT_VERSION="v$VERSION" | |
echo "${TEXT_VERSION}" >"$VERSION_FILE" | |
echo "Version: $TEXT_VERSION" | |
else | |
echo "Version file does not exist. Generate v0.1.0" | |
echo "v0.1.0" >"$VERSION_FILE" | |
fi | |
VERSION_MESSAGE="[${TEXT_VERSION}]" | |
sed -i.old "1s/^/$VERSION_MESSAGE \n /" "$COMMIT_MESSAGE_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment