| 1 | #!/bin/bash |
| 2 | LOCAL_DIR="$( dirname "${BASH_SOURCE}" )" |
| 3 | |
| 4 | if git log -n 1 --format='%D' HEAD@{upstream} | grep -q aosp/; then |
| 5 | # Change appears to be in AOSP |
| 6 | exit 0 |
| 7 | elif git log -n 1 --format='%B' $1 | grep -q -E "^Ignore-AOSP-First: .+" ; then |
| 8 | # Change is explicitly marked as ok to skip AOSP |
| 9 | exit 0 |
| 10 | else |
| 11 | # Change appears to be non-AOSP. |
| 12 | |
| 13 | # If this is a cherry-pick, then allow it. |
| 14 | cherrypick=0 |
| 15 | while read -r line ; do |
| 16 | if [[ $line =~ cherry\ picked\ from ]] ; then |
| 17 | (( cherrypick++ )) |
| 18 | fi |
| 19 | done < <(git show $1) |
| 20 | if (( cherrypick != 0 )); then |
| 21 | # This is a cherry-pick, so allow it. |
| 22 | exit 0 |
| 23 | fi |
| 24 | |
| 25 | # See if any files are affected. |
| 26 | count=0 |
| 27 | while read -r file ; do |
| 28 | if (( count == 0 )); then |
| 29 | echo |
| 30 | fi |
| 31 | echo -e "\033[0;31;47mThe source of truth for '$file' is in AOSP.\033[0m" |
| 32 | (( count++ )) |
| 33 | done < <(git show --name-only --pretty=format: $1 | grep -- "$2") |
| 34 | if (( count != 0 )); then |
| 35 | echo |
| 36 | echo "If your change contains no confidential details (such as security fixes), please" |
| 37 | echo "upload and merge this change at https://android-review.googlesource.com/." |
| 38 | echo "Else add a tag 'Ignore-AOSP-First:' with the reason to bypass AOSP." |
| 39 | echo |
| 40 | exit 1 |
| 41 | fi |
| 42 | fi |