question for the room: how are you integrating Pan...
# general
w
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
l
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
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
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
Hum the formating never prvents you from commiting
w
yea, exactly.
l
I would say for us we would add the lint in the CI
(we did not set it up yet)