From: Tristan Partin <tristan@neon.tech>
To: Jelte Fennema-Nio <postgres@jeltef.nl>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Euler Taveira <euler@eulerto.com>
Cc: Michael Banck <mbanck@gmx.net>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Add --check option to pgindent
Date: Tue, 19 Dec 2023 10:54:36 -0600
Message-ID: <CXSGUFLDISHS.3LK6EM9GMPP7L@neon.tech> (raw)
In-Reply-To: <CAGECzQTvyx1EZyRYhCmWV=uREg7H6h0+uCSpPEkkrsP95_AW9Q@mail.gmail.com>
References: <202312121530.7vztxm3bfyrx@alvherre.pgsql>
<4b390361-484d-7598-ac13-db2dd7072ad3@dunslane.net>
<CXO7OZEZ53RE.1Q4SXU4WJ25RN@neon.tech>
<CAGECzQRAyCkzM=g9Sv149kXqfL_q4t7WdZ4wb_OizmUYhVrRyg@mail.gmail.com>
<CXP0TUOU4C1N.Z7Q508WQ4XJP@neon.tech>
<46DAFBD4-0387-4F8B-96A2-A39499600C32@yesql.se>
<CAGECzQS0zOsf3+NTxZPpBaBm7vivJwfZ=n=Qq0x62mRhFq52vQ@mail.gmail.com>
<CXRM4KD9NXIC.V372H4MRTMDT@neon.tech>
<CXRRU5Z7R9XN.3JZTO6G7PTKSU@neon.tech>
<CAGECzQTvyx1EZyRYhCmWV=uREg7H6h0+uCSpPEkkrsP95_AW9Q@mail.gmail.com>
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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tristan@neon.tech, postgres@jeltef.nl, daniel@yesql.se, andrew@dunslane.net, alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us, euler@eulerto.com, mbanck@gmx.net
Subject: Re: Add --check option to pgindent
In-Reply-To: <CXSGUFLDISHS.3LK6EM9GMPP7L@neon.tech>
References: <202312121530.7vztxm3bfyrx@alvherre.pgsql> <4b390361-484d-7598-ac13-db2dd7072ad3@dunslane.net> <CXO7OZEZ53RE.1Q4SXU4WJ25RN@neon.tech> <CAGECzQRAyCkzM=g9Sv149kXqfL_q4t7WdZ4wb_OizmUYhVrRyg@mail.gmail.com> <CXP0TUOU4C1N.Z7Q508WQ4XJP@neon.tech> <46DAFBD4-0387-4F8B-96A2-A39499600C32@yesql.se> <CAGECzQS0zOsf3+NTxZPpBaBm7vivJwfZ=n=Qq0x62mRhFq52vQ@mail.gmail.com> <CXRM4KD9NXIC.V372H4MRTMDT@neon.tech> <CXRRU5Z7R9XN.3JZTO6G7PTKSU@neon.tech> <CAGECzQTvyx1EZyRYhCmWV=uREg7H6h0+uCSpPEkkrsP95_AW9Q@mail.gmail.com> <CXSGUFLDISHS.3LK6EM9GMPP7L@neon.tech>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox