Skip to content

Commit

Permalink
Display the actual tree status when the tree is closed. Much more hel…
Browse files Browse the repository at this point in the history
…pful.

TEST=Try committing when the tree is closed to see.
BUG=none
Review URL: http://codereview.chromium.org/119437

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18125 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
maruel@chromium.org committed Jun 11, 2009
1 parent 4306417 commit 04a39f7
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def CheckChangeOnCommit(input_api, output_api):
input_api, output_api, sources))
# Make sure the tree is 'open'.
# TODO(maruel): Run it in a separate thread to parallelize checks?
results.extend(input_api.canned_checks.CheckTreeIsOpen(
input_api, output_api,
'http://chromium-status.appspot.com/status', '0'
))
results.extend(CheckTreeIsOpen(input_api, output_api,
'http://chromium-status.appspot.com/status',
'0',
'http://chromium-status.appspot.com/current'))
results.extend(CheckTryJobExecution(input_api, output_api))
return results

Expand Down Expand Up @@ -109,3 +109,31 @@ def CheckTryJobExecution(input_api, output_api):
outputs.append(output_api.PresubmitNotifyResult(
'Got %s while looking for try job status.' % str(e)))
return outputs


def CheckTreeIsOpen(input_api, output_api, url, closed, url_text):
"""Similar to the one in presubmit_canned_checks except it shows an helpful
status text instead.
"""
assert(input_api.is_committing)
try:
connection = input_api.urllib2.urlopen(url)
status = connection.read()
connection.close()
if input_api.re.match(closed, status):
long_text = status + '\n' + url
try:
connection = input_api.urllib2.urlopen(url_text)
text = connection.read()
connection.close()
match = input_api.re.search(r"\<div class\=\"Notice\"\>(.*)\<\/div\>",
text)
if match:
long_text = match.group(1).strip()
except IOError:
pass
return [output_api.PresubmitPromptWarning("The tree is closed.",
long_text=long_text)]
except IOError:
pass
return []

0 comments on commit 04a39f7

Please sign in to comment.