From 5c3867431651b90a85655fc213f21333c683ca31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:10:59 -0300 Subject: [PATCH 1/9] PAYH-10: adding husky --- .gitignore | 3 ++- .husky/commit-msg | 23 +++++++++++++++++++++++ .husky/pre-commit | 1 + package-lock.json | 28 ++++++++++++++++++++++++++++ package.json | 8 ++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 57872d0..ff87634 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/vendor/ +vendor/ +node_modules/ \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..af05b8c --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +KN='\033[0m' +BBlue='\033[1;34m' +Bred='\033[1;31m' + +REGEX_ISSUE_ID="[a-zA-Z0-9,\.\_\-]+-[0-9]+" + +BRANCH_NAME=$(git symbolic-ref --short HEAD) +ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID") +COMMIT_MESSAGE=$(cat "$1") + +if [ -z "$ISSUE_ID" ]; then + echo -e "{$Bred}Branch não está no padrão de deveria mestre... ${NC}" + exit 1 +fi + +if [[ $COMMIT_MESSAGE == $ISSUE_ID ]]; then + exit 0 +fi + +echo "$ISSUE_ID: $COMMIT_MESSAGE" > $1 \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..3ae6b77 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +php composer test \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..68000ca --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "payhub", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "husky": "^9.1.7" + } + }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6b87ff3 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "husky": "^9.1.7" + }, + "scripts": { + "prepare": "husky" + } +} From 2e99c2a7fa943b4a7d1b3299616f5688f9432a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:12:30 -0300 Subject: [PATCH 2/9] PAYH-10: adding husky --- .husky/commit-msg | 4 ++-- .husky/pre-commit | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 .husky/pre-commit diff --git a/.husky/commit-msg b/.husky/commit-msg index af05b8c..0655259 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -16,8 +16,8 @@ if [ -z "$ISSUE_ID" ]; then exit 1 fi -if [[ $COMMIT_MESSAGE == $ISSUE_ID ]]; then - exit 0 +if [ "$COMMIT_MESSAGE" = "$ISSUE_ID" ]; then + exit 0 fi echo "$ISSUE_ID: $COMMIT_MESSAGE" > $1 \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 3ae6b77..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -php composer test \ No newline at end of file From c49190249bcc58536f4dbbefb3a44f829e3fd0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:12:57 -0300 Subject: [PATCH 3/9] PAYH-10: adding husky --- .husky/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 0655259..ecbaed8 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -16,7 +16,7 @@ if [ -z "$ISSUE_ID" ]; then exit 1 fi -if [ "$COMMIT_MESSAGE" = "$ISSUE_ID" ]; then +if [ $COMMIT_MESSAGE = $ISSUE_ID ]; then exit 0 fi From e82b0adcc0ebde88b6276b6ba1956e89c5b7f441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:13:30 -0300 Subject: [PATCH 4/9] PAYH-10: adding husky --- .husky/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index ecbaed8..2275057 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -16,7 +16,7 @@ if [ -z "$ISSUE_ID" ]; then exit 1 fi -if [ $COMMIT_MESSAGE = $ISSUE_ID ]; then +if [[ $COMMIT_MESSAGE == $ISSUE_ID ]]; then exit 0 fi From ac40f71e2aa292e1f13bb27447764dcdc2746c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:13:47 -0300 Subject: [PATCH 5/9] PAYH-10: adding husky --- .husky/commit-msg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 2275057..9937e48 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -16,8 +16,8 @@ if [ -z "$ISSUE_ID" ]; then exit 1 fi -if [[ $COMMIT_MESSAGE == $ISSUE_ID ]]; then - exit 0 +if [ $COMMIT_MESSAGE == $ISSUE_ID ]; then + exit 0 fi echo "$ISSUE_ID: $COMMIT_MESSAGE" > $1 \ No newline at end of file From 7f28cc622695fca5ba005b79c3bf9dcacd82c2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:14:14 -0300 Subject: [PATCH 6/9] PAYH-10: adding husky --- .husky/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 9937e48..22bbb9b 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -16,7 +16,7 @@ if [ -z "$ISSUE_ID" ]; then exit 1 fi -if [ $COMMIT_MESSAGE == $ISSUE_ID ]; then +if [[ "$COMMIT_MESSAGE" == "$ISSUE_ID" ]]; then exit 0 fi From 2b6648610106a6a0c76fed863f9602e606ccf2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:14:22 -0300 Subject: [PATCH 7/9] PAYH-10: adding husky --- .husky/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 22bbb9b..af05b8c 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -16,7 +16,7 @@ if [ -z "$ISSUE_ID" ]; then exit 1 fi -if [[ "$COMMIT_MESSAGE" == "$ISSUE_ID" ]]; then +if [[ $COMMIT_MESSAGE == $ISSUE_ID ]]; then exit 0 fi From a3bc6153cfb4734816c6402601df99362b5c683a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:15:23 -0300 Subject: [PATCH 8/9] PAYH-10: adding husky --- .husky/commit-msg | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index af05b8c..d8449ee 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,23 +1,22 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" +#!/bin/bash KN='\033[0m' BBlue='\033[1;34m' -Bred='\033[1;31m' +BRed='\033[1;31m' -REGEX_ISSUE_ID="[a-zA-Z0-9,\.\_\-]+-[0-9]+" +REGEX_ISSUE_ID="[a-zA-Z0-9,._-]+-[0-9]+" BRANCH_NAME=$(git symbolic-ref --short HEAD) ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID") COMMIT_MESSAGE=$(cat "$1") if [ -z "$ISSUE_ID" ]; then - echo -e "{$Bred}Branch não está no padrão de deveria mestre... ${NC}" - exit 1 + echo -e "${BRed}Branch name does not follow the expected pattern...${KN}" + exit 1 fi -if [[ $COMMIT_MESSAGE == $ISSUE_ID ]]; then - exit 0 +if [[ "$COMMIT_MESSAGE" == "$ISSUE_ID"* ]]; then + exit 0 fi -echo "$ISSUE_ID: $COMMIT_MESSAGE" > $1 \ No newline at end of file +echo "$ISSUE_ID: $COMMIT_MESSAGE" > "$1" From fa3b6f1173963d1ae8e9ed88a21916bee0379b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Fri, 29 Nov 2024 23:17:00 -0300 Subject: [PATCH 9/9] PAYH-10: adding husky --- .husky/commit-msg | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index d8449ee..4b69191 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env sh KN='\033[0m' BBlue='\033[1;34m' @@ -11,12 +11,14 @@ ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID") COMMIT_MESSAGE=$(cat "$1") if [ -z "$ISSUE_ID" ]; then - echo -e "${BRed}Branch name does not follow the expected pattern...${KN}" + echo "${BRed}Branch name does not follow the expected pattern...${KN}" exit 1 fi -if [[ "$COMMIT_MESSAGE" == "$ISSUE_ID"* ]]; then - exit 0 -fi +case "$COMMIT_MESSAGE" in + "$ISSUE_ID"*) + exit 0 + ;; +esac echo "$ISSUE_ID: $COMMIT_MESSAGE" > "$1"