On Thu, Nov 2, 2023 at 8:52 PM Bruce Momjian <br...@momjian.us> wrote:
>
> Third, I have come up with the following shell script to test for proper
> pgindentation, which I run automatically before commit:
>
>         # 
> https://www.postgresql.org/message-id/CAGECzQQL-Dbb%2BYkid9Dhq-491MawHvi6hR_NGkhiDE%2B5zRZ6vQ%40mail.gmail.com
>         src/tools/pgindent/pgindent $(git diff --name-only 
> --diff-filter=ACMR) > /tmp/$$
>
>         if [ \( "$(wc -l < /tmp/$$)" -eq 1 -a "$(expr match "$(cat /tmp/$$)" 
> "No files to process\>")" -eq 0 \) -o \
>              "$(wc -l < /tmp/$$)" -gt 1 ]
>         then    echo "pgindent failure in master branch, exiting." 1>&2
>                 cat /tmp/$$
>                 exit 1
>         fi
>

Looks useful. Git supports pre-push hook:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks, a sample
script showing how to access the commits being pushed and other
arguments at 
https://github.com/git/git/blob/87c86dd14abe8db7d00b0df5661ef8cf147a72a3/templates/hooks--pre-push.sample.
I have not used it. But it seems that your script can be used to
implement the pre-push hook.

-- 
Best Wishes,
Ashutosh Bapat


Reply via email to