diff --git a/scripts/deploy_gitlab_ci.py b/scripts/deploy_gitlab_ci.py index e673d61db56b69e8ecf23ee927d5c0628f944b2d..c3a1bf0a001916d925fe3070829c33e40804bb08 100755 --- a/scripts/deploy_gitlab_ci.py +++ b/scripts/deploy_gitlab_ci.py @@ -49,6 +49,7 @@ def integrate_submodule_into( ( project_repo, + project_dir, integration_branch_name, integration_commit, message, @@ -67,6 +68,7 @@ def integrate_submodule_into( ret = { "project": gitlab_project, "repo": project_repo, + "dir": project_dir, "branch": integration_branch_name, "commit": integration_commit, "message": message, diff --git a/scripts/update_submodule.py b/scripts/update_submodule.py index d5f6b123ef01ce9dd50bc29bffbfd2f3d1b5c05b..ea8f5a97674be6e9a66f22fd3f86fada88d8288e 100755 --- a/scripts/update_submodule.py +++ b/scripts/update_submodule.py @@ -85,7 +85,7 @@ def clone_project_and_submodule(project: Project, submodule_name, branch=None): # Checkout project try: - repo = Repo.clone_from(clone_url.url, project_dir, branch=branch, depth=1) + repo = Repo.clone_from(clone_url.url, project_dir.name, branch=branch, depth=1) except GitCommandError as e: sys.exit("ERROR: could not clone repository\n" + str(e)) except IndexError: @@ -130,7 +130,9 @@ def clone_project_and_submodule(project: Project, submodule_name, branch=None): with submodule.config_writer() as writer: writer.set("url", submodule_relative_url) - return repo, submodule_project + # We need to keep the TemporaryDirectory object reference project_dir because we + # need the cloned repo later, otherwise the directory will be immediately deleted. + return repo, submodule_project, project_dir def update_submodule_in_repo(repo: Repo, submodule_project: Project, new_revision): @@ -209,6 +211,7 @@ def update_submodule_and_include_ref( submodule_update_needed = True project_repo = None + project_dir = None integration_commit = None if branch is None: @@ -233,7 +236,7 @@ def update_submodule_and_include_ref( "No commits found in range %s, probably submodule already up-to-date.", revision_range, ) - return None, None, None, None + return None, None, None, None, None logging.debug("New commits: %s", commits) # Find out if top commit is part of a merge request @@ -328,7 +331,7 @@ def update_submodule_and_include_ref( clone_branch = integration_branch_name # Actually clone - project_repo, submodule_project = clone_project_and_submodule( + project_repo, submodule_project, project_dir = clone_project_and_submodule( project, submodule_name, clone_branch ) @@ -389,7 +392,13 @@ def update_submodule_and_include_ref( less_verbose=True, ) - return project_repo, integration_branch_name, integration_commit, message + return ( + project_repo, + project_dir, + integration_branch_name, + integration_commit, + message, + ) def main():