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

Method iterator

pygit2/references.py:63–95  ·  view source on GitHub ↗

Creates a new iterator and fetches references for a given repository. Can also filter and pass all refs or only branches or only tags. Parameters: references_return_type: ReferenceFilter Optional specifier to filter references. By default, all references are

(
        self, references_return_type: ReferenceFilter = ReferenceFilter.ALL
    )

Source from the content-addressed store, hash-verified

61 return
62
63 def iterator(
64 self, references_return_type: ReferenceFilter = ReferenceFilter.ALL
65 ) -> Iterator['Reference']:
66 """Creates a new iterator and fetches references for a given repository.
67
68 Can also filter and pass all refs or only branches or only tags.
69
70 Parameters:
71
72 references_return_type: ReferenceFilter
73 Optional specifier to filter references. By default, all references are
74 returned.
75
76 The following values are accepted:
77 - ReferenceFilter.ALL, fetches all refs, this is the default
78 - ReferenceFilter.BRANCHES, fetches only branches
79 - ReferenceFilter.TAGS, fetches only tags
80
81 TODO: Add support for filtering by reference types notes and remotes.
82 """
83
84 # Enforce ReferenceFilter type - raises ValueError if we're given an invalid value
85 references_return_type = ReferenceFilter(references_return_type)
86
87 iter = self._repository.references_iterator_init()
88 while True:
89 ref = self._repository.references_iterator_next(
90 iter, references_return_type
91 )
92 if ref:
93 yield ref
94 else:
95 return
96
97 def create(self, name: str, target: Oid | str, force: bool = False) -> 'Reference':
98 return self._repository.create_reference(name, target, force)

Calls 1

ReferenceFilterClass · 0.85