Re: Add --check option to pgindent

2023-12-21 Thread Jelte Fennema-Nio
On Tue, 19 Dec 2023 at 17:54, Tristan Partin wrote: > I was envisioning something along the lines of: > > pgindent --check --diff > patches.txt > status=$? > patch with manual parsing > exit $status Okay, I got a working version. And I updated the pre-commit hook

Re: Add --check option to pgindent

2023-12-20 Thread Andrew Dunstan
On 2023-12-20 We 11:05, Andrew Dunstan wrote: On 2023-12-19 Tu 08:57, Daniel Gustafsson wrote:   The posted v5 seems like a good compromise I reckon. Andrew: When applying this, how do we synchronize with the buildfarm to avoid false negatives due to the BF using the wrong options? The

Re: Add --check option to pgindent

2023-12-20 Thread Andrew Dunstan
On 2023-12-19 Tu 08:57, Daniel Gustafsson wrote: On 19 Dec 2023, at 14:51, Andrew Dunstan wrote: On 2023-12-18 Mo 11:14, Jelte Fennema-Nio wrote: On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: I think this is pretty much ready to go, the attached v4 squashes the changes and fixes

Re: Add --check option to pgindent

2023-12-19 Thread Tristan Partin
On Tue Dec 19, 2023 at 10:36 AM CST, Jelte Fennema-Nio wrote: On Mon, 18 Dec 2023 at 22:18, Tristan Partin 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

Re: Add --check option to pgindent

2023-12-19 Thread Jelte Fennema-Nio
On Mon, 18 Dec 2023 at 22:18, Tristan Partin 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

Re: Add --check option to pgindent

2023-12-19 Thread Tristan Partin
On Mon Dec 18, 2023 at 3:18 PM CST, Tristan Partin wrote: On Mon Dec 18, 2023 at 10:50 AM CST, Tristan Partin wrote: > On Mon Dec 18, 2023 at 10:14 AM CST, Jelte Fennema-Nio wrote: > > On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: > > > I think this is pretty much ready to go, the

Re: Add --check option to pgindent

2023-12-19 Thread Daniel Gustafsson
> On 19 Dec 2023, at 14:51, Andrew Dunstan wrote: > > On 2023-12-18 Mo 11:14, Jelte Fennema-Nio wrote: >> On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: >>> I think this is pretty much ready to go, the attached v4 squashes the >>> changes >>> and fixes the man-page which also needed an

Re: Add --check option to pgindent

2023-12-19 Thread Andrew Dunstan
On 2023-12-18 Mo 11:14, Jelte Fennema-Nio wrote: On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: I think this is pretty much ready to go, the attached v4 squashes the changes and fixes the man-page which also needed an update. The referenced Wiki page will need an edit or two after

Re: Add --check option to pgindent

2023-12-18 Thread Tristan Partin
On Mon Dec 18, 2023 at 11:21 AM CST, Jelte Fennema-Nio wrote: On Mon, 18 Dec 2023 at 17:50, Tristan Partin 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

Re: Add --check option to pgindent

2023-12-18 Thread Tristan Partin
On Mon Dec 18, 2023 at 10:50 AM CST, Tristan Partin wrote: On Mon Dec 18, 2023 at 10:14 AM CST, Jelte Fennema-Nio wrote: > On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: > > I think this is pretty much ready to go, the attached v4 squashes the changes > > and fixes the man-page which

Re: Add --check option to pgindent

2023-12-18 Thread Jelte Fennema-Nio
On Mon, 18 Dec 2023 at 17:50, Tristan Partin 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

Re: Add --check option to pgindent

2023-12-18 Thread Tristan Partin
On Mon Dec 18, 2023 at 10:14 AM CST, Jelte Fennema-Nio wrote: On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: > I think this is pretty much ready to go, the attached v4 squashes the changes > and fixes the man-page which also needed an update. The referenced Wiki page > will need an

Re: Add --check option to pgindent

2023-12-18 Thread Jelte Fennema-Nio
On Mon, 18 Dec 2023 at 17:14, Jelte Fennema-Nio wrote: > One thing I'm wondering: When both --check and --diff are passed, > should pgindent still early exit with 2 on the first incorrectly > formatted file? Or should it show diffs for all failing files? I'm > leaning towards the latter making

Re: Add --check option to pgindent

2023-12-18 Thread Jelte Fennema-Nio
On Mon, 18 Dec 2023 at 13:42, Daniel Gustafsson wrote: > I think this is pretty much ready to go, the attached v4 squashes the changes > and fixes the man-page which also needed an update. The referenced Wiki page > will need an edit or two after this goes in, but that's easy enough. One thing

Re: Add --check option to pgindent

2023-12-18 Thread Matthias van de Meent
On Mon, 18 Dec 2023 at 16:45, Tristan Partin wrote: > > On Mon Dec 18, 2023 at 6:41 AM CST, Daniel Gustafsson wrote: > > > On 15 Dec 2023, at 16:43, Tristan Partin wrote: > > > > > Here is a v3. > > > > I think this is pretty much ready to go, the attached v4 squashes the > > changes > > and

Re: Add --check option to pgindent

2023-12-18 Thread Tristan Partin
On Mon Dec 18, 2023 at 7:56 AM CST, Euler Taveira wrote: On Mon, Dec 18, 2023, at 9:41 AM, Daniel Gustafsson wrote: > > On 15 Dec 2023, at 16:43, Tristan Partin wrote: > > > Here is a v3. > > I think this is pretty much ready to go, the attached v4 squashes the changes > and fixes the

