util,python: Add check to ensure files are utf-8 in pre-commit
authorBobby R. Bruce <bbruce@ucdavis.edu>
Thu, 28 Jan 2021 05:33:15 +0000 (21:33 -0800)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Tue, 2 Feb 2021 21:39:09 +0000 (21:39 +0000)
commit58ccc6287e95c597a14d359c0fb703774d02eb82
tree00b7f54ad6fa40ab01c91fd018e8057b281683ab
parent86222736e60b4e2783dcf6c7c0e0963066ec3729
util,python: Add check to ensure files are utf-8 in pre-commit

The `file_from_index` function throws a UnicodeDecodeError if a modified
file targetted for style-checking (i.e. source-code) cannot be decoded
using `.decode("utf-8")`.

This check throws an error informing the user a submitted file must be
utf-8 encoded if this case arises.

Change-Id: I2361017f2e7413ed60f897d2301f2e4c7995dd76
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40015
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/git-pre-commit.py