The Repository constructor will commonly be called with one argument, the path of the repository to open. Alternatively, constructing a repository with no arguments will create a repository with no backends. You can use this path to create repositories with
(
self,
path: str | bytes | None | Path = None,
flags: RepositoryOpenFlag = RepositoryOpenFlag.DEFAULT,
)
| 1786 | |
| 1787 | class Repository(BaseRepository): |
| 1788 | def __init__( |
| 1789 | self, |
| 1790 | path: str | bytes | None | Path = None, |
| 1791 | flags: RepositoryOpenFlag = RepositoryOpenFlag.DEFAULT, |
| 1792 | ): |
| 1793 | """ |
| 1794 | The Repository constructor will commonly be called with one argument, |
| 1795 | the path of the repository to open. |
| 1796 | |
| 1797 | Alternatively, constructing a repository with no arguments will create |
| 1798 | a repository with no backends. You can use this path to create |
| 1799 | repositories with custom backends. Note that most operations on the |
| 1800 | repository are considered invalid and may lead to undefined behavior if |
| 1801 | attempted before providing an odb and refdb via set_odb and set_refdb. |
| 1802 | |
| 1803 | Parameters: |
| 1804 | |
| 1805 | path : str |
| 1806 | The path to open - if not provided, the repository will have no backend. |
| 1807 | |
| 1808 | flags : enums.RepositoryOpenFlag |
| 1809 | An optional combination of enums.RepositoryOpenFlag constants |
| 1810 | controlling how to open the repository. |
| 1811 | """ |
| 1812 | |
| 1813 | if path is not None: |
| 1814 | if hasattr(path, '__fspath__'): |
| 1815 | path = path.__fspath__() |
| 1816 | if not isinstance(path, str): |
| 1817 | path = path.decode('utf-8') |
| 1818 | path_backend = init_file_backend(path, int(flags)) |
| 1819 | super().__init__(path_backend) |
| 1820 | else: |
| 1821 | super().__init__() |
| 1822 | |
| 1823 | @classmethod |
| 1824 | def _from_c(cls, ptr: 'GitRepositoryC', owned: bool) -> 'Repository': |
no test coverage detected