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: Mon, 18 Dec 2023 15:34:05 -0600
Message-ID: <CXRS5VNNIFMO.137GVG1RORYH2@neon.tech> (raw)
In-Reply-To: <CAGECzQQnJbu=pfWYOeBrAMOF4is6tpRZm-feoWfQ8YtAJ-FsoQ@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>
<CAGECzQQnJbu=pfWYOeBrAMOF4is6tpRZm-feoWfQ8YtAJ-FsoQ@mail.gmail.com>
On Mon Dec 18, 2023 at 11:21 AM CST, Jelte Fennema-Nio wrote:
> On Mon, 18 Dec 2023 at 17:50, Tristan Partin <tristan@neon.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
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?
--
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: <CXRS5VNNIFMO.137GVG1RORYH2@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> <CAGECzQQnJbu=pfWYOeBrAMOF4is6tpRZm-feoWfQ8YtAJ-FsoQ@mail.gmail.com> <CXRS5VNNIFMO.137GVG1RORYH2@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