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

Function test_refspec

test/test_remote.py:136–179  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

134
135
136def test_refspec(testrepo: Repository) -> None:
137 remote = testrepo.remotes['origin']
138
139 assert remote.refspec_count == 1
140 refspec = remote.get_refspec(0)
141 assert refspec.src == REMOTE_FETCHSPEC_SRC
142 assert refspec.dst == REMOTE_FETCHSPEC_DST
143 assert refspec.force is True
144 assert ORIGIN_REFSPEC == refspec.string
145
146 assert list is type(remote.fetch_refspecs)
147 assert 1 == len(remote.fetch_refspecs)
148 assert ORIGIN_REFSPEC == remote.fetch_refspecs[0]
149
150 assert refspec.src_matches('refs/heads/master')
151 assert refspec.dst_matches('refs/remotes/origin/master')
152 assert 'refs/remotes/origin/master' == refspec.transform('refs/heads/master')
153 assert 'refs/heads/master' == refspec.rtransform('refs/remotes/origin/master')
154
155 assert list is type(remote.push_refspecs)
156 assert 0 == len(remote.push_refspecs)
157
158 push_specs = remote.push_refspecs
159 assert list is type(push_specs)
160 assert 0 == len(push_specs)
161
162 testrepo.remotes.add_fetch('origin', '+refs/test/*:refs/test/remotes/*')
163 remote = testrepo.remotes['origin']
164
165 fetch_specs = remote.fetch_refspecs
166 assert list is type(fetch_specs)
167 assert 2 == len(fetch_specs)
168 assert [
169 '+refs/heads/*:refs/remotes/origin/*',
170 '+refs/test/*:refs/test/remotes/*',
171 ] == fetch_specs
172
173 testrepo.remotes.add_push('origin', '+refs/test/*:refs/test/remotes/*')
174
175 with pytest.raises(TypeError):
176 testrepo.remotes.add_fetch(['+refs/*:refs/*', 5]) # type: ignore
177
178 remote = testrepo.remotes['origin']
179 assert ['+refs/test/*:refs/test/remotes/*'] == remote.push_refspecs
180
181
182def test_remote_list(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 7

get_refspecMethod · 0.80
src_matchesMethod · 0.80
dst_matchesMethod · 0.80
transformMethod · 0.80
rtransformMethod · 0.80
add_fetchMethod · 0.80
add_pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…