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

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: 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):
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_files = [af for af in input_api.AffectedSourceFiles(None)
yhirano 2013/07/11 01:44:34 Maybe you can delete added_source_files by creatin
Adam Rice 2013/07/11 06:42:37 Good idea, thank you.
32 if af.Action().startswith('A')]
33 if not added_source_files:
34 return []
35 readme = input_api.AffectedSourceFiles(
36 lambda af: af.LocalPath().endswith('/README'))
37 added_source_filenames = set(input_api.basename(sf.LocalPath())
38 for sf in added_source_files)
39 if not readme:
40 return [output_api.PresubmitPromptWarning(
41 'One or more files were added to net/websockets without being added\n'
42 'to net/websockets/README.\n', added_source_filenames)]
43 for line in readme[0].NewContents():
yhirano 2013/07/11 01:44:34 Can you introduce readme_added_filenames = set([li
yhirano 2013/07/11 01:47:35 rewrite the following lines by using set operation
Adam Rice 2013/07/11 06:42:37 Very nice. Implemented.
Adam Rice 2013/07/11 06:42:37 No problem. I understood what you meant.
44 if line.strip() in added_source_filenames:
45 added_source_filenames.remove(line.strip())
46 if added_source_filenames:
47 return [output_api.PresubmitPromptWarning(
48 'One or more files added to net/websockets but not found in the README '
49 'file.\n', added_source_filenames)]
50 else:
51 return []
52
53
54 def CheckChange(input_api, output_api):
55 results = []
56 results += CheckReadMeComplete(input_api, output_api)
57 return results
58
59
60 def CheckChangeOnUpload(input_api, output_api):
61 return CheckChange(input_api, output_api)
62
63
64 def CheckChangeOnCommit(input_api, output_api):
65 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