diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 16:50:28 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 16:50:28 +0000 |
commit | e5dd62f9ceaf7bccb3103546e4d123169c1fa55c (patch) | |
tree | c91e294205f59f48eabea9fd9c29867918690fcf /third_party/PRESUBMIT.py | |
parent | 3ea69c5f79027e9a39d1078bc79509157e411e00 (diff) | |
download | chromium_src-e5dd62f9ceaf7bccb3103546e4d123169c1fa55c.zip chromium_src-e5dd62f9ceaf7bccb3103546e4d123169c1fa55c.tar.gz chromium_src-e5dd62f9ceaf7bccb3103546e4d123169c1fa55c.tar.bz2 |
Fix 2 bugs in third_party/PRESUBMIT.py
1) Removing a third_party directory raises an exception since it tries to
open the deleted README.chromium file. Instead, try to make sure files
are being deleted.
2) Editing PRESUBMIT.py gives errors about not having edited README.chromium.
Ignore the files in third_party that are not directories.
TBR=cdn@chromium.org
Review URL: https://codereview.chromium.org/21217004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/PRESUBMIT.py')
-rw-r--r-- | third_party/PRESUBMIT.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/third_party/PRESUBMIT.py b/third_party/PRESUBMIT.py index 6812a18..4a6cba8 100644 --- a/third_party/PRESUBMIT.py +++ b/third_party/PRESUBMIT.py @@ -11,9 +11,12 @@ def _CheckThirdPartyReadmesUpdated(input_api, output_api): files = [] errors = [] for f in input_api.AffectedFiles(): - if f.LocalPath().startswith('third_party' + input_api.os_path.sep): + local_path = f.LocalPath() + if input_api.os_path.dirname(local_path) == 'third_party': + continue + if local_path.startswith('third_party' + input_api.os_path.sep): files.append(f) - if f.LocalPath().endswith("README.chromium"): + if local_path.endswith("README.chromium"): readmes.append(f) if files and not readmes: errors.append(output_api.PresubmitPromptWarning( @@ -40,6 +43,10 @@ def _CheckThirdPartyReadmesUpdated(input_api, output_api): input_api.re.IGNORECASE | input_api.re.MULTILINE) for f in readmes: + if 'D' in f.Action(): + _IgnoreIfDeleting(input_api, output_api, f, errors) + continue + contents = input_api.ReadFile(f) if (not shortname_pattern.search(contents) and not name_pattern.search(contents)): @@ -70,6 +77,16 @@ def _CheckThirdPartyReadmesUpdated(input_api, output_api): return errors +def _IgnoreIfDeleting(input_api, output_api, affected_file, errors): + third_party_dir = input_api.os_path.dirname(affected_file.LocalPath()) + for f in input_api.AffectedFiles(): + if f.LocalPath().startswith(third_party_dir): + if 'D' not in f.Action(): + errors.append(output_api.PresubmitError( + 'Third party README should only be removed when the whole\n' + 'directory is being removed.\n', [f, affected_file])) + + def CheckChangeOnUpload(input_api, output_api): results = [] results.extend(_CheckThirdPartyReadmesUpdated(input_api, output_api)) |