Require 'CHROME_HEADLESS' to use 'git-number'.

Updated 'git-number' to produce an error message if it's run without the
CHROME_HEADLESS (bot) environment variable. This is intended to alert developers
who may be incorrectly using this tool to get positioning information instead of
the commit position.

BUG=409917
TEST=local
  - Ran with and without 'CHROME_HEADLESS'; observed the error message in the
    'without' case.

R=iannucci@chromium.org

Review URL: https://codereview.chromium.org/534703002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291773 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_number.py b/git_number.py
index 7fa0398..6997f51 100755
--- a/git_number.py
+++ b/git_number.py
@@ -252,6 +252,13 @@
   levels = [logging.ERROR, logging.INFO, logging.DEBUG]
   logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])
 
+  # 'git number' should only be used on bots.
+  if os.getenv('CHROME_HEADLESS') != '1':
+    logging.error("'git-number' is an infrastructure tool that is only "
+                  "intended to be used internally by bots. Developers should "
+                  "use the 'Cr-Commit-Position' value in the commit's message.")
+    return 1
+
   try:
     if opts.reset:
       clear_caches(on_disk=True)