wide-midnight-78598
02/13/2024, 2:18 PMpre-commit default githook and instructions at https://www.pantsbuild.org/2.18/docs/contributions/development/setting-up-pants#step-3-optional-set-up-a-git-hook with a pre-push instead?
From conversations in the past, we have a bit of a divisive history with the pre-commit hook (whether we should even have one or let CI take the hit). I'm on team githook all day, but I personally think pre-commit hooks are archaic and teams should use pre-push hooks instead (why does anyone need to care that I didn't format my repo for the 30 local commits, before my 1 big push?)wide-midnight-78598
02/13/2024, 2:20 PMpre-commit makes for a bad dev experience, whereas I think pre-push is a sensible middleground.
There are people who push often, I suppose, and we list the githook as optional (which I also disagree with), but at the very least, I think we should rename the pre-commitgorgeous-winter-99296
02/13/2024, 2:33 PMgorgeous-winter-99296
02/13/2024, 2:34 PMwide-midnight-78598
02/13/2024, 2:37 PMMy argument against hooks is that they break a lot of editor tooling, scripts, etcThat sounds like poorly designed scripts ๐ For instance, when I have a monorepo with them - they check where the source tree was altered, only run relevant code, check if tools are installed, etc... Annnnd, very limited use of tooling - more like "you have to have this, if you're gonna be changing this code" So, in one of my recent monorepos, you only need pants installed if you're updating backend code, but frontend code just uses
pnpm (which, if you're changing anything in the frontend code and don't have pnpm, then that's terrifying)wide-midnight-78598
02/13/2024, 2:38 PMfor directory in "${FRONTEND_DIRS[@]}"; do
if has_unpushed_changes_in "${directory}"; then
run_pnpm_checks_in "${directory}"
fi
done
for directory in "${BACKEND_DIRS[@]}"; do
if has_unpushed_changes_in "${directory}"; then
run_pants_checks_in "${directory}"
fi
done
for directory in "${UTIL_DIRS[@]}"; do
if has_unpushed_changes_in "${directory}"; then
run_pants_checks_in "${directory}"
fi
done
or whatevergorgeous-winter-99296
02/13/2024, 2:42 PMgorgeous-winter-99296
02/13/2024, 2:46 PMflat-zoo-31952
02/13/2024, 2:48 PMcost value to each check and then users have a gitignored settings file they can use to set pre-commit and pre-push cost thresholdsflat-zoo-31952
02/13/2024, 2:49 PMwide-midnight-78598
02/13/2024, 2:49 PMwide-midnight-78598
02/13/2024, 2:50 PMflat-zoo-31952
02/13/2024, 2:50 PMgorgeous-winter-99296
02/13/2024, 2:50 PM[cli.alias].run-precommit = "--changed-since=upstream/main test lint whatever" and the hook just runs that.gorgeous-winter-99296
02/13/2024, 2:51 PMflat-zoo-31952
02/13/2024, 2:52 PMwide-midnight-78598
02/13/2024, 2:56 PMflat-zoo-31952
02/13/2024, 2:57 PMhappy-kitchen-89482
02/13/2024, 6:28 PMwide-midnight-78598
02/13/2024, 6:30 PMonly if it's fast and stable on development platformsThis is largely a function of pants though.
pants --changed-since=origin/main fix fmt lint test or whatever... \proud-dentist-22844
02/13/2024, 7:08 PMpre-commit hook on the pants repo. I let CI take the hit.
I cannot run pants when Iโm developing in Termux on my phone. So, the pre-commit hook is pointless there.
On my laptops, Iโd be more likely to enable a pre-push hook than a pre-commit hook, as I need commit to be snappy. Iโll put the fix/fmt in a separate commit so that I donโt lose my train of thought working on whatever code Iโm focusing on.curved-manchester-66006
02/13/2024, 8:02 PM