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

Add add_remote and push functionality and test

parent 76f7651c
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,20 @@ class BaseRepo:
self._earliest_commit = earliest_commit
return self._earliest_commit
def add_remote(self, remote_url, remote_name="origin"):
self.git_repo.create_remote(remote_name, url=remote_url)
def push(self, remote=None, local_branch=None, remote_branch=None):
if local_branch is None:
local_branch = self.active_branch
if remote_branch is None:
remote_branch = local_branch
if remote is None:
remote = list(sorted(self.git_repo.remotes.keys()))[0]
remote_interface = self.git_repo.remotes[remote]
remote_interface.push(refspec=f'{local_branch}:{remote_branch}')
def delete_active_branch_if_branch_is_empty(self):
"""
Delete the currently active branch and checkout the master branch
......@@ -317,7 +331,7 @@ class ProjectRepo(BaseRepo):
"Output repo commit hash": output_repo_hash,
"Project repo commit hash": str(self.head.commit),
"Project repo folder name": os.path.split(self.working_dir)[-1],
"Project repo remotes": self.remotes,
"Project repo remotes": [str(remote.url) for remote in self.remotes],
}
csv_header = ",".join(meta_info_dict.keys())
csv_data = ",".join([str(x) for x in meta_info_dict.values()])
......@@ -471,4 +485,3 @@ class ProjectRepo(BaseRepo):
class ResultsRepo(BaseRepo):
pass
......@@ -128,10 +128,17 @@ def try_load_previous_result(path_to_repo, branch_name):
assert os.path.exists(extended_array_file_path)
def try_add_remote(path_to_repo):
repo = ProjectRepo(path_to_repo)
repo.add_remote("git@jugit.fz-juelich.de:IBG-1/ModSim/cadet/CADET-RDM.git")
assert "origin" in repo.git_repo.remotes
def test_cadet_rdm(path_to_repo):
# because these depend on one-another and there is no native support afaik for sequential tests
# these tests are called sequentially here as try_ functions.
try_initialize_git_repo(path_to_repo)
try_add_remote(path_to_repo)
try_commit_code(path_to_repo)
try_commit_code_without_code_changes(path_to_repo)
results_branch_name = try_commit_results_data(path_to_repo)
......
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