repopick: Use hostname of the URL to determine omnirom gerrit

Change-Id: Ifd3883917bc4acd7d58179235d880f2e4a43b670
diff --git a/build/tools/repopick.py b/build/tools/repopick.py
index 0a28d37..e41b733 100755
--- a/build/tools/repopick.py
+++ b/build/tools/repopick.py
@@ -34,9 +34,6 @@
 from functools import cmp_to_key, partial
 from xml.etree import ElementTree
 
-# Default to LineageOS Gerrit
-DEFAULT_GERRIT = "https://gerrit.omnirom.org"
-
 
 # cmp() is not available in Python 3, define it manually
 # See https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
@@ -187,6 +184,11 @@
     return status not in ("OPEN", "NEW", "DRAFT")
 
 
+def is_omnirom_gerrit(remote_url):
+    p = urllib.parse.urlparse(remote_url)
+    return p.hostname == "gerrit.omnirom.org"
+
+
 def commit_exists(project_path, revision):
     return (
         subprocess.call(
@@ -285,7 +287,7 @@
     parser.add_argument(
         "-g",
         "--gerrit",
-        default=DEFAULT_GERRIT,
+        default="https://gerrit.omnirom.org",
         metavar="",
         help="Gerrit Instance to use. Form proto://[user@]host[:port]",
     )
@@ -635,8 +637,8 @@
         cmd.append("--quiet")
     cmd.extend(["", item["fetch"][method]["ref"]])
 
-    # Try fetching from GitHub first if using default gerrit
-    if args.gerrit == DEFAULT_GERRIT:
+    # Try fetching from GitHub first if using omnirom gerrit
+    if is_omnirom_gerrit(args.gerrit):
         if args.verbose:
             print("Trying to fetch the change from GitHub")
 
@@ -649,9 +651,9 @@
             return
         print("ERROR: git command failed")
 
-    # If not using the default gerrit or github failed, fetch from gerrit.
+    # If not using the omnirom gerrit or github failed, fetch from gerrit.
     if args.verbose:
-        if args.gerrit == DEFAULT_GERRIT:
+        if is_omnirom_gerrit(args.gerrit):
             print(
                 "Fetching from GitHub didn't work, trying to fetch the change from Gerrit"
             )