pre-upload: Do not ignore errors in PRESUBMIT.cfg.
We used to fall back to an empty config if we fail to parse
PRESUBMIT.cfg. But it's very error-prone because an accidental
error in PRESUBMIT.cfg leads to disabling all preupload hooks
silently.
BUG=chromium:1019067
TEST=repo upload # in third_party/autotest/files; fails
Change-Id: I8c2f446eff4fceaba3a0f1373b5237b1afca67bc
Reviewed-on: https://chromium-review.googlesource.com/1885930
Tested-by: Shuhei Takahashi <nya@chromium.org>
Commit-Ready: Shuhei Takahashi <nya@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 0b8a055..34dfcaf 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -1351,7 +1351,7 @@
# Require people to set specific values all the time.
settings = (
# TODO: Enable this for everyone. http://crbug.com/408038
- #('fast caching', 'cache-format = md5-dict'),
+ # ('fast caching', 'cache-format = md5-dict'),
('fast manifests', 'thin-manifests = true'),
('extra features', 'profile-formats = portage-2 profile-default-eapi'),
('newer eapi', 'profile_eapi_when_unspecified = 5-progress'),
@@ -1909,11 +1909,11 @@
presubmit: A Boolean, True if the check is run as a git pre-submit script.
"""
config = configparser.RawConfigParser()
- try:
- config.read(_CONFIG_FILE)
- except configparser.Error:
+ if not os.path.exists(_CONFIG_FILE):
# Just use an empty config file
config = configparser.RawConfigParser()
+ else:
+ config.read(_CONFIG_FILE)
if presubmit:
hooks = _COMMON_HOOKS