util,python: Fix Pre-commit hooks to ignore non-source files
authorBobby R. Bruce <bbruce@ucdavis.edu>
Thu, 28 Jan 2021 05:44:31 +0000 (21:44 -0800)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Tue, 2 Feb 2021 21:39:09 +0000 (21:39 +0000)
commit86222736e60b4e2783dcf6c7c0e0963066ec3729
tree0749c369f73c4dff533279076255f95aa6cdd80a
parent7ed22b36cb7844df929dd5783d452c422e720c1a
util,python: Fix Pre-commit hooks to ignore non-source files

Previously if binary blobs were modified the pre-commit hook attempted
to run style-checks on the binary, causing an error when attempting to
decode to utf-8. This commit runs a check on each file to ensure it has
a valid source-code extension prior to running style checks. If a file
does not have a valid extension style checks are not run.

Change-Id: Id1263cac0d6c190ad1a3d67720b3f373e0e42234
Issue-on: https://gem5.atlassian.net/browse/GEM5-903
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39795
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
util/style/style.py