Commit 0946f6cf authored by Henrik Skov Midtiby's avatar Henrik Skov Midtiby

Added the method fetch_repositories.

parent b0d52d1d
......@@ -234,6 +234,26 @@ class GitlabClassHelper:
ssh_url_to_git_repo = self.get_project_ssh_url(project_id)
git.Repo.clone_from(ssh_url_to_git_repo, local_folder)
def fetch_repositories(self, repositories: List[str], local_path_to_fetch_to: str, group_id: int = None):
"""
Fetch all repositories in "repositories"
"""
use_group_id, _ = self.check_group_id(group_id)
for repo in repositories:
repo_id = self.get_repo_id(repo, use_group_id)
path_to_repo = os.path.join(local_path_to_fetch_to, repo)
self.fetch_repo(path_to_repo, repo_id)
print('Fetched the repository "%s" to "%s"' % (repo, local_path_to_fetch_to))
def fetch_repo(self, local_folder: str, project_id: int):
"""
fetched the project
"""
repo = git.Repo(local_folder)
ssh_url_to_git_repo = self.get_project_ssh_url(project_id)
print(repo.git.pull(ssh_url_to_git_repo, 'master'))
def push_repositories(self, repositories: List[str], local_path: str, group_id: int = None):
"""
Push local repositories to remote repositories.
......
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