Accept URLs missing schemes in git cl patch

Currently, calling a command like "git cl patch crrev.com/c/1234567"
will fail with "git cl: error: Invalid issue ID or URL." as no scheme is
supplied (i.e. "git cl patch https://crrev.com/c/1234567" is considered
valid).

This cl removes the requirement for supplying a scheme. Instead, the
script attempts to add "https://" where it would've thrown an error
previously. If the resulting string is valid, it is used. Otherwise, an
error will still be thrown.

Bug: 1223200
Change-Id: I24ee4df48b5f5d434f3abe270f5c3e793c347cc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2983443
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Alex Turner <alexmt@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 3540382..22c1585 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -881,10 +881,10 @@
 
   if arg.isdigit():
     return _ParsedIssueNumberArgument(issue=int(arg))
-  if not arg.startswith('http'):
-    return fail_result
 
   url = gclient_utils.UpgradeToHttps(arg)
+  if not url.startswith('http'):
+    return fail_result
   for gerrit_url, short_url in _KNOWN_GERRIT_TO_SHORT_URLS.items():
     if url.startswith(short_url):
       url = gerrit_url + url[len(short_url):]
@@ -895,6 +895,11 @@
   except ValueError:
     return fail_result
 
+  # If "https://" was automatically added, fail if `arg` looks unlikely to be a
+  # URL.
+  if not arg.startswith('http') and '.' not in parsed_url.netloc:
+    return fail_result
+
   # Gerrit's new UI is https://domain/c/project/+/<issue_number>[/[patchset]]
   # But old GWT UI is https://domain/#/c/project/+/<issue_number>[/[patchset]]
   # Short urls like https://domain/<issue_number> can be used, but don't allow