Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pre-commit hook does not echo on terminal

I am trying to run a script with pre-commit hook. Here is my script:

build_script.sh

 #! /bin/bash
 echo "Stage 1: Preparing CMake configuration"

.pre-commit-config.yaml

fail_fast: false
  - repo: local
    hooks:
    -   id: Generate build 
        name: Generate build 
        entry: sh build_script.sh
        language: system
        always_run: true
        pass_filenames: false

I can see when I run command git commit -m "message", the hook calls the script and Generate build will Pass. However, I do not see the echo on the terminal. I would like to see the message, "Stage 1: Preparing CMake configuration". What is wrong with this setup?

like image 801
SNR_BT Avatar asked Jun 15 '26 10:06

SNR_BT


1 Answers

pre-commit takes a bit from unix philosophy here -- it is silent unless there is a problem (by default).

if your script fails then the output will be displayed

you can also use --verbose to show the full output (for debugging) and optionally set verbose: true on your hook itself. note: these are both debugging options and are not intended for use outside that -- we've found that when hooks are noisy contributors tend to ignore all of the output


disclaimer: I wrote pre-commit

like image 144
Anthony Sottile Avatar answered Jun 17 '26 01:06

Anthony Sottile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!