Last active
May 11, 2018 16:13
-
-
Save michaelglass/9471b9288c3e71e64384f25b8345cdba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# usage: invalidate-old-elm "src directories space delimeted" BRANCH_TO_COMPARE OPTIONAL_BRANCH_TO_COMPARE_DEFAULTS_TO_HEAD | |
# git diff --name-only gives us relative paths from git root | |
# git rev-parse --show-prefix this fetches the current directory's relative prefix to the git root | |
# we remove the prefix | |
prefix=$(git rev-parse --show-prefix) | |
for file in $(git diff --name-only $2 $3 | grep .elm$) | |
# collect changed files and select only elms | |
do | |
relative_path=$(printf $file | sed -e "s|$prefix||") | |
for src_dir in $1 | |
do | |
src_dir=$src_dir/ | |
if [[ $relative_path == $src_dir* ]]; then | |
# remove the src_dir to find in elm-stuff | |
elm=$(printf $relative_path | sed -e "s|$src_dir||") | |
elmi=$(printf $elm | tr "/" "-")i | |
find elm-stuff/build-artifacts -type f -name $elmi -exec rm {} \; | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment