[go: nahoru, domu]

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