Skip to content

Instantly share code, notes, and snippets.

@martint
Last active November 18, 2021 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martint/c5786df73b718b746f5eeb94e35af5e5 to your computer and use it in GitHub Desktop.
Save martint/c5786df73b718b746f5eeb94e35af5e5 to your computer and use it in GitHub Desktop.
#!/bin/sh
find_in_ancestor() {
dir="$2"
while [ -n "$dir" ] && [ ! -f "$dir/$1" ]; do
dir=${dir%/*}
done
if [ -f "$dir/$1" ]; then
printf '%s\n' "$dir"
fi
}
BRANCH=${1:-master}
MODULES=$(git diff --merge-base "$BRANCH" --name-only | \
while read -r file
do
find_in_ancestor pom.xml "$file"
done | \
sort -u | \
tr '\n' ',')
echo -am -pl "$MODULES"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment