How can I trigger vsc hooks like husky? #1464
Unanswered
harrytran998
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Are they being created in |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yeah, I already see the git hook file in #!/usr/bin/env bash
set -eo pipefail
./.moon/hooks/commit-msg.sh $1 $2 $3 Here is the content in script #!/bin/bash
# regex to validate in commit-msg
techmelyTicketReg='^(TML-[A-Z0-9]{2,4}|merge|hotfix|release)'
errorMsg="Aborting commit. Your commit message must start with JIRA code (eg: 'TML-1111') or 'merge|hotfix|release'"
if ! grep -iqE "$techmelyTicketReg" "$1"; then
echo "$errorMsg" >&2
exit 1
fi
#!/bin/bash
textBase='\033[0m'
textInformation='\033[1;34m'
textSuccess='\033[1;32m'
branchName=$(git rev-parse --abbrev-ref HEAD)
techmelyTicketReg='^(TML-[A-Z0-9]{2,4}|merge|hotfix|release)'
gitCommitMsg=$(head -n 1 "$1") # $1 is path = .git/COMMIT_EDITMSG
if [[ $gitCommitMsg =~ $techmelyTicketReg ]];then
echo "$textInformation Already exist prefix branch-name, ignore appending prefix."
echo "$textBase"
else
echo "$textInformation Starting append prefix branch-name..."
if [[ -n "$branchName" ]] && [[ $branchName =~ $techmelyTicketReg ]]; then
# Append prefix branch name into the commit message
sed -i.bak -e "1s~^~$branchName ~" "$1"
echo "$textSuccess Append prefix branch-name successfully."
echo "$textBase"
fi
fi |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I read the docs, seems like I just need to configure like bellow --> git hooks can work, but did not! So do you have any suggestions or guides to make this work like husky(https://github.com/typicode/husky)
Beta Was this translation helpful? Give feedback.
All reactions