Skip to content

Commit

Permalink
fix: append version number automatically to commit msg
Browse files Browse the repository at this point in the history
  • Loading branch information
nahoc committed Dec 19, 2024
1 parent e17d69a commit 94c1f6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
16 changes: 0 additions & 16 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
#!/bin/bash

#!/bin/bash

# Get the prepared commit message
COMMIT_MSG_FILE=".git/COMMIT_EDITMSG"
VERSION=$(grep -o '"version": "[^"]*"' package.json | cut -d'"' -f4)

# Run pre-commit tasks
bun run pre-commit

# Prepend version to commit message if it doesn't already start with the version
if [ -f "$COMMIT_MSG_FILE" ]; then
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
if [[ ! $COMMIT_MSG =~ ^$VERSION ]]; then
echo "$VERSION - $COMMIT_MSG" > "$COMMIT_MSG_FILE"
fi
fi

git add .
13 changes: 13 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
VERSION=$(grep -o '"version": "[^"]*"' package.json | cut -d'"' -f4)

# Only add version if this is a new commit message (not amend, merge, etc)
if [ -z "$COMMIT_SOURCE" ]; then
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
if [[ ! $COMMIT_MSG =~ ^$VERSION ]]; then
echo "$VERSION - $(cat $COMMIT_MSG_FILE)" > "$COMMIT_MSG_FILE"
fi
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@risc0/ui",
"version": "0.0.256",
"version": "0.0.257",
"private": false,
"sideEffects": false,
"type": "module",
Expand Down

0 comments on commit 94c1f6f

Please sign in to comment.