From a29345a8033ad1b79a1316d37dc9c34f46c05eae Mon Sep 17 00:00:00 2001 From: cophilot Date: Wed, 7 Aug 2024 23:23:09 +0200 Subject: [PATCH 1/5] test --- .githooks/prepare-commit-msg | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg index d676a75..d16b054 100755 --- a/.githooks/prepare-commit-msg +++ b/.githooks/prepare-commit-msg @@ -20,8 +20,17 @@ 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] " +else + issue_id="" +fi -echo "$(cat $COMMIT_MSG_FILE)" +echo "$issue_idv$VERSION - $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE -echo "prepare-commit-msg hook finished" \ No newline at end of file +echo "prepare-commit-msg hook finished" +exit 1 \ No newline at end of file From d210c1729d4ca0ac5f7f8efbc16c8a835698d773 Mon Sep 17 00:00:00 2001 From: cophilot Date: Wed, 7 Aug 2024 23:24:46 +0200 Subject: [PATCH 2/5] fixed --- .githooks/pre-commit | 2 +- .githooks/prepare-commit-msg | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 35b79b3..533aba4 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -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 \ No newline at end of file +fi diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg index d16b054..e946997 100755 --- a/.githooks/prepare-commit-msg +++ b/.githooks/prepare-commit-msg @@ -32,5 +32,5 @@ fi echo "$issue_idv$VERSION - $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE -echo "prepare-commit-msg hook finished" -exit 1 \ No newline at end of file +echo $(cat $COMMIT_MSG_FILE) +echo "prepare-commit-msg hook finished" \ No newline at end of file From 500385a1985aeeb76721bb4e48f483c19262682b Mon Sep 17 00:00:00 2001 From: cophilot Date: Wed, 7 Aug 2024 23:27:15 +0200 Subject: [PATCH 3/5] 1.0.0 - fixed git hook --- .githooks/prepare-commit-msg | 8 +------- test | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) create mode 100644 test diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg index e946997..8c8e1ee 100755 --- a/.githooks/prepare-commit-msg +++ b/.githooks/prepare-commit-msg @@ -9,11 +9,6 @@ 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) @@ -25,12 +20,11 @@ issue_id=$(echo $BRANCH_NAME | cut -d'-' -f1) if [ ! -z "$issue_id" ]; then echo "Found Issue ID: $issue_id" - issue_id="[$issue_id] " + issue_id="[#$issue_id] " else issue_id="" fi echo "$issue_idv$VERSION - $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE -echo $(cat $COMMIT_MSG_FILE) echo "prepare-commit-msg hook finished" \ No newline at end of file diff --git a/test b/test new file mode 100644 index 0000000..562095e --- /dev/null +++ b/test @@ -0,0 +1 @@ +1.0.0 - From 81e5e493c9eac3b1478ae7534d6633efc30b9959 Mon Sep 17 00:00:00 2001 From: cophilot Date: Wed, 7 Aug 2024 23:28:54 +0200 Subject: [PATCH 4/5] [#8] 1.0.0 - fixed git hook --- .githooks/prepare-commit-msg | 8 +++++--- test | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg index 8c8e1ee..7abad70 100755 --- a/.githooks/prepare-commit-msg +++ b/.githooks/prepare-commit-msg @@ -20,11 +20,13 @@ issue_id=$(echo $BRANCH_NAME | cut -d'-' -f1) if [ ! -z "$issue_id" ]; then echo "Found Issue ID: $issue_id" - issue_id="[#$issue_id] " + issue_id="[#$issue_id] $VERSION -" else - issue_id="" + issue_id="$VERSION -" fi -echo "$issue_idv$VERSION - $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE +echo "$issue_id $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE + +echo "Updated commit message: $(cat $COMMIT_MSG_FILE)" echo "prepare-commit-msg hook finished" \ No newline at end of file diff --git a/test b/test index 562095e..b4a6a5f 100644 --- a/test +++ b/test @@ -1 +1 @@ -1.0.0 - +[#8] 1.0.0 - [#8] 1.0.0 - [#8] 1.0.0 - 1.0.0 - 1.0.0 - From c7ee13745a8c358bead3264c2d1a517587b9134d Mon Sep 17 00:00:00 2001 From: cophilot Date: Wed, 7 Aug 2024 23:31:28 +0200 Subject: [PATCH 5/5] [#8] 1.0.0 - fixed pipeline --- .github/workflows/check_rust_quality.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_rust_quality.yml b/.github/workflows/check_rust_quality.yml index c51d0f0..f5168aa 100644 --- a/.github/workflows/check_rust_quality.yml +++ b/.github/workflows/check_rust_quality.yml @@ -2,8 +2,7 @@ name: Run rust quality checks on: push: - branches: - - dev + branches: ['*'] workflow_call: inputs: branch: @@ -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 }}