Bobby R. Bruce has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/39795 )
Change subject: util,python: Fix Pre-commit hooks to ignore non-source files
......................................................................
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...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M util/style/style.py
1 file changed, 13 insertions(+), 5 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/util/style/style.py b/util/style/style.py
index e765a92..1a5e94b 100644
--- a/util/style/style.py
+++ b/util/style/style.py
@@ -86,6 +86,15 @@
return rex.match(fname)
return match_re
+def _re_only(expr):
+ """Helper function to create regular expressions to only keep
+ matcher functions"""
+
+ rex = re.compile(expr)
+ def match_re(fname):
+ return not rex.match(fname)
+ return match_re
+
# This list contains a list of functions that are called to determine
# if a file should be excluded from the style matching rules or
# not. The functions are called with the file name relative to the
@@ -97,11 +106,10 @@
_re_ignore("^ext/"),
# Ignore test data, as they are not code
_re_ignore("^tests/(?:quick|long)/"),
- # Ignore RISC-V assembly tests as they are maintained in an external
- # project that does not follow the gem5 coding convention
- _re_ignore("tests/test-progs/asmtest/src/riscv/"),
- # Ignore RISC-V assembly dump files
- _re_ignore("tests/test-progs/asmtest/dump/riscv/")
+ # Only include Scons files and those with extensions that suggest
source
+ # code
+ _re_only("^((.*\/)?(SConscript|SConstruct)|"
+ ".*\.(c|h|cc|hh|cpp|hpp|py|isa|proto))$")
]
def check_ignores(fname):
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39795
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Id1263cac0d6c190ad1a3d67720b3f373e0e42234
Gerrit-Change-Number: 39795
Gerrit-PatchSet: 4
Gerrit-Owner: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Boris Shingarov <shinga...@gmail.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s