Re: Add --check option to pgindent

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: Tristan Partin <tristan(at)neon(dot)tech>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Euler Taveira <euler(at)eulerto(dot)com>, Michael Banck <mbanck(at)gmx(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add --check option to pgindent
Date: 2023-12-18 17:21:59
Message-ID: CAGECzQQnJbu=pfWYOeBrAMOF4is6tpRZm-feoWfQ8YtAJ-FsoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 18 Dec 2023 at 17:50, Tristan Partin <tristan(at)neon(dot)tech> wrote:
> I could propose something. It would help if I had an example of such
> a tool that already exists.

Basically the same behaviour as what you're trying to add now for
--check, only instead of printing the diff it would actually change
the files just like running pgindent without a --check flag does. i.e.
allow pgindent --check to not run in "dry-run" mode
My pre-commit hook looks like this currently (removed boring cruft around it):

if ! src/tools/pgindent/pgindent --check $files > /dev/null; then
exit 0
fi
echo "Running pgindent on changed files"
src/tools/pgindent/pgindent $files
echo "Commit abandoned. Rerun git commit to adopt pgindent changes"
exit 1

But I would like it to look like:

if src/tools/pgindent/pgindent --check --write $files > /dev/null; then
exit 0
fi
echo "Commit abandoned. Rerun git commit to adopt pgindent changes"
exit 1

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-12-18 17:30:11 Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock
Previous Message Robert Haas 2023-12-18 17:04:07 Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock