Commit 753815c5 authored by dbeam's avatar dbeam Committed by Commit bot

Touch up md_history presubmit

- os.path is provided by input_api, and it's preferred to use it
- time does not seem to be used any more
- input_api.change.AffectedFiles() with a "starts with my dir" filter
  is equivalent to input_api.AffectedFiles(); also, harness file_filter=
- os.path.split()[1] is equivalent to os.path.basename(), which is more
  readable, IMO

R=calamity@chromium.org
BUG=none
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2599593003
Cr-Commit-Position: refs/heads/master@{#440937}
parent a08ea6fb
......@@ -2,30 +2,29 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os.path
import time
def CheckChangeOnUpload(input_api, output_api):
"""Warn when changing md_history without vulcanizing."""
def _is_md_history_file(path):
return (path.startswith('chrome/browser/resources/md_history') and
(not path.endswith('externs.js')) and
(not path.endswith('crisper.js')) and
(not path.endswith('vulcanized.html')) and
(path.endswith('js') or path.endswith('html')))
def _is_history_source_file(file):
path = file.LocalPath()
return (not path.endswith('externs.js') and
not path.endswith('crisper.js') and
not path.endswith('vulcanized.html') and
(path.endswith('.js') or path.endswith('.html')))
paths = [x.LocalPath() for x in input_api.change.AffectedFiles()]
earliest_vulcanize_change = min(os.path.getmtime(x) for x in
os_path = input_api.os_path
earliest_vulcanize_change = min(os_path.getmtime(x) for x in
['app.vulcanized.html',
'app.crisper.js',
'lazy_load.vulcanized.html',
'lazy_load.crisper.js'])
history_changes = filter(_is_md_history_file, paths)
source_files = input_api.AffectedFiles(file_filter=_is_history_source_file)
latest_history_change = 0
if history_changes:
latest_history_change = max(os.path.getmtime(os.path.split(x)[1]) for x in
history_changes)
if source_files:
latest_history_change = max(
os_path.getmtime(os_path.basename(f.LocalPath())) for f in source_files)
if latest_history_change > earliest_vulcanize_change:
return [output_api.PresubmitPromptWarning(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment