https://pantsbuild.org/ logo
#general
Title
# general
w

witty-crayon-22786

03/26/2021, 12:20 AM
question for the room: how are you integrating Pants (formatters and linters) with your git-hooks, if any?
1
1
the pantsbuild repo runs approximately `./pants --changed-since=HEAD typecheck lint`… downside of course is that if it fails you need to run
./pants fmt
manually. but interested in whether folks have different strategies!
b

busy-vase-39202

03/26/2021, 2:01 AM
l

loud-stone-83419

03/26/2021, 1:15 PM
Copy code
#!/usr/bin/env bash

# NB: pre-commit runs in the context of GIT_WORK_TREE, ie: pwd == REPO_ROOT

changed=("$(./pants --changed-fast --changed-parent=HEAD list)")

./pants fmt ${changed}
c

clean-city-64472

03/26/2021, 1:47 PM
I have this pre-commit hook locally
Copy code
/bin/bash
./pants lint --changed-since=HEAD || exit 1
I added these aliases to my bashrc
Copy code
alias fmt='./pants --changed-since=master fmt'
alias lint='./pants --changed-since=master lint'
w

witty-crayon-22786

03/26/2021, 6:53 PM
interesting! so @loud-stone-83419: you folks just auto-format in the hook
if people are expecting it, that’s about as easy as it gets
i’ve always been scared that folks would lose work. but if they’re expecting it / have editor buffers
l

loud-stone-83419

03/26/2021, 6:54 PM
Hum the formating never prvents you from commiting
w

witty-crayon-22786

03/26/2021, 6:54 PM
yea, exactly.
l

loud-stone-83419

03/26/2021, 6:54 PM
I would say for us we would add the lint in the CI
(we did not set it up yet)