Skip to content
Snippets Groups Projects
Commit 73b9fc5e authored by Ronald Jäpel's avatar Ronald Jäpel
Browse files

Add additional checks and updates for the output_remotes.json

parent 46ca1138
No related branches found
No related tags found
No related merge requests found
......@@ -182,6 +182,8 @@ def clone(project_url, path_to_repo: str = None):
output_folder_name = os.path.join(path_to_repo, meta_dict["output_folder_name"])
ssh_remotes = list(meta_dict["output_remotes"].values())
http_remotes = [ssh_url_to_http_url(url) for url in ssh_remotes]
if len(ssh_remotes + http_remotes) == 0:
raise RuntimeError("No output remotes configured in output_remotes.json")
for output_remote in ssh_remotes + http_remotes:
try:
print(f"Attempting to clone {output_remote} into {output_folder_name}")
......
......@@ -115,6 +115,13 @@ class BaseRepo:
:return:
"""
self._git_repo.create_remote(remote_name, url=remote_url)
with open(self.data_json_path, "r") as handle:
rdm_data = json.load(handle)
if rdm_data["is_project_repo"]:
pass
if rdm_data["is_output_repo"]:
project_repo = ProjectRepo(os.path.split(self.working_dir)[0])
project_repo.update_output_remotes_json()
def import_remote_repo(self, source_repo_location, source_repo_branch, target_repo_location=None):
"""
......@@ -726,17 +733,19 @@ class ProjectRepo(BaseRepo):
Option to add all changed and new files to git automatically.
"""
self.update_output_remotes_json()
super().commit(message=message, add_all=add_all)
def update_output_remotes_json(self):
output_repo_remotes = self.output_repo.remote_urls
self.add_list_of_remotes_in_readme_file("output_repo", output_repo_remotes)
output_json_filepath = os.path.join(self.working_dir, "output_remotes.json")
with open(output_json_filepath, "w") as file_handle:
remotes_dict = {remote.name: str(remote.url) for remote in self.output_repo.remotes}
json_dict = {"output_folder_name": self.output_folder, "output_remotes": remotes_dict}
json.dump(json_dict, file_handle, indent=2)
super().commit(message=message, add_all=add_all)
def download_file(self, url, file_path):
"""
Download the file from the url and put it in the output+file_path location.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment