From f6c5f75b3cb173be1a45032f8fc78b02cded9cc8 Mon Sep 17 00:00:00 2001 From: "rmistry@google.com" Date: Fri, 29 Mar 2013 17:26:00 +0000 Subject: [PATCH] Display prompt for caution only if it is an interactive shell. Created to fix https://code.google.com/p/skia/issues/detail?id=1197 : Skia Commit Queue quits if the tree is in Caution. (SkipBuildbotRuns) Review URL: https://codereview.chromium.org/13325002 git-svn-id: http://skia.googlecode.com/svn/trunk@8446 2bbb7eff-a529-9590-31e7-b0007b416f81 --- PRESUBMIT.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index ddac74a..323bba9 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -9,6 +9,9 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into gcl. """ +import os +import sys + def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): """Checks that files end with atleast one \n (LF).""" @@ -67,7 +70,11 @@ def _CheckTreeStatus(input_api, output_api, json_url): connection = input_api.urllib2.urlopen(json_url) status = input_api.json.loads(connection.read()) connection.close() - if 'caution' in status['message'].lower(): + if ('caution' in status['message'].lower() and + os.isatty(sys.stdout.fileno())): + # Display a prompt only if we are in an interactive shell. Without this + # check the commit queue behaves incorrectly because it considers + # prompts to be failures. short_text = 'Tree state is: ' + status['general_state'] long_text = status['message'] + '\n' + json_url tree_status_results.append( -- 2.7.4