Fix to work when a single project has multiple remotes.

Porting change https://gerrit.chromium.org/gerrit/#/c/48397/3 to factory
branch

BUG=chrome-os-partner:19663
TEST=none

Change-Id: I595c99820c2a6a3b9a699e824f7c24127aa1d196
Reviewed-on: https://gerrit.chromium.org/gerrit/56304
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Mohammed Habibulla <moch@chromium.org>
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
Tested-by: Mohammed Habibulla <moch@chromium.org>
diff --git a/buildbot/portage_utilities.py b/buildbot/portage_utilities.py
index 844b165..35ea3d9 100644
--- a/buildbot/portage_utilities.py
+++ b/buildbot/portage_utilities.py
@@ -289,9 +289,9 @@
                             subdir_path, self._pkgname))
 
     # Verify that we're grabbing the commit id from the right project name.
-    cmd = ('git config --get remote.cros.projectname || '
-           'git config --get remote.cros-internal.projectname')
-    real_project = self._RunCommand(cmd, cwd=subdir_path, shell=True).rstrip()
+    cmd = ['repo', 'forall', '.', '-c',
+           'git config --get remote.${REPO_REMOTE}.projectname']
+    real_project = self._RunCommand(cmd, cwd=subdir_path).rstrip()
     if project != real_project:
       cros_build_lib.Die('Project name mismatch for %s '
                          '(found %s, expected %s)' % (