Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output suppressed until pre-commit scripts fully ran #1333

Open
fragolinux opened this issue Jan 8, 2025 · 0 comments
Open

output suppressed until pre-commit scripts fully ran #1333

fragolinux opened this issue Jan 8, 2025 · 0 comments

Comments

@fragolinux
Copy link

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

  1. .git/hooks/pre-commit #. works and produces its own output
  2. git commit -m "something" #. works and produces its own output
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant