Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Rob Jennings
git-export-import
Commits
6ba00fbe
Commit
6ba00fbe
authored
4 months ago
by
Rob Jennings
Browse files
Options
Download
Email Patches
Plain Diff
Limit the amount of import attempts before skipping
parent
599d9802
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
git_migration/project_migration.py
git_migration/project_migration.py
+8
-0
No files found.
git_migration/project_migration.py
View file @
6ba00fbe
...
...
@@ -4,6 +4,8 @@ import requests
import
time
from
pathlib
import
Path
COUNT_THRESHOLD
=
15
class
ProjectExportImport
:
"""Helper class for exporting / importing a gitlab project."""
...
...
@@ -30,6 +32,7 @@ class ProjectExportImport:
self
.
ci_cd_json_path
=
None
self
.
source_namespace
=
source_namespace
self
.
dest_namespace
=
dest_namespace
self
.
import_status_count
=
0
@
staticmethod
def
get_headers
(
token
):
...
...
@@ -175,6 +178,9 @@ class ProjectExportImport:
proj_id
=
resp
.
json
()[
"id"
]
while
not
self
.
get_import_status
(
proj_id
):
time
.
sleep
(
20
)
self
.
import_status_count
+=
1
if
self
.
import_status_count
>
COUNT_THRESHOLD
:
raise
Exception
(
"Too many import status requests. Skipping import..."
)
print
(
"Import complete!"
)
return
proj_id
...
...
@@ -186,6 +192,8 @@ class ProjectExportImport:
print
(
"Import status is: "
,
resp
.
json
()[
"import_status"
])
if
resp
.
json
()[
"import_status"
]
in
[
"finished"
]:
return
True
if
resp
.
json
()[
"import_status"
]
==
"failed"
:
raise
Exception
(
"Import failed. Skipping project..."
)
return
False
def
import_environments
(
self
,
proj_id
):
...
...
This diff is collapsed.
Click to expand it.
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