Repository navigation
output suppressed until pre-commit scripts fully ran #1333
Description
Description
Hi, I've configured cz to run some custom pre-commit scripts, and these scripts work as expected if directly called via .git/hooks/pre-commit or via "git commit -m ..."
if i use instead cz, after its questions and my answers, it produces its "purple" commit message, then the SAME hooks scripts start running but i can't see any output until the script as fully completed its run...
as some tasks in these scripts are very long to run, i'd like to have some output given to the user on what's going on in the background...
thanks in advance
Steps to reproduce
- .git/hooks/pre-commit #. works and produces its own output
- git commit -m "something" #. works and produces its own output
- cz c (and following Q&A) # waits for script completion before producing output
Current behavior
this fully works if called manually or via git commit, producing the desired output, while does not until fully completed in case of using "cz c"
#!/usr/bin/env bash
source "${HOME}/.aliases.sh"
function main() {
if [ -n "${REMOTE_CONTAINERS}" ]; then
printf "${COLOR_GREEN}%s${COLOR_NONE}\n" "Updating Helm dependencies... Please be patient..."
if ! updateCharts
then
printf '\n%s\n' "${COLOR_RED}----------------------------${COLOR_NONE}"
printf '%s\n' "${COLOR_RED}!!! Cannot update charts !!!${COLOR_NONE}"
printf '%s\n' "${COLOR_RED}----------------------------${COLOR_NONE}"
exit 1
else
git add "${WORKSPACE}/infrastructure/helm/Chart.lock"
git add "${WORKSPACE}/infrastructure/helm/charts"
fi
if ! testTemplates
then
exit 1
fi
fi
}
function testTemplates() {
result=true
for f in "${WORKSPACE}/infrastructure/helm/values/"*
do
if [ ! -d "${f}" ];
then
filename=$(basename -- "${f}")
env="${filename%.*}"
if ! template -n "precommit" "${env}"
then
result=false
printf '\n%s\n' "${COLOR_RED}----------------------------------------------${COLOR_NONE}"
printf '%s\n' "${COLOR_RED}!!! Templating of ${env} environment failed !!!${COLOR_NONE}"
printf '%s\n' "${COLOR_RED}----------------------------------------------${COLOR_NONE}"
fi
fi
done
rm -rf "${WORKSPACE}/template/"*"precommit"*
$result
}
main
Desired behavior
having my output on console while scripts run, so users are aware of what's going on
Screenshots
No response
Environment
Commitizen Version: 4.1.0
Python Version: 3.13.1 (main, Jan 7 2025, 11:12:45) [GCC 12.2.0]
Operating System: Linux
Activity
bearomorphism commentedon May 9, 2026
The buffering is intentional.
commitizen/cmd.pyinvokessubprocess.Popen(..., stdout=PIPE, stderr=PIPE)and waits viacommunicate()so it can:git commitand raiseCommitError(c.err)with a clean message instead of letting raw output leak through, andstderrinto commitizen's own retry / error-rendering paths.If the captured streams were forwarded live, the error parsing would race with the subprocess and the exit-code-aware retry / hook plumbing in
commitizen/commands/commit.pywould break.The downside the issue describes (output appearing only after pre-commit hooks finish) is the cost of that design. It's a feature, not a bug — surfaced via the round-2 triage in #1965; proposing close as by-design. If anyone wants live tee-ing for long-running hooks, that's a separate feature request and would have to opt-in.