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
0946f6cf
Commit
0946f6cf
authored
Sep 05, 2020
by
Henrik Skov Midtiby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the method fetch_repositories.
parent
b0d52d1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
gitlab_class_helper/gitlab_class_helper.py
gitlab_class_helper/gitlab_class_helper.py
+20
-0
No files found.
gitlab_class_helper/gitlab_class_helper.py
View file @
0946f6cf
...
...
@@ -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.
...
...
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