Skip to content

Commit

Permalink
Merge pull request #9 from cophilot/8-add-issue-id-to-commit
Browse files Browse the repository at this point in the history
8 add issue id to commit
  • Loading branch information
cophilot authored Aug 7, 2024
2 parents 7388dfe + c7ee137 commit 35544db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ branch=$(git branch --show-current)
if [ "$branch" = "main" ] || [ "$branch" = "master" ]; then
echo "🚨🚨 You can not commit to the master branch. Please switch to the dev branch."
exit 1
fi
fi
19 changes: 12 additions & 7 deletions .githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ echo "Running prepare-commit-msg hook"
# get the current branch name
BRANCH_NAME=$(git branch --show-current)

# return if not in dev branch
if [ "$BRANCH_NAME" != "dev" ]; then
exit 0
fi

# read the content of the README.md file
PHIL_PROJECT_FILE=$(cat .phil-project)

# get the version of the project
VERSION=$(echo $PHIL_PROJECT_FILE | grep -oP 'version:\K[0-9]+\.[0-9]+\.[0-9]+')

echo "v$VERSION - $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE
# get the branch name and split it by '-' and get the first element
issue_id=$(echo $BRANCH_NAME | cut -d'-' -f1)

if [ ! -z "$issue_id" ]; then
echo "Found Issue ID: $issue_id"
issue_id="[#$issue_id] $VERSION -"
else
issue_id="$VERSION -"
fi

echo "$issue_id $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE

echo "$(cat $COMMIT_MSG_FILE)"
echo "Updated commit message: $(cat $COMMIT_MSG_FILE)"

echo "prepare-commit-msg hook finished"
5 changes: 2 additions & 3 deletions .github/workflows/check_rust_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Run rust quality checks

on:
push:
branches:
- dev
branches: ['*']
workflow_call:
inputs:
branch:
Expand Down Expand Up @@ -35,7 +34,7 @@ jobs:
run: ./scripts/test

- name: Merge to master branch
if: ${{ inputs.branch != 'master' }}
if: ${{ inputs.branch == 'dev' }}
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[#8] 1.0.0 - [#8] 1.0.0 - [#8] 1.0.0 - 1.0.0 - 1.0.0 -

0 comments on commit 35544db

Please sign in to comment.