util: do not run host command check unless needed

With the recent addition of the presubmit check progress display it
became obvious that hook2 from ./PRESUBMIT.cfg takes quite a bit of
time on each check.

A closer examination has shown that this script scans the entire
codebase on each patch to see if there have been some inconsistencies
wrt EC host command definitions.

Let's limit running this check only to patches which actually touch EC
host commands in any way.

BRANCH=none
BUG=none
TEST=verified that the check runs only when the 'EC_.*CMD' string is
     present in the diffs output of the patch

Change-Id: I128dba48332142b8835cf36747ab290190e6bcef
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/815951
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Sam Hurst <shurst@google.com>
This commit is contained in:
Vadim Bendebury 2017-12-07 18:28:20 -08:00 committed by chrome-bot
parent 7c96395355
commit 94774ad9df
1 changed files with 7 additions and 0 deletions

View File

@ -80,6 +80,13 @@ should_check() {
}
main() {
# Do not run the check unless an EC_[xxx]CMD change is present.
if [[ -z "$(git diff "${PRESUBMIT_COMMIT}~" "${PRESUBMIT_COMMIT}" -U0 |
egrep 'EC_[^ ]*CMD')" ]]; then
exit 0
fi
ec_errors=()
ei=0
# Search all file occurrences of "EC_CMD" and store in array