Re: Add --check option to pgindent

Tristan Partin <tristan@neon.tech>

From: "Tristan Partin" <tristan@neon.tech>
To: "Jelte Fennema-Nio" <postgres@jeltef.nl>
Cc: "Daniel Gustafsson" <daniel@yesql.se>, "Andrew Dunstan" <andrew@dunslane.net>, "Alvaro Herrera" <alvherre@alvh.no-ip.org>, "Tom Lane" <tgl@sss.pgh.pa.us>, "Euler Taveira" <euler@eulerto.com>, "Michael Banck" <mbanck@gmx.net>, "PostgreSQL Hackers" <pgsql-hackers@postgresql.org>
Date: 2023-12-19T16:54:36Z
Lists: pgsql-hackers
On Tue Dec 19, 2023 at 10:36 AM CST, Jelte Fennema-Nio wrote:
> On Mon, 18 Dec 2023 at 22:18, Tristan Partin <tristan@neon.tech> wrote:
> > Here is an additional patch which implements the behavior you described.
> > The first patch is just Daniel's squashed version of my patches.
>
> I think we'd still want the early exit behaviour when only --check is
> provided. No need to spend time checking more files if you're not
> doing anything else.

Good point. Patch looks good.

> On Mon, 18 Dec 2023 at 22:34, Tristan Partin <tristan@neon.tech> wrote:
> > To me, the two options seem at odds, like you either check or write. How
> > would you feel about just capturing the diffs that are printed and
> > patch(1)-ing them?
>
> I tried capturing the diffs and patching them, but simply piping the
> pgindent output to patch(1) didn't work because the pipe loses the
> exit code of pgindent. -o pipefail would help with this, but it's not
> available in all shells. Also then it's suddenly unclear if pgident
> failed or if patch failed.

I was envisioning something along the lines of:

	pgindent --check --diff > patches.txt
	status=$?
	patch <patches.txt # no idea if this works, or if you need a for loop with manual parsing
	exit $status

-- 
Tristan Partin
Neon (https://neon.tech)



Commits

  1. Rename pgindent options