Add ability to specify and run post upload hooks.

Motivation: There are a few things we want to do in Skia infrastructure that is not possible to do without this functionality.
Eg1: If there is a change made to Skia's markdown then automatically include a 'DOCS_PREVIEW_URL=https://skia.org?cl=1234' in the CL's description.
Eg2: Automatically add 'NOTRY=true' for changes impacting things that do not need trybot runs.
Eg3: Include CL specific links to skia's perf (https://perf.skia.org/) and correctness (https://gold.skia.org/) servers.

BUG=chromium:462208

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294242 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 728bae7..9ac9470 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -432,6 +432,11 @@
   def GetBugPrefix(self):
     return self._GetRietveldConfig('bug-prefix', error_ok=True)
 
+  def GetRunPostUploadHook(self):
+    run_post_upload_hook = self._GetRietveldConfig(
+        'run-post-upload-hook', error_ok=True)
+    return run_post_upload_hook == "True"
+
   def GetDefaultCCList(self):
     return self._GetRietveldConfig('cc', error_ok=True)
 
@@ -1029,6 +1034,8 @@
               'tree-status-url', False)
   SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True)
   SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False)
+  SetProperty(settings.GetRunPostUploadHook(), 'Run Post Upload Hook',
+              'run-post-upload-hook', False)
 
   # TODO: configure a default branch to diff against, rather than this
   # svn-based hackery.
@@ -1211,6 +1218,8 @@
   SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True)
   SetProperty('project', 'PROJECT', unset_error_ok=True)
   SetProperty('pending-ref-prefix', 'PENDING_REF_PREFIX', unset_error_ok=True)
+  SetProperty('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK',
+              unset_error_ok=True)
 
   if 'GERRIT_HOST' in keyvals:
     RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
@@ -2036,6 +2045,14 @@
   if not ret:
     git_set_branch_value('last-upload-hash',
                          RunGit(['rev-parse', 'HEAD']).strip())
+    # Run post upload hooks, if specified.
+    if settings.GetRunPostUploadHook():
+      presubmit_support.DoPostUploadExecuter(
+          change,
+          cl,
+          settings.GetRoot(),
+          options.verbose,
+          sys.stdout)
 
   return ret