blob: 36bea57b710fda44a0cfcac9c2c3d55aaf6ef4ff [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
Vince Harronb3a17c72021-11-12 18:28:01 -08004if git branch -vv | grep -q -E "^\*[^\[]+\[aosp/"; then
Jeff Sharkey0a9c7312018-08-23 22:01:53 -06005 # Change appears to be in AOSP
6 exit 0
Seth Moore627b9ca2021-05-24 13:43:35 -07007elif 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
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060010else
Christopher Ferris9fbe8a82021-05-18 13:49:08 -070011 # 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.
Jeff Sharkey5b471992018-09-11 10:36:57 -060026 count=0
27 while read -r file ; do
28 if (( count == 0 )); then
29 echo
30 fi
Alan Stokes293096a2020-07-28 18:19:20 +010031 echo -e "\033[0;31;47mThe source of truth for '$file' is in AOSP.\033[0m"
Jeff Sharkey5b471992018-09-11 10:36:57 -060032 (( count++ ))
33 done < <(git show --name-only --pretty=format: $1 | grep -- "$2")
34 if (( count != 0 )); then
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060035 echo
Jeff Sharkey5b471992018-09-11 10:36:57 -060036 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/."
Martin Stjernholmf1ca1272021-08-31 16:49:11 +010038 echo "Else add a tag 'Ignore-AOSP-First:' with the reason to bypass AOSP."
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060039 echo
Jeff Sharkeyaaaf1b72018-12-03 10:56:56 -070040 exit 1
Jeff Sharkey5b471992018-09-11 10:36:57 -060041 fi
Jeff Sharkey0a9c7312018-08-23 22:01:53 -060042fi