I’m trying to run a git hook in a monorepo, where our React client is in a subfolder. I only want the hook to run when files in that subfolder have changed. This means that I need to somehow conditionally run only if the commits since I last pushed have had files change in that particular subfolder. e.g.
-- project
-- files
-- subfolder
-- files I care about
and some git command like git show
and outputs any files that have been changed in any commit since I last pushed. It also needs to not be branch specific, but know which branch I’m on and compare to unpushed commits on the same branch.
I’ve started out trying to do something like
if git show --name-only -r --stat --oneline HEAD^^..HEAD | grep -q 'ReactClient/'; then
npm run verify
fi
but that only shows changed files from the last two commits