Verified Commit df1e9fb7 authored by Huste, Tobias (FWCC) - 111645's avatar Huste, Tobias (FWCC) - 111645
Browse files

utils: fix error when no metadata file given

parent 6231b497
Pipeline #8727 passed with stage
in 2 minutes and 57 seconds
......@@ -71,8 +71,12 @@ def get_extra_metadata(gl, project_id, tag):
try:
project = gl.api.projects.get(project_id)
items = project.repository_tree(ref=tag)
file_id = [element['id'] for element in items if element['name'] ==
current_app.config['GITLAB_METADATA_FILE']][0]
try:
file_id = [element['id'] for element in items if
element['name'] ==
current_app.config['GITLAB_METADATA_FILE']][0]
except IndexError:
file_id = None
if file_id:
file_info = project.repository_blob(file_id)
content = base64.b64decode(file_info['content'])
......@@ -83,5 +87,5 @@ def get_extra_metadata(gl, project_id, tag):
except ValueError:
raise CustomGitLabMetadataError(
u'Metadata file "{file}" is not valid JSON.'
.format(file=current_app.config['GITHUB_METADATA_FILE'])
.format(file=current_app.config['GITLAB_METADATA_FILE'])
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment