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

Side by Side Diff: commit-queue/post_processors/chromium_copyright.py

Issue 135363007: Delete public commit queue to avoid confusion after move to internal repo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « commit-queue/pending_manager.py ('k') | commit-queue/projects.py » ('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 (c) 2012 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 import datetime
6 import os
7 import re
8
9 import errors
10
11
12 def process(checkout, patch):
13 """Enforces current year in Chromium copyright."""
14 pattern = (
15 r'^(.*)Copyright (?:\(c\) )?\d{4}(|-\d{4}) The Chromium Authors. '
16 r'All rights reserved.$')
17 replacement = (
18 r'\1Copyright %s The Chromium Authors. All rights reserved.' %
19 datetime.date.today().year)
20
21 if not patch.is_new or patch.is_binary:
22 return
23 filepath = os.path.join(checkout.project_path, patch.filename)
24 try:
25 with open(filepath, 'rb') as f:
26 lines = f.read().splitlines(True)
27 except IOError, e:
28 errors.send_stack(e)
29 lines = None
30 if not lines:
31 return
32 modified = False
33 for i in xrange(min(5, len(lines))):
34 old_line = lines[i]
35 lines[i] = re.sub(pattern, replacement, lines[i])
36 if old_line != lines[i]:
37 modified = True
38 break
39 if modified:
40 with open(filepath, 'wb') as f:
41 f.write(''.join(lines))
OLDNEW
« no previous file with comments | « commit-queue/pending_manager.py ('k') | commit-queue/projects.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698