Skip to content

Commit

Permalink
hard coded search type
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-armah committed Oct 30, 2024
1 parent 3b8aa2e commit ee946ee
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
3 changes: 0 additions & 3 deletions integrations/gitlab/gitlab_integration/git_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ class FilesSelector(BaseModel):
repos: List[str] = Field(
description="A list of repositories to search files in", default_factory=list
)
search_type: Literal["zoekt", "advanced", "basic"] = Field(
alias="searchType", default="advanced"
)


class GitLabFilesSelector(Selector):
Expand Down
4 changes: 2 additions & 2 deletions integrations/gitlab/gitlab_integration/gitlab_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def get_all_file_paths(
]

async def search_files_in_project(
self, project: Project, path: str | List[str], search_type: str
self, project: Project, path: str | List[str]
) -> AsyncIterator[list[dict[str, Any]]]:
logger.info(
f"Searching project {project.path_with_namespace} for files with path pattern {path}"
Expand All @@ -176,7 +176,7 @@ async def search_files_in_project(
project.search,
scope="blobs",
search=f"filename:{file_pattern}",
search_type=search_type,
search_type="advanced",
retry_transient_errors=True,
):
logger.info(
Expand Down
4 changes: 1 addition & 3 deletions integrations/gitlab/gitlab_integration/ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ async def resync_files(kind: str) -> ASYNC_GENERATOR_RESYNC_TYPE:
matching_projects.append(project)
tasks.append(
service.search_files_in_project(
project,
selector.files.path,
selector.files.search_type,
project, selector.files.path
)
)

Expand Down
2 changes: 1 addition & 1 deletion integrations/gitlab/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gitlab"
version = "0.1.135-rc2"
version = "0.1.135-rc3"
description = "Gitlab integration for Port using Port-Ocean Framework"
authors = ["Yair Siman-Tov <[email protected]>"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def test_search_files_in_folders_in_project(
# Act
actual_files = []
async for file in mocked_gitlab_service.search_files_in_project(
mock_project, search_pattern, search_type="basic"
mock_project, search_pattern
):
actual_files.extend(file)

Expand All @@ -52,15 +52,14 @@ async def test_search_files_in_project(
) -> None:
# Arrange
search_pattern = "**/file.yaml"
search_type = "basic"

mock_project = MagicMock()
monkeypatch.setattr(mock_project, "search", mock_search)
expected_files = ["hello/aaa/file.yaml", "hello/my/file.yaml"]
# Act
actual_files = []
async for file in mocked_gitlab_service.search_files_in_project(
mock_project, search_pattern, search_type
mock_project, search_pattern
):
actual_files.extend(file)

Expand All @@ -83,7 +82,7 @@ async def test_search_files_invalid_glob_in_project(
# Act
actual_files = []
async for file in mocked_gitlab_service.search_files_in_project(
mock_project, search_pattern, search_type="basic"
mock_project, search_pattern
):
actual_files.extend(file)

Expand Down Expand Up @@ -114,7 +113,7 @@ async def test_search_generic_files_inside_folder_inside_folder_in_project(
# Act
actual_files = []
async for file in mocked_gitlab_service.search_files_in_project(
mock_project, search_pattern, search_type="basic"
mock_project, search_pattern
):
actual_files.extend(file)

Expand Down

0 comments on commit ee946ee

Please sign in to comment.