added repo fetch method

parent 7d53eb15
......@@ -195,6 +195,25 @@ class GitlabClassHelper:
self.clone_repo(local_path, repo_id)
print('Cloned the repository "%s" to "%s"' % (repo, local_path))
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)
repo.git.pull(ssh_url_to_git_repo, 'master')
def clone_repo(self, local_folder: str, project_id: int):
"""
Clone the project into the local folder
......
......@@ -74,6 +74,13 @@ Id of the group: 123.
Working in group: 123 - "test-rmurv2".
Cloned the repository "hw1-adam" to "assignment1/studentresponses/hw1-adam".
Cloned the repository "hw1-birger" to "assignment1/studentresponses/hw1-birger".
>>> # Studens makes updates.
>>> class_helper.fetch_repositories(
repositories = list_of_repo_names['repository'],
local_path_to_fetch_to = "assignment1/studentresponses/")
Working in group: 123 - "test-rmurv2".
Fetched the repository "hw1-adam" to "assignment1/studentresponses/hw1-adam".
Fetched the repository "hw1-birger" to "assignment1/studentresponses/hw1-birger".
>>> # Grade assignments / provide feedback.
>>> class_helper.push_repositories(
repositories = list_of_repo_names['repository'],
......
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