Add default-branch property to projects
Some projects don't have a 'master' branch. Allow users to specify the default-branch of a project so the executor can know what branch to fall back to when preparing repos for a test. Pass that information to the executor. A subsequent change will begin to use it. Change-Id: I20723ac0d3edc9eef38445fb5b61ba3122fe58bb
This commit is contained in:
parent
1960d687c9
commit
040b65097f
|
@ -519,6 +519,7 @@ class ProjectParser(object):
|
|||
'templates': [str],
|
||||
'merge-mode': vs.Any('merge', 'merge-resolve',
|
||||
'cherry-pick'),
|
||||
'default-branch': str,
|
||||
'_source_context': model.SourceContext,
|
||||
'_start_mark': yaml.Mark,
|
||||
}
|
||||
|
@ -554,15 +555,20 @@ class ProjectParser(object):
|
|||
configs.extend([layout.project_templates[name]
|
||||
for name in conf_templates])
|
||||
configs.append(project_template)
|
||||
# Set the following values to the first one that we find and
|
||||
# ignore subsequent settings.
|
||||
mode = conf.get('merge-mode')
|
||||
if mode and project_config.merge_mode is None:
|
||||
# Set the merge mode to the first one that we find and
|
||||
# ignore subsequent settings.
|
||||
project_config.merge_mode = model.MERGER_MAP[mode]
|
||||
default_branch = conf.get('default-branch')
|
||||
if default_branch and project_config.default_branch is None:
|
||||
project_config.default_branch = default_branch
|
||||
if project_config.merge_mode is None:
|
||||
# If merge mode was not specified in any project stanza,
|
||||
# set it to the default.
|
||||
project_config.merge_mode = model.MERGER_MAP['merge-resolve']
|
||||
if project_config.default_branch is None:
|
||||
project_config.default_branch = 'master'
|
||||
for pipeline in layout.pipelines.values():
|
||||
project_pipeline = model.ProjectPipelineConfig()
|
||||
queue_name = None
|
||||
|
|
|
@ -286,21 +286,28 @@ class ExecutorClient(object):
|
|||
params['vars'][secret.name] = copy.deepcopy(secret.secret_data)
|
||||
params['vars']['zuul'] = zuul_params
|
||||
projects = set()
|
||||
|
||||
def make_project_dict(project):
|
||||
project_config = item.current_build_set.layout.project_configs.get(
|
||||
project.canonical_name, None)
|
||||
if project_config:
|
||||
project_default_branch = project_config.default_branch
|
||||
else:
|
||||
project_default_branch = 'master'
|
||||
connection = project.source.connection
|
||||
return dict(connection=connection.connection_name,
|
||||
name=project.name,
|
||||
default_branch=project_default_branch)
|
||||
|
||||
if job.repos:
|
||||
for repo in job.repos:
|
||||
(trusted, project) = tenant.getProject(repo)
|
||||
connection = project.source.connection
|
||||
params['projects'].append(
|
||||
dict(connection=connection.connection_name,
|
||||
name=project.name))
|
||||
params['projects'].append(make_project_dict(project))
|
||||
projects.add(project)
|
||||
for item in all_items:
|
||||
if item.change.project not in projects:
|
||||
project = item.change.project
|
||||
connection = item.change.project.source.connection
|
||||
params['projects'].append(
|
||||
dict(connection=connection.connection_name,
|
||||
name=project.name))
|
||||
params['projects'].append(make_project_dict(project))
|
||||
projects.add(project)
|
||||
|
||||
build = Build(job, uuid)
|
||||
|
|
|
@ -1944,6 +1944,7 @@ class ProjectConfig(object):
|
|||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.merge_mode = None
|
||||
self.default_branch = None
|
||||
self.pipelines = {}
|
||||
self.private_key_file = None
|
||||
|
||||
|
|
Loading…
Reference in New Issue