Retrieves the content of a file from a Git repository (GitHub or GitLab). Args: repo_type (str): Type of repository repo_url (str): The URL of the repository file_path (str): The path to the file within the repository access_token (str, optional): Access tok
(repo_url: str, file_path: str, repo_type: str = None, access_token: str = None)
| 693 | |
| 694 | |
| 695 | def get_file_content(repo_url: str, file_path: str, repo_type: str = None, access_token: str = None) -> str: |
| 696 | """ |
| 697 | Retrieves the content of a file from a Git repository (GitHub or GitLab). |
| 698 | |
| 699 | Args: |
| 700 | repo_type (str): Type of repository |
| 701 | repo_url (str): The URL of the repository |
| 702 | file_path (str): The path to the file within the repository |
| 703 | access_token (str, optional): Access token for private repositories |
| 704 | |
| 705 | Returns: |
| 706 | str: The content of the file as a string |
| 707 | |
| 708 | Raises: |
| 709 | ValueError: If the file cannot be fetched or if the URL is not valid |
| 710 | """ |
| 711 | if repo_type == "github": |
| 712 | return get_github_file_content(repo_url, file_path, access_token) |
| 713 | elif repo_type == "gitlab": |
| 714 | return get_gitlab_file_content(repo_url, file_path, access_token) |
| 715 | elif repo_type == "bitbucket": |
| 716 | return get_bitbucket_file_content(repo_url, file_path, access_token) |
| 717 | else: |
| 718 | raise ValueError("Unsupported repository type. Only GitHub, GitLab, and Bitbucket are supported.") |
| 719 | |
| 720 | class DatabaseManager: |
| 721 | """ |
no test coverage detected