MCPcopy Create free account
hub / github.com/libgit2/pygit2 / Repository

Class Repository

pygit2/repository.py:1787–1830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1785
1786
1787class 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':
1825 cptr = ffi.new('git_repository **')
1826 cptr[0] = ptr
1827 repo = cls.__new__(cls)
1828 BaseRepository._from_c(repo, bytes(ffi.buffer(cptr)[:]), owned) # type: ignore
1829 repo._common_init()
1830 return repo

Callers 2

test_write_tree_toFunction · 0.90
init_repositoryFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_write_tree_toFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…