Re: Add --check option to pgindent

2023-12-18 Thread Tristan Partin
On Mon Dec 18, 2023 at 6:41 AM CST, Daniel Gustafsson wrote: > On 15 Dec 2023, at 16:43, Tristan Partin wrote: > Here is a v3. I think this is pretty much ready to go, the attached v4 squashes the changes and fixes the man-page which also needed an update. The referenced Wiki page will need

Re: Add --check option to pgindent

2023-12-18 Thread Euler Taveira
On Mon, Dec 18, 2023, at 9:41 AM, Daniel Gustafsson wrote: > > On 15 Dec 2023, at 16:43, Tristan Partin wrote: > > > Here is a v3. > > I think this is pretty much ready to go, the attached v4 squashes the changes > and fixes the man-page which also needed an update. The referenced Wiki page >

Re: Add --check option to pgindent

2023-12-18 Thread Daniel Gustafsson
> On 15 Dec 2023, at 16:43, Tristan Partin wrote: > Here is a v3. I think this is pretty much ready to go, the attached v4 squashes the changes and fixes the man-page which also needed an update. The referenced Wiki page will need an edit or two after this goes in, but that's easy enough. --

Re: Add --check option to pgindent

2023-12-15 Thread Tristan Partin
On Fri Dec 15, 2023 at 8:18 AM CST, Jelte Fennema-Nio wrote: This part of the first patch seems incorrect, i.e. same condition in the if as elsif - if ($silent_diff) + if ($check) + { + print show_diff($source, $source_filename); + exit 2; + } +

Re: Add --check option to pgindent

2023-12-15 Thread Jelte Fennema-Nio
This part of the first patch seems incorrect, i.e. same condition in the if as elsif - if ($silent_diff) + if ($check) + { + print show_diff($source, $source_filename); + exit 2; + } + elsif ($check) { exit 2; } On

Re: Add --check option to pgindent

2023-12-14 Thread Tristan Partin
On Wed Dec 13, 2023 at 2:46 PM CST, Andrew Dunstan wrote: On 2023-12-12 Tu 10:30, Alvaro Herrera wrote: > On 2023-Dec-12, Tom Lane wrote: > >> "Euler Taveira" writes: >>> When you add exceptions, it starts to complicate the UI. >> Indeed. It seems like --silent-diff was poorly defined and

Re: Add --check option to pgindent

2023-12-13 Thread Andrew Dunstan
On 2023-12-12 Tu 10:30, Alvaro Herrera wrote: On 2023-Dec-12, Tom Lane wrote: "Euler Taveira" writes: When you add exceptions, it starts to complicate the UI. Indeed. It seems like --silent-diff was poorly defined and poorly named, and we need to rethink that option along the way to

Re: Add --check option to pgindent

2023-12-12 Thread Alvaro Herrera
On 2023-Dec-12, Tom Lane wrote: > "Euler Taveira" writes: > > When you add exceptions, it starts to complicate the UI. > > Indeed. It seems like --silent-diff was poorly defined and poorly > named, and we need to rethink that option along the way to adding > this behavior. The idea that

Re: Add --check option to pgindent

2023-12-12 Thread Tristan Partin
On Tue Dec 12, 2023 at 5:47 AM CST, Euler Taveira wrote: On Tue, Dec 12, 2023, at 7:28 AM, Michael Banck wrote: > On Tue, Dec 12, 2023 at 11:18:59AM +0100, Daniel Gustafsson wrote: > > > On 12 Dec 2023, at 01:09, Tristan Partin wrote: > > > > > > Not sold on the name, but --check is a

Re: Add --check option to pgindent

2023-12-12 Thread Tom Lane
"Euler Taveira" writes: > When you add exceptions, it starts to complicate the UI. Indeed. It seems like --silent-diff was poorly defined and poorly named, and we need to rethink that option along the way to adding this behavior. The idea that --show-diff and --silent-diff can be used together

Re: Add --check option to pgindent

2023-12-12 Thread Euler Taveira
On Tue, Dec 12, 2023, at 7:28 AM, Michael Banck wrote: > On Tue, Dec 12, 2023 at 11:18:59AM +0100, Daniel Gustafsson wrote: > > > On 12 Dec 2023, at 01:09, Tristan Partin wrote: > > > > > > Not sold on the name, but --check is a combination of --silent-diff > > > and --show-diff. I envision

Re: Add --check option to pgindent

2023-12-12 Thread Michael Banck
Hi, On Tue, Dec 12, 2023 at 11:18:59AM +0100, Daniel Gustafsson wrote: > > On 12 Dec 2023, at 01:09, Tristan Partin 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

Re: Add --check option to pgindent

2023-12-12 Thread Daniel Gustafsson
> On 12 Dec 2023, at 01:09, Tristan Partin 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

Re: Add --check option to pgindent

2023-12-11 Thread Daniel Gustafsson
> On 12 Dec 2023, at 01:09, Tristan Partin 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

Add --check option to pgindent

2023-12-11 Thread Tristan Partin
and exit 2 if the output isn't empty by yourself. -- Tristan Partin Neon (https://neon.tech) From 1001252d49a47e660045cee3d2ba5abd87e925d9 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Mon, 11 Dec 2023 17:34:17 -0600 Subject: [PATCH v1] Add --check option to pgindent The option is a combination