Skip to content

Commit 0ed164d

Browse files
[PATCH] Catch GitlabHttpError (#31)
* Catch Gitlab HTTP error for missing submodules since Gitlab 1.74 --------- Co-authored-by: Max Mertens <max.mertens@uni-ulm.de>
1 parent d102362 commit 0ed164d

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

gitlab_submodule/submodule_commit.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
from os import path
44
from typing import Optional, Union
55

6-
from gitlab.exceptions import GitlabGetError
6+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
77
from gitlab.v4.objects import Project, ProjectCommit
88

99
from gitlab_submodule.objects import Commit, Submodule
1010

11-
12-
logger = logging.getLogger(__name__)
13-
14-
1511
logger = logging.getLogger(__name__)
1612

1713

@@ -54,7 +50,7 @@ def _get_submodule_commit_id(
5450
submodule_dir = project.files.get(
5551
submodule_path,
5652
ref=ref if ref else project.default_branch)
57-
except GitlabGetError:
53+
except (GitlabGetError, GitlabHttpError):
5854
raise FileNotFoundError(
5955
f'Local submodule path "{submodule_path}" was not found for '
6056
f'project at url "{project.web_url}" - check if your .gitmodules '

gitlab_submodule/submodule_to_project.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from typing import List, Optional, Union
2-
31
import logging
42
import re
53
from posixpath import join, normpath
4+
from typing import List, Optional, Union
65

7-
from gitlab.exceptions import GitlabGetError
6+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
87
from gitlab.v4.objects import Project, ProjectManager
98
from giturlparse import GitUrlParsed, parse
109

@@ -28,7 +27,7 @@ def submodule_to_project(
2827
try:
2928
submodule_project = project_manager.get(
3029
submodule_project_path_with_namespace)
31-
except GitlabGetError:
30+
except (GitlabGetError, GitlabHttpError):
3231
# Repo doesn't actually exist (possible because you can modify
3332
# .gitmodules without using `git submodule add`)
3433
raise FileNotFoundError(

0 commit comments

Comments
 (0)