blob: 514f17a042bc13df59db2d173b7e19c56736d0a6 [file] [log] [blame]
Jeff Sharkey0a9c7312018-08-23 22:01:53 -06001#!/bin/bash
Jeff Sharkey5b471992018-09-11 10:36:57 -06002LOCAL_DIR="$( dirname "${BASH_SOURCE}" )"
Jeff Sharkey0a9c7312018-08-23 22:01:53 -06003
Jeff Sharkey5b471992018-09-11 10:36:57 -06004if git branch -vv | grep -q -P "^\*[^\[]+\[aosp/"; then
Jeff Sharkey0a9c7312018-08-23 22:01:53 -06005 # Change appears to be in AOSP
6 exit 0
7else
Christopher Ferris9fbe8a82021-05-18 13:49:08 -07008 # Change appears to be non-AOSP.
9
10 # If this is a cherry-pick, then allow it.
11 cherrypick=0
12 while read -r line ; do
13 if [[ $line =~ cherry\ picked\ from ]] ; then
14 (( cherrypick++ ))
15 fi
16 done < <(git show $1)
17 if (( cherrypick != 0 )); then
18 # This is a cherry-pick, so allow it.
19 exit 0
20 fi
21
22 # See if any files are affected.
Jeff Sharkey5b471992018-09-11 10:36:57 -060023 count=0
24 while read -r file ; do
25 if (( count == 0 )); then
26 echo
27 fi
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060028 echo -e "\033[0;31mThe source of truth for '$file' is in AOSP.\033[0m"
Jeff Sharkey5b471992018-09-11 10:36:57 -060029 (( count++ ))
30 done < <(git show --name-only --pretty=format: $1 | grep -- "$2")
31 if (( count != 0 )); then
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060032 echo
Jeff Sharkey5b471992018-09-11 10:36:57 -060033 echo "If your change contains no confidential details (such as security fixes), please"
34 echo "upload and merge this change at https://android-review.googlesource.com/."
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060035 echo
Jeff Sharkeyaaaf1b72018-12-03 10:56:56 -070036 exit 1
Jeff Sharkey5b471992018-09-11 10:36:57 -060037 fi
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060038fi