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

Unified Diff: presubmit_support.py

Issue 147162: Ask for feedback one time out of 5, only when there is presubmit check notification. (Closed)
Patch Set: . Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index 8586a48712dd9015d1743fb764bfb38224b686ac..351dcda80b14d189b702e1fb77c944c6fe70c4d3 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -22,6 +22,7 @@ import marshal # Exposed through the API.
import optparse
import os # Somewhat exposed through the API.
import pickle # Exposed through the API.
+import random
import re # Exposed through the API.
import subprocess # Exposed through the API.
import sys # Parts exposed through API.
@@ -40,6 +41,10 @@ import gclient
import presubmit_canned_checks
+# Ask for feedback only once in program lifetime.
+_ASKED_FOR_FEEDBACK = False
+
+
class NotImplementedException(Exception):
"""We're leaving placeholders in a bunch of places to remind us of the
design of the API, but we have not implemented all of it yet. Implement as
@@ -780,6 +785,10 @@ def DoPresubmitChecks(change,
default_presubmit: A default presubmit script to execute in any case.
may_prompt: Enable (y/n) questions on warning or error.
+ Warning:
+ If may_prompt is true, output_streeam SHOULD be sys.stdout and input_stream
Jói Sigurðsson 2009/06/25 21:19:28 output_streeam -> output_stream
+ SHOULD be sys.stdin.
+
Return:
True if execution can continue, False if not.
"""
@@ -830,6 +839,13 @@ def DoPresubmitChecks(change,
response = input_stream.readline()
if response.strip().lower() != 'y':
error_count += 1
+
+ global _ASKED_FOR_FEEDBACK
+ # Ask for feedback one time out of 5.
+ if (len(results) and random.randint(0, 4) == 0 and not _ASKED_FOR_FEEDBACK):
+ output_stream.write("Was the presubmit check useful? Please send feedback "
+ "& hate mail to maruel@chromium.org!\n")
+ _ASKED_FOR_FEEDBACK = True
return (error_count == 0)
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698