Merge "Update OpenDev Manual URL in new contributor intro"
diff --git a/jeepyb/cmd/manage_projects.py b/jeepyb/cmd/manage_projects.py
index 009f2db..fcdcdba 100644
--- a/jeepyb/cmd/manage_projects.py
+++ b/jeepyb/cmd/manage_projects.py
@@ -351,7 +351,7 @@
return created
-# TODO(mordred): Inspect repo_dir:master for a description
+# TODO(mordred): Inspect repo_dir:default-branch for a description
# override
def find_description_override(repo_path):
return None
@@ -385,14 +385,15 @@
raise ProcessACLException()
finally:
u.git_command(repo_path, 'reset --hard')
- u.git_command(repo_path, 'checkout master')
+ default_branch = section.get('default-branch', 'master')
+ u.git_command(repo_path, 'checkout %s' % default_branch)
u.git_command(repo_path, 'branch -D config')
-def create_gerrit_project(project, project_list, gerrit):
+def create_gerrit_project(project, default_branch, project_list, gerrit):
if project not in project_list:
try:
- gerrit.createProject(project)
+ gerrit.createProject(project, branches=[default_branch])
return True
except Exception:
log.exception(
@@ -484,6 +485,7 @@
description = section.get('description', None)
homepage = section.get('homepage', DEFAULT_HOMEPAGE)
upstream = section.get('upstream', None)
+ default_branch = section.get('default-branch', 'master')
repo_path = os.path.join(JEEPYB_CACHE_DIR, project)
# If this project doesn't want to use gerrit, exit cleanly.
@@ -511,7 +513,7 @@
if not project_created:
try:
project_created = create_gerrit_project(
- project, project_list, gerrit)
+ project, default_branch, project_list, gerrit)
project_cache[project]['project-created'] = True
except Exception:
project_cache[project]['project-created'] = False
@@ -526,7 +528,7 @@
# Make Local repo
push_string = u.make_local_copy(
- repo_path, project, project_list,
+ repo_path, project, default_branch, project_list,
git_opts, ssh_env, upstream, GITREVIEW_GERRIT_HOST,
GITREVIEW_GERRIT_PORT, project_git, GERRIT_GITID)
@@ -555,9 +557,10 @@
if not os.path.exists(repo_path):
u.make_local_copy(
- repo_path, project, project_list,
- git_opts, ssh_env, upstream, GERRIT_HOST,
- GERRIT_PORT, project_git, GERRIT_GITID)
+ repo_path, project, default_branch,
+ project_list, git_opts, ssh_env, upstream,
+ GERRIT_HOST, GERRIT_PORT, project_git,
+ GERRIT_GITID)
process_acls(
acl_config, project, ACL_DIR, section,
remote_url, repo_path, ssh_env, gerrit,
diff --git a/jeepyb/cmd/track_upstream.py b/jeepyb/cmd/track_upstream.py
index cbd0721..ba2b482 100644
--- a/jeepyb/cmd/track_upstream.py
+++ b/jeepyb/cmd/track_upstream.py
@@ -189,6 +189,7 @@
upstream = section.get('upstream', None)
upstream_prefix = section.get('upstream-prefix', None)
+ default_branch = section.get('default-branch', 'master')
repo_path = os.path.join(IMPORT_DIR, project)
project_git = "%s.git" % project
@@ -206,7 +207,7 @@
# Make Local repo
if not os.path.exists(repo_path):
u.make_local_copy(
- repo_path, project, project_list,
+ repo_path, project, default_branch, project_list,
git_opts, ssh_env, upstream, GERRIT_HOST,
GERRIT_PORT, project_git, GERRIT_GITID)
else:
diff --git a/jeepyb/utils.py b/jeepyb/utils.py
index 8e6ab34..31510cf 100644
--- a/jeepyb/utils.py
+++ b/jeepyb/utils.py
@@ -92,7 +92,7 @@
return dict(GIT_SSH=name)
-def make_local_copy(repo_path, project, project_list,
+def make_local_copy(repo_path, project, default_branch, project_list,
git_opts, ssh_env, upstream, GERRIT_HOST, GERRIT_PORT,
project_git, GERRIT_GITID):
@@ -148,8 +148,11 @@
# Neither gerrit has it, nor does it have an upstream,
# just create a whole new one
else:
+ ref_str = 'refs/heads/%s' % default_branch
run_command("git init %s" % repo_path)
git_command(
+ repo_path, "symbolic-ref HEAD " + ref_str)
+ git_command(
repo_path,
"remote add origin %(remote_url)s" % git_opts)
with open(os.path.join(repo_path,
@@ -164,7 +167,7 @@
cmd = ("commit -a -m'Added .gitreview' --author='%s'"
% GERRIT_GITID)
git_command(repo_path, cmd)
- return "push %s HEAD:refs/heads/master"
+ return "push %s HEAD:" + ref_str
def fsck_repo(repo_path):