Re: Add --check option to pgindent - Mailing list pgsql-hackers

From Tristan Partin
Subject Re: Add --check option to pgindent
Date
Msg-id CXSGUFLDISHS.3LK6EM9GMPP7L@neon.tech
Whole thread Raw
In response to Re: Add --check option to pgindent  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Responses Re: Add --check option to pgindent
List 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)



pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
Next
From: Jacob Burroughs
Date:
Subject: Re: libpq compression (part 3)