1#!/bin/bash
2LOCAL_DIR="$( dirname "${BASH_SOURCE}" )"
3
4if git branch -vv | grep -q -P "^\*[^\[]+\[aosp/"; then
5    # Change appears to be in AOSP
6    exit 0
7else
8    # Change appears to be non-AOSP; search for files
9    count=0
10    while read -r file ; do
11        if (( count == 0 )); then
12            echo
13        fi
14        echo -e "\033[0;31mThe source of truth for '$file' is in AOSP.\033[0m"
15        (( count++ ))
16    done < <(git show --name-only --pretty=format: $1 | grep -- "$2")
17    if (( count != 0 )); then
18        echo
19        echo "If your change contains no confidential details (such as security fixes), please"
20        echo "upload and merge this change at https://android-review.googlesource.com/."
21        echo
22        exit 1
23    fi
24fi
25