Reputation: 2961
To speed up running tests during CI, I need to know for a given directory if anything in or below that directory was changed in the last commit, so I can skip the tests for that directory.
Does such a command exist? I am not looking for the specific files that changed, just for a command that exits 1 if anything was changed, and 0 otherwise.
Upvotes: 1
Views: 93
Reputation: 13377
Since you mention CI, I assume you are writing a script. Then you should use the "plumbing" (low-level) commands. This would do:
if git diff-tree --quiet --exit-code HEAD^:"$subdir" HEAD:"$subdir"
then
# no change
else
# there was a change
fi
Upvotes: 2