Re: Add --check option to pgindent

From: Michael Banck <mbanck(at)gmx(dot)net>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Tristan Partin <tristan(at)neon(dot)tech>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add --check option to pgindent
Date: 2023-12-12 10:28:10
Message-ID: 657835bb.500a0220.a88d.2058@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Dec 12, 2023 at 11:18:59AM +0100, Daniel Gustafsson wrote:
> > On 12 Dec 2023, at 01:09, Tristan Partin <tristan(at)neon(dot)tech> wrote:
> >
> > Not sold on the name, but --check is a combination of --silent-diff
> > and --show-diff. I envision --check mostly being used in CI
> > environments. I recently came across a situation where this behavior
> > would have been useful. Without --check, you're left to capture the
> > output of --show-diff and exit 2 if the output isn't empty by
> > yourself.
>
> I wonder if we should model this around the semantics of git diff to
> keep it similar to other CI jobs which often use git diff? git diff
> --check means "are there conflicts or issues" which isn't really
> comparable to here, git diff --exit-code however is pretty much
> exactly what this is trying to accomplish.
>
> That would make pgindent --show-diff --exit-code exit with 1 if there
> were diffs and 0 if there are no diffs.

To be honest, I find that rather convoluted; contrary to "git diff", I
believe the primary action of pgident is not to show diffs, so I find
the proposed --check option to be entirely reasonable from a UX
perspective.

On the other hand, tying a "does this need re-indenting?" question to a
"--show-diff --exit-code" option combination is not very obvious (to me,
at least).

Cheers,

Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2023-12-12 10:40:15 [meson] expose buildtype debug/optimization info to pg_config
Previous Message Daniel Gustafsson 2023-12-12 10:18:59 Re: Add --check option to pgindent