Fetch all refs/heads from upstream and push them.

Previously we were only fetching and pushing the default upstream branch
to the new Gerrit repos. Explicitly fetch all the upstream refs/heads/*
and push them to the new Gerrit repo's refs/heads/*.

Change-Id: Icd94453c640961e8d759073fb2a2f51163d875e9
Reviewed-on: https://review.openstack.org/17262
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Paul Belanger <paul.belanger@polybeacon.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
diff --git a/jeepyb/cmd/manage_projects.py b/jeepyb/cmd/manage_projects.py
index dd3aa9f..0421dcb 100644
--- a/jeepyb/cmd/manage_projects.py
+++ b/jeepyb/cmd/manage_projects.py
@@ -284,6 +284,11 @@
                         run_command("git clone %(upstream)s %(repo_path)s" %
                                     dict(upstream=upstream,
                                          repo_path=repo_path))
+                        git_command(repo_path,
+                                    "fetch origin "
+                                    "+refs/heads/*:refs/copy/heads/*",
+                                    env=ssh_env)
+                        push_string = "push %s +refs/copy/heads/*:refs/heads/*"
                     else:
                         run_command("git init %s" % repo_path)
                         with open(os.path.join(repo_path,
@@ -300,6 +305,7 @@
                               "'Openstack Project Creator " \
                               "<openstack-infra@lists.openstack.org>'"
                         git_command(repo_path, cmd)
+                        push_string = "push --all %s"
                     gerrit.createProject(project)
 
                     if not os.path.exists(project_dir):
@@ -308,7 +314,7 @@
                                     % project_dir)
 
                     git_command(repo_path,
-                                "push --all %s" % remote_url,
+                                push_string % remote_url,
                                 env=ssh_env)
                     git_command(repo_path,
                                 "push --tags %s" % remote_url, env=ssh_env)