diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg index bc76a56..fd05574 100644 --- a/scripts/githooks/commit-msg +++ b/scripts/githooks/commit-msg @@ -53,10 +53,11 @@ GITLINT_DIR="./_output/tools/go-gitlint" if ! command -v $GITLINT_DIR &>/dev/null; then echo "$GITLINT_DIR not found. Attempting to install it..." - # Add the commands to download and install the go-gitlint tool here + wget https://github.com/llorllale/go-gitlint/releases/latest/download/go-gitlint_${GOOS}_${GOARCH}.tar.gz -O go-gitlint.tar.gz || curl -L https://github.com/llorllale/go-gitlint/releases/latest/download/go-gitlint_${GOOS}_${GOARCH}.tar.gz -o go-gitlint.tar.gz + tar xzf go-gitlint.tar.gz -C ./_output/tools/ && chmod +x $GITLINT_DIR if [ $? -ne 0 ]; then - printError "Failed to install $GITLINT_DIR. Please run 'make tools' OR 'make tools.verify.go-gitlint' make verto install it manually." - exit 1 + printError "Installation of $GITLINT_DIR failed. Please check your network connection, ensure you have the necessary permissions, and run 'make tools' OR 'make tools.verify.go-gitlint' to install it manually." + exit 2 fi fi @@ -77,5 +78,5 @@ then fi printError "Please fix your commit message to match kubecub coding standards" printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" - exit 1 + exit 2 fi \ No newline at end of file diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 7660e5d..ea28b39 100644 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -67,6 +67,11 @@ cd $repo_root empty_tree=$( git hash-object -t tree /dev/null ) +if ! command -v $GITLINT_DIR &>/dev/null; then + printError "The go-gitlint tool is not installed. Please run 'make tools' OR 'make tools.verify.go-gitlint' to install it." + exit 1 +fi + if git rev-parse --verify HEAD > /dev/null 2>&1 then against=HEAD @@ -94,6 +99,13 @@ then exit 1; fi +if [ $? -ne 0 ] +then + printError "The commit-msg hook failed. Please check the error logs for more information." + exit 2 +fi +fi + if [[ ! $local_branch =~ $valid_branch_regex ]] then printError "There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex.