Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pJFML-0000Z7-NQ for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Jan 2023 15:00:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pJFMJ-0006nh-S7 for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Jan 2023 15:00:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pJFMJ-0006nX-IR for pgsql-hackers@lists.postgresql.org; Sat, 21 Jan 2023 15:00:43 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pJFME-0001YS-Uk for pgsql-hackers@lists.postgresql.org; Sat, 21 Jan 2023 15:00:42 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id CAF4260003 for ; Sat, 21 Jan 2023 15:00:32 +0000 (UTC) Message-ID: <17455b0f-0161-9aa9-b6dd-1279e947b8f4@dunslane.net> Date: Sat, 21 Jan 2023 10:00:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: run pgindent on a regular basis / scripted manner Content-Language: en-US From: Andrew Dunstan To: pgsql-hackers@lists.postgresql.org References: <20200814202651.GA31108@alvherre.pgsql> <531251.1674234545@sss.pgh.pa.us> <20230120175806.iogdcra2xpmmh5de@awork3.anarazel.de> <538672.1674238787@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-01-21 Sa 08:26, Andrew Dunstan wrote: > On 2023-01-20 Fr 13:19, Tom Lane wrote: >> Andres Freund writes: >>> On 2023-01-20 12:09:05 -0500, Tom Lane wrote: >>>> The core problem here is that requiring that would translate to >>>> requiring every code contributor to have a working copy of pg_bsd_indent. >>> Wouldn't just every committer suffice? >> Not if we have cfbot complaining about it. >> >> (Another problem here is that there's a sizable subset of committers >> who clearly just don't care, and I'm not sure we can convince them to.) > > I think we could do better with some automation tooling for committers > here. One low-risk and simple change would be to provide a > non-destructive mode for pgindent that would show you the changes if any > it would make. That could be worked into a git pre-commit hook that > committers could deploy. I can testify to the usefulness of such hooks - > I have one that while not perfect has saved me on at least two occasions > from forgetting to bump the catalog version. > > I'll take a look at fleshing this out, for my own if no-one else's use. > > Here's a quick patch for this. I have it in mind to use like this in a pre-commit hook: # only do this on master test `git rev-parse --abbrev-ref HEAD` = "master" || exit 0 src/tools/pgindent/pg_indent --silent `git diff --cached --name-only` || \   { echo "Need a pgindent run" >&2 ; exit 1; } The committer could then run src/tools/pgindent/pg_indent --show-diff `git diff --cached --name-only` to see what changes it thinks are needed. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com