Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions gitlab_submodule/submodule_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
from os import path
from typing import Optional, Union

from gitlab.exceptions import GitlabGetError
from gitlab.exceptions import GitlabGetError, GitlabHttpError
from gitlab.v4.objects import Project, ProjectCommit

from gitlab_submodule.objects import Commit, Submodule


logger = logging.getLogger(__name__)


Comment on lines -11 to -14
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side cleanup

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -54,7 +50,7 @@ def _get_submodule_commit_id(
submodule_dir = project.files.get(
submodule_path,
ref=ref if ref else project.default_branch)
except GitlabGetError:
except (GitlabGetError, GitlabHttpError):
raise FileNotFoundError(
f'Local submodule path "{submodule_path}" was not found for '
f'project at url "{project.web_url}" - check if your .gitmodules '
Expand Down
7 changes: 3 additions & 4 deletions gitlab_submodule/submodule_to_project.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from typing import List, Optional, Union

import logging
import re
from posixpath import join, normpath
from typing import List, Optional, Union

from gitlab.exceptions import GitlabGetError
from gitlab.exceptions import GitlabGetError, GitlabHttpError
from gitlab.v4.objects import Project, ProjectManager
from giturlparse import GitUrlParsed, parse

Expand All @@ -28,7 +27,7 @@ def submodule_to_project(
try:
submodule_project = project_manager.get(
submodule_project_path_with_namespace)
except GitlabGetError:
except (GitlabGetError, GitlabHttpError):
Comment on lines -31 to +30
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mertemba would you agree that it makes more sense to catch the GitlabHttpError here?
The FileNotFoundError does not come from python-gitlab actually, it comes from my code (see the raise FileNotFoundError at line 33/34 below)

# Repo doesn't actually exist (possible because you can modify
# .gitmodules without using `git submodule add`)
raise FileNotFoundError(
Expand Down