Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Henrik Skov Midtiby
gitlab-assignment-handler
Commits
f337a431
Commit
f337a431
authored
Aug 10, 2020
by
Henrik Skov Midtiby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new method add_specific_commit_to_local_repositories.
parent
9a88b115
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
gitlab_class_helper/gitlab_class_helper.py
gitlab_class_helper/gitlab_class_helper.py
+18
-0
No files found.
gitlab_class_helper/gitlab_class_helper.py
View file @
f337a431
...
...
@@ -231,4 +231,22 @@ class GitlabClassHelper:
self
.
push_git_repository_content_to_project
(
path_to_repo
,
repo_id
)
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment