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

Side by Side Diff: verification/tree_status.py

Issue 68113009: Adding support for NOTREECHECKS (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/commit-queue/
Patch Set: Created 7 years, 1 month 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 | « tests/tree_status_test.py ('k') | 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 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Postpone commits until the tree is open.""" 5 """Postpone commits until the tree is open."""
6 6
7 import calendar 7 import calendar
8 import json 8 import json
9 import logging 9 import logging
10 import re
10 import ssl 11 import ssl
11 import time 12 import time
12 import urllib2 13 import urllib2
13 14
14 from verification import base 15 from verification import base
15 16
16 17
17 class TreeStatus(base.IVerifierStatus): 18 class TreeStatus(base.IVerifierStatus):
18 tree_status_url = unicode 19 tree_status_url = unicode
19 issue = int 20 issue = int
(...skipping 29 matching lines...) Expand all
49 return False 50 return False
50 except (ssl.SSLError, urllib2.URLError, ValueError): 51 except (ssl.SSLError, urllib2.URLError, ValueError):
51 logging.error('Failed to request tree status! %s' % url) 52 logging.error('Failed to request tree status! %s' % url)
52 return True 53 return True
53 54
54 def why_not(self): 55 def why_not(self):
55 if self.last_tree_status: 56 if self.last_tree_status:
56 return u'Tree is currently not open: %s' % self.last_tree_status 57 return u'Tree is currently not open: %s' % self.last_tree_status
57 58
58 59
60 class AlwaysOpenTreeStatus(TreeStatus):
61 """Used when tree status does not need to be checked."""
62 def postpone(self):
63 return False
64
65
59 class TreeStatusVerifier(base.Verifier): 66 class TreeStatusVerifier(base.Verifier):
60 """Checks the tree status before allowing a commit.""" 67 """Checks the tree status before allowing a commit."""
61 name = 'tree status' 68 name = 'tree status'
62 69
63 def __init__(self, tree_status_url): 70 def __init__(self, tree_status_url):
64 super(TreeStatusVerifier, self).__init__() 71 super(TreeStatusVerifier, self).__init__()
65 self.tree_status_url = tree_status_url 72 self.tree_status_url = tree_status_url
66 73
67 def verify(self, pending): 74 def verify(self, pending):
68 pending.verifications[self.name] = TreeStatus( 75 if re.search(r'(?im)^NOTREECHECKS=TRUE$', pending.description):
69 tree_status_url=self.tree_status_url, issue=pending.issue) 76 # Use a TreeStatus instance that always returns False for postpone().
77 tree_status = AlwaysOpenTreeStatus()
78 else:
79 tree_status = TreeStatus(
80 tree_status_url=self.tree_status_url, issue=pending.issue)
81
82 pending.verifications[self.name] = tree_status
70 83
71 def update_status(self, queue): 84 def update_status(self, queue):
72 pass 85 pass
86
OLDNEW
« no previous file with comments | « tests/tree_status_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698