Skip to content

Instantly share code, notes, and snippets.

@jwineinger
Created February 27, 2025 20:31
Show Gist options
  • Save jwineinger/8d70cbc5cc746b3a115e0e338ad58192 to your computer and use it in GitHub Desktop.
Save jwineinger/8d70cbc5cc746b3a115e0e338ad58192 to your computer and use it in GitHub Desktop.
Bash set variable to "yes"/"no" if changes in last commit included any files matching "tests/"
VAR=$([ "$(git diff --name-status HEAD HEAD^ | grep tests/ | wc -l | xargs)" -ge "1" ] && echo "yes" || echo "no")
@jwineinger
Copy link
Author

or

VAR=$(git diff --name-status HEAD HEAD^ | grep tests/ >/dev/null && echo "yes" || echo "no")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment