627b9ca3b7
If the Ignore-AOSP-First tag is in a commit message, it means the committer is intentionally bypassing the AOSP source of truth. Check for this tag in the AOSP-first presubmit hook so that devs don't have to turn off hooks to get past the AOSP-first policy in exceptional cases. Bug: 189139990 Change-Id: I18231b93d7f213c13ace0a0af24bb20a394cc50f Test: Manual testing with various commit messages
28 lines
902 B
Bash
Executable File
28 lines
902 B
Bash
Executable File
#!/bin/bash
|
|
LOCAL_DIR="$( dirname "${BASH_SOURCE}" )"
|
|
|
|
if git branch -vv | grep -q -P "^\*[^\[]+\[aosp/"; then
|
|
# Change appears to be in AOSP
|
|
exit 0
|
|
elif git log -n 1 --format='%B' $1 | grep -q -E "^Ignore-AOSP-First: .+" ; then
|
|
# Change is explicitly marked as ok to skip AOSP
|
|
exit 0
|
|
else
|
|
# Change appears to be non-AOSP; search for files
|
|
count=0
|
|
while read -r file ; do
|
|
if (( count == 0 )); then
|
|
echo
|
|
fi
|
|
echo -e "\033[0;31;47mThe source of truth for '$file' is in AOSP.\033[0m"
|
|
(( count++ ))
|
|
done < <(git show --name-only --pretty=format: $1 | grep -- "$2")
|
|
if (( count != 0 )); then
|
|
echo
|
|
echo "If your change contains no confidential details (such as security fixes), please"
|
|
echo "upload and merge this change at https://android-review.googlesource.com/."
|
|
echo
|
|
exit 1
|
|
fi
|
|
fi
|