Commit f337a431 authored by Henrik Skov Midtiby's avatar Henrik Skov Midtiby
Browse files

Added new method add_specific_commit_to_local_repositories.

parent 9a88b115
...@@ -231,4 +231,22 @@ class GitlabClassHelper: ...@@ -231,4 +231,22 @@ class GitlabClassHelper:
self.push_git_repository_content_to_project(path_to_repo, repo_id) self.push_git_repository_content_to_project(path_to_repo, repo_id)
print('Pushed the repository "%s" to "%s"' % (path_to_repo, repo)) print('Pushed the repository "%s" to "%s"' % (path_to_repo, repo))
def add_specific_commit_to_local_repositories(self, repositories: List[str], local_path: str, local_reference_path: str, commit_id: str):
"""
Push local repositories to remote repositories.
"""
teacher_repo = git.Repo(local_reference_path)
for repo in set(repositories):
path_to_repo = os.path.join(local_path, repo)
student_repo = git.Repo(path_to_repo)
# Fetch data from the teacher repository
student_repo.git.fetch(teacher_repo.working_tree_dir)
# Cherry pick a specific commit from the teacher repository
try:
student_repo.git.cherry_pick(commit_id)
print('Added a specific commit to local repository "%s" to "%s"' % (path_to_repo, commit_id))
except git.GitCommandError as e:
print("The git command failed")
print(e)
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