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

Side by Side Diff: net/websockets/PRESUBMIT.py

Issue 18112015: Add PRESUBMIT.py file to net/websockets (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Re-write PRESUBMIT using set operations Created 7 years, 5 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 | net/websockets/README » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Chromium presubmit script for src/net/websockets.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details on the presubmit API built into gcl.
9 """
10
11
12 # TODO(ricea): Remove this once the old implementation has been removed and the
13 # list of files in the README file is no longer needed.
14 def CheckReadMeComplete(input_api, output_api):
tyoshino (SeeGerritForStatus) 2013/07/11 09:26:54 Add '_' prefix to CheckReadMeComplete?
Adam Rice 2013/07/11 09:46:20 Done.
15 """Verifies that any new files have been added to the README file.
16
17 Checks that if any source files were added in this CL, that they were
18 also added to the README file. We do not warn about pre-existing
19 errors, as that would be annoying.
20
21 Args:
22 input_api: The InputApi object provided by the presubmit framework.
23 output_api: The OutputApi object provided by the framework.
24
25 Returns:
26 A list of zero or more PresubmitPromptWarning objects.
27 """
28 # None passed to AffectedSourceFiles means "use the default filter", which
29 # does what we want, ie. returns files in the CL with filenames that look like
30 # source code.
31 added_source_filenames = set(input_api.basename(af.LocalPath())
32 for af in input_api.AffectedSourceFiles(None)
33 if af.Action().startswith('A'))
34 if not added_source_filenames:
35 return []
36 readme = input_api.AffectedSourceFiles(
37 lambda af: af.LocalPath().endswith('/README'))
38 if not readme:
39 return [output_api.PresubmitPromptWarning(
40 'One or more files were added to net/websockets without being added\n'
41 'to net/websockets/README.\n', added_source_filenames)]
42 readme_added_filenames = set(line.strip() for line in readme[0].NewContents()
43 if line.strip() in added_source_filenames)
44 if readme_added_filenames < added_source_filenames:
45 return [output_api.PresubmitPromptWarning(
46 'One or more files added to net/websockets but not found in the README '
47 'file.\n', added_source_filenames - readme_added_filenames)]
48 else:
49 return []
50
51
52 def CheckChange(input_api, output_api):
53 results = []
54 results += CheckReadMeComplete(input_api, output_api)
55 return results
56
57
58 def CheckChangeOnUpload(input_api, output_api):
tyoshino (SeeGerritForStatus) 2013/07/11 09:26:54 It seems only CheckChangeOnUpload and CheckChangeO
Adam Rice 2013/07/11 09:46:20 Yes. I included CheckChange() so it would be easy
59 return CheckChange(input_api, output_api)
60
61
62 def CheckChangeOnCommit(input_api, output_api):
63 return CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « no previous file | net/websockets/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698