Skip to content

Commit

Permalink
Use normpath for file path when getting file in GitLab
Browse files Browse the repository at this point in the history
So that the behaviour is consistent among forges. GitLab
cannot do this automatically.

Related to #838
  • Loading branch information
lbarcziova committed Mar 1, 2024
1 parent 7fc0829 commit b79a9d6
Show file tree
Hide file tree
Showing 3 changed files with 632 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ogr/services/gitlab/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

import logging
import os
from typing import Any, Optional, Union

import gitlab
Expand Down Expand Up @@ -361,6 +362,8 @@ def get_branches(self) -> list[str]:

def get_file_content(self, path, ref=None) -> str:
ref = ref or self.default_branch
# GitLab cannot resolve './'
path = os.path.normpath(path)
try:
file = self.gitlab_repo.files.get(file_path=path, ref=ref)
return file.decode().decode()
Expand Down
Loading

0 comments on commit b79a9d6

Please sign in to comment.