Re: Add --check option to pgindent

Поиск
Список
Период
Сортировка
От Tristan Partin
Тема Re: Add --check option to pgindent
Дата
Msg-id CXRS5VNNIFMO.137GVG1RORYH2@neon.tech
обсуждение исходный текст
Ответ на Re: Add --check option to pgindent  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Список pgsql-hackers
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)



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Tristan Partin"
Дата:
Сообщение: Re: Add --check option to pgindent
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: add non-option reordering to in-tree getopt_long