blob: 9405140e69c70a3c38170040bdc327b24b70a222 [file] [log] [blame]
Jeff Gastonca0bc712021-01-14 19:32:39 -05001set -e
2
3if [ ! -e .git ]; then
4 echo "This script must be run from the root of the git repository"
5 exit 1
6fi
7
8function usage() {
9 echo "Usage: split_change_into_owners.sh <commit message>"
10 echo
11 echo "Splits changes in the current repository based on OWNERS files"
12 exit 1
13}
14
15commitMessage="$1"
16if [ "$commitMessage" == "" ]; then
17 usage
18fi
19
20ownersFiles="$(find -name OWNERS)"
21ownedDirs="$(echo "$ownersFiles" | sed 's|/OWNERS||' | sort -r)"
22
23for d in $ownedDirs; do
24 git add "$d"
25 if git status | grep -i "changes to be committed" >/dev/null; then
26 echo making commit for "$d"
27 git commit -m "$commitMessage
28
29This change includes files under $d"
30 fi
31done