Fix GetGitProjectName to work when a single project has multiple remotes.

BUG=none
TEST=remote trybot run

Change-Id: I35fc40e8f6fcd263ff0fe9e5bd28945942b53f8b
Previous-Reviewed-on: https://gerrit.chromium.org/gerrit/48397
(cherry picked from commit 350cac722bdad232517e5c2e90527ec82e02d311)
Reviewed-on: https://gerrit.chromium.org/gerrit/48527
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/buildbot/portage_utilities.py b/buildbot/portage_utilities.py
index 5abefa4..a046c86 100644
--- a/buildbot/portage_utilities.py
+++ b/buildbot/portage_utilities.py
@@ -300,9 +300,9 @@
 
   def GetGitProjectName(self, path):
     """Read the project variable from a git repository at given path."""
-    cmd = ('git config --get remote.cros.projectname || '
-           'git config --get remote.cros-internal.projectname')
-    return self._RunCommand(cmd, cwd=path, shell=True).rstrip()
+    cmd = ['repo', 'forall', '.', '-c',
+           'git config --get remote.${REPO_REMOTE}.projectname']
+    return self._RunCommand(cmd, cwd=path).rstrip()
 
   def GetSourcePath(self, srcroot):
     """Get the project and path for this ebuild.