in fog-updater/src/fog_update.py [0:0]
def _rewrite_repositories_yaml(repo, branch, data, debug=False):
contents = repo.get_contents("repositories.yaml", ref=branch)
content = contents.decoded_content.decode("utf-8")
new_content = content
for item in data:
name, metrics_or_pings, library, files = item
new_content = swap_file_list(
new_content, name, files, metrics_or_pings, library
)
if content == new_content:
raise UnmodifiedException(
"Update to repositories.yaml resulted in no changes: maybe the file was already up to date?" # noqa
)
if debug:
diff = difflib.unified_diff(
content.splitlines(keepends=True),
new_content.splitlines(keepends=True),
fromfile="old/repositories.yaml",
tofile="new/repositories.yaml",
)
sys.stdout.writelines(diff)
return new_content