git cl: restart using project~number on Gerrit.

This fixes Gerrit project detection based on remote URL,
accounting for potential 'a/' prefix in the URL path component,
which isn't part of the Gerrit project name.

R=ehmaldonado, mmoss

Bug: 876964, 876910
Change-Id: I473ae8c6c9e0f2034b350901abd67db151e0a3d3
Reviewed-on: https://chromium-review.googlesource.com/1187573
Reviewed-by: Michael Moss <mmoss@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 7a46c1f..36c6889 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2412,6 +2412,14 @@
     project = urlparse.urlparse(remote_url).path.strip('/')
     if project.endswith('.git'):
       project = project[:-len('.git')]
+    # *.googlesource.com hosts ensure that Git/Gerrit projects don't start with
+    # 'a/' prefix, because 'a/' prefix is used to force authentication in
+    # gitiles/git-over-https protocol. E.g.,
+    # https://chromium.googlesource.com/a/v8/v8 refers to the same repo/project
+    # as
+    # https://chromium.googlesource.com/v8/v8
+    if project.startswith('a/'):
+      project = project[len('a/'):]
     return project
 
   def _GerritChangeIdentifier(self):
@@ -2419,10 +2427,8 @@
 
     Not to be confused by value of "Change-Id:" footer.
     """
-    # TODO(tandrii): undo this once a fix is in place for crbug/876964.
-    # return gerrit_util.ChangeIdentifier(
-    #     self._GetGerritProject(), self.GetIssue())
-    return str(self.GetIssue())
+    return gerrit_util.ChangeIdentifier(
+        self._GetGerritProject(), self.GetIssue())
 
   @classmethod
   def IssueConfigKey(cls):