Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/resources/md_history/PRESUBMIT.py

Issue 2251403002: [MD History] Use modified time to check staleness of vulcanize and crisper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os.path, time
tsergeant 2016/08/19 00:24:37 Nit: imports on separate lines
calamity 2016/08/19 02:01:11 Done.
5 6
6 def CheckChangeOnUpload(input_api, output_api): 7 def CheckChangeOnUpload(input_api, output_api):
7 """Warn when changing md_history without vulcanizing.""" 8 """Warn when changing md_history without vulcanizing."""
8 9
9 def _is_md_history_file(path): 10 def _is_md_history_file(path):
10 return (path.startswith('chrome/browser/resources/md_history') and 11 return (path.startswith('chrome/browser/resources/md_history') and
11 (not path.endswith('externs.js')) and 12 (not path.endswith('externs.js')) and
12 (path.endswith('js') or path.endswith('html'))) 13 (path.endswith('js') or path.endswith('html')))
13 14
14 def _affects_file(filename, paths): 15 def _affects_file(filename, paths):
15 return any([filename in path for path in paths]) 16 return any([filename in path for path in paths])
16 17
17 paths = [x.LocalPath() for x in input_api.change.AffectedFiles()] 18 paths = [x.LocalPath() for x in input_api.change.AffectedFiles()]
18 vulcanize_changes = (_affects_file('md_history/app.vulcanized.html', paths) or 19 earliest_vulcanize_change = min(os.path.getmtime(x) for x in
19 _affects_file('md_history/app.crisper.js', paths)) 20 ['app.vulcanized.html', 'app.crisper.js'])
20 history_changes = filter(_is_md_history_file, paths) 21 history_changes = filter(_is_md_history_file, paths)
22 latest_history_change = 0
23 if history_changes:
24 latest_history_change = max(os.path.getmtime(os.path.split(x)[1]) for x in
25 history_changes)
21 26
22 if history_changes and not vulcanize_changes: 27 if latest_history_change > earliest_vulcanize_change:
23 return [output_api.PresubmitPromptWarning( 28 return [output_api.PresubmitPromptWarning(
24 'Vulcanize must be run when changing files in md_history. See ' 29 'Vulcanize must be run when changing files in md_history. See '
25 'docs/vulcanize.md.')] 30 'docs/vulcanize.md.')]
26 return [] 31 return []
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